Where do I start if I want to write a wayland compositor? - wayland

I imagine there isn't a "Beginner's guide to wayland server programming" drifting around the web, and the weston source looks daunting.
Is there a barebones wayland server I can look at to give me an idea where to start? Something I can run under X that I can confirm is recieving input. I'm sure I can go from there.

Take a look at the Small Wayland Compositor. You can either use it as library to build upon, or check out how it does things internally if you want to start from scratch.

I wrote a minimal wayland compositor that runs on top of X11 with the hope that it might be useful for other people who want to learn how to write a wayland compositor.
It's about 500 lines of code that are really just the minimal code that is needed to host multiple instances of weston-terminal and move them around.

I can only recommend to take a look at the KWayland sources (especially if you're interested in how the wayland protocol maps to an object oriented world).
KWayland is an object oriented (C++/Qt) wrapper around the wayland client and server libraries and it also includes a minimal server (tests/renderingservertest.cpp).

Related

Talking to Arduino from Scala

Is there a standard way to control an Arduino from Scala? If not I am interested in hacking one together, but am unsure of where I should start. The Firmata library seemed like the way to go but there is no Java or Scala interface. SPDE supports Processing pretty well, but I see no Arduino functionality there. I also have a few snippets of Java<->Arduino example code scoured from the Arduino playground and other sources, but nothing comprehensive.
If anyone knows of a Scala or straight Java (I can just wrap it in Scala) way to do this, or has suggestions on rolling my own interface, I would like to hear about it.
Thanks.
Any programming language can be used to communicate between the serial ports of the PC and arduino,as long as the programs running on both sides can make make sense of the data exchanged.RxTX is a java library for serial port communication.Hope this helps.
You might want to check out apache MINA, which provides some nice wrapping around the RXTX libraries and offers an API that's friendly to idiomatic Scala.
I've already had some success with this approach in driving an X10 controller for home automation.

Communication between applications written in different languages

I am looking at linking a few applications together (all written in different languages like C#, C++, Python) and I am not sure how to go about it.
What I mean by linking? The system I am working on consists of small programs each responsible for a particular processing task. I need to be able to transfer a data set from one application to another easily (the data set in question is not huge, probably a few megabytes) and I also need some form of way to control the current state of the operation (This is where a client-server model rings a bell)
It seems like sockets or maybe SOAP would be a universal solution but just wanted to get some opinions as to what people think about this subject.
Comments/suggestions will be appreciated, thanks!
I personally take a liking towards ØMQ. It's a library that has a familiar BSD-sockets-like interface for passing messages, but you'll find it implements interesting patterns for distributing tasks.
It sounds like you want to arrange several processes in a pipeline. ØMQ allows you to do that using push and poll sockets. (And afterwards, you'll find it's even possible to scale up across multiple processes and machines with little effort.) Take a look at the guide to get started, and the zmq_socket(3) manpage specifically for how push and pull works.
Bindings are available for all the languages you mention.
As for the contents of the message, ØMQ doesn't concern itself with that, they are just blocks of raw data. You can use any format that suits you, such as JSON, or perhaps Protocol Buffers.
What I'm not sure about is the ‘controlling state’ you mention. Are you interested in, for example, cancelling a job halfway through?
For C# to C# you can use Windows Communication Foundation. You may be able to use it with Python and C++ as well.
You may also want to checkout named pipes.
I would think about moving to a model where you eliminate the issue by having centralized data that all of the applications look at. Keep "one source of the truth" so to speak.
Most outside software has trouble linking against C++ code, due to the name-mangling algorithm it uses for its symbols. For that reason, when interfacing with programs written in other languages, it is often best to declare wrappers to things as extern "C" or inside an extern "C" { block.
I need to be able to transfer a data set from one application to another easily (the data set in question is not huge, probably a few megabytes)
Use the file system.
and I also need some form of way to control the current state of the operation
Again, use the file system. A "current_state.json" file with a JSON serialized object is perfect for multiple languages to work with.
It seems like sockets or maybe SOAP would be a universal solution.
Perhaps. But it's overkill for this kind of thing. Your OS already has all the facilities you need. Just use the file system. It's very simple and very reliable.
There are many ways to do interprocess communication. As you said, sockets may be a universal solution. SOAP, i think, is somewhat an overkill. You may also use mailslots. I wrote C++ application using it a couple of years ago. Named pipes could be also a solution, but if you are coding on Windows, it may be difficult.
In my opinion:
Sockets
Mailslots
Are the best candidates.

Possible to port gui functions with swig

I was wondering if it would be possible to port the gtk gui framework to Go with the swig wrapper? Or am I just living in a fantasy world?
Technically, yes. It looks like SWIG support for Go is limited right now.
The real problem with simple SWIG wrappers is the ugly details leak through. The produced interface would need a layer on top of it in order to provide "Goish" behavior, especially in regards to garbage collection and interfaces.
Yes, it's possible. SWIG isn't even strictly necessary, but it does make the process more automatic.
There's already a GTK binding for Go in progress here:
http://github.com/mattn/go-gtk

Are there some up-to-date tutorials on Perl network programming?

Are there links, materials, or books about network programming with Perl that are relevant to 2010? I saw some books on programming the network with Perl are very old (about a decade) and the tutorials on the internet are also old and using old modules.
Could someone provide a good reference about programming sockets and network layer/application layer protocols with Perl that are updated to 2010?
This task really demands an asynchronous framework: pretty much everyone uses POE these days. I hate it because for me it doesn't look like Perl. It looks like its own special silly premature-optimized language. Anyway, you can find more info on cpan's docs about poe.
The internals of POE are weird, and POE does rather silly stuff like statically index the contents of #_ for "speed". A POE-component looks like a little brick of voodoo-dung right in the middle of your code. You might like it, give it a shot. If you have to debug it or expand POE::Kernel you might want to look for employment elsewhere.
There is a growing alternative too: AnyEvent. I'd look at it first. It does things massively different and is a much thinner layer that doesn't want to infest your whole application.
Links:
AnyEvent::Socket
POE SocketFactory
Although Lincoln Stein's Network Programming with Perl is a bit old, the content is still mostly good. Network programming at that level hasn't changed that much in the last couple of decades. If you want to learn to play with sockets, that's the book to get to get you started.
However, Perl at the socket level does that same thing the C libraries do. There might be some nice interfaces around it, but look under the interface and you'll see the same things.

How hard would it to create a media player (gui fronteend for mplayer), need guiddance for getting started

I am pretty dissatisfied with all the available media players, and I was also looking for a major project to really get into programming. so I am thinking of writing my own media player . Or to be more accurate a gui-frontend for mplayer (something similar to smplayer). How hard would this be.? I have plenty of time (months), and am willing to learn anything.
I practically don't have any knowledge of any windows/gui libraries . My programming experience : tried lots of different languages, wrote a couple of websites in php, lots of practice in java (although did nothing major) . Thats all
Can someone provide some guidance, about where to get started. what all to read. Which language should be used. is C#/.net a good language for this? since I am no expert in any language and have dabbled in plenty of different languages , I think I can pick up any language. Though My main concern is my lack of any practical knowledge . So guide me please.
Lastly my preference is windows (haha whatever), so thats what my target is and thats where I'll doing my coding.
To sum it up I want to create a guifrontend for mplayer that would work in windows.
Thanks
Edit: by mplayer I mean mplayer (the linux one) , and not WIndows media player.
One good place to start could be looking at how the code for gmplayer works - gmplayer is the graphic frontend for mplayer on Linux. It could be that all you really need to do is port the gmplayer code to Windows, then you get a fully integrated GUI instead of just a frontend.
Also, feature request: a nice friendly UI for putting video / audio effects on the output stream (it is so hard to use in the CLI version that most mplayer users probably don't even know it is in there).
I know what I'm going to recommend you is not what you're looking for, BUT:
I'd create a front-end for VLC, which uses Qt, a GUI framework which is extremely usable and easy to start with, in C++.
From my experience as an user, VLC is also more stable and has more features.
Start by copying a working implementation. As you mentioned, SMPlayer exists as a working example of what you want. I'd recommend starting by either hacking it to work better (the playlist really needs more intuitive controls, and multiple monitor support in Windows was nonexistent last time I tried it) or trying to duplicate it in your language of choice.
The benefits of hacking on an existing probject include: the existing codebase works, the margin of work required to make a noticeable change is much smaller, and the existing developers are able to help you come to speed with internals. Also, learning the project's language (C++) would be useful, though it may not be worth the effort if it's more interesting to copy its features in your favorite language.
C# is great for creating any desktop gui quickly. Best way to start with the gui design is to play a bit with the drag/drop components available in visual studio. For the functionality you can use this: http://msdn.microsoft.com/en-us/library/dd564585%28VS.85%29.aspx .