You are not logged in.

#1 2012-09-25 19:40:59

examon
Member
Registered: 2011-05-07
Posts: 208

Good way to start with the WM programming?

I follow "Community Contributions" and I'm testing every new WM what's out there. I know C and I would like to write the WM. How did you learn to write your first WM?

What would you suggest to starting WM programmer? Reading Xlib (or others) reference manuals or just studying other WM's source code? Or something else?

Offline

#2 2012-09-25 19:53:35

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: Good way to start with the WM programming?

I'm working on writing a window manager currently (not quite ready for release), but I'd suggest diving right in. Xlib / XCB seem really daunting (and, quite honestly, they are) but you'll learn more more quickly -- even if it is a bit more frustrating.

I'm also writing mine in Python, which may or may not be a mistake. C's Xlib is much better documented than Python's port, which can make it super frustrating to try and find out how to do what you want done.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#3 2012-09-25 20:08:53

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Good way to start with the WM programming?

How do you learn best? Do you like to reverse-engineer other people's code, or do you prefer reading the specs and starting from scratch?

If you like to start with other people's code, take a look at TinyWM (it's in the AUR). It's only 50 lines of C and the code is heavily annotated. It also comes with a version written in python. Tiny Tiler / Tabbed Tiler Window Manager (ttwm) is based on TinyWM, and it's also in the AUR.

You could also look at some of the minimal tiling WMs people have written loosely based on dwm (catwm, dminiwm, monsterwm, and snapwm to name a few).

Last edited by 2ManyDogs (2012-09-25 20:18:28)

Offline

#4 2012-09-25 20:44:55

examon
Member
Registered: 2011-05-07
Posts: 208

Re: Good way to start with the WM programming?

@2ManyDogs
@synogy

I've checked TinyWM and I understand it pretty good cos it's really simple, but I'm interested in something more complex (like workspaces implementation, tiling, etc.).

Going to check out catwm, ttwm, ...

Offline

#5 2012-09-25 23:27:21

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: Good way to start with the WM programming?

I can testify that catwm is a nice wm to start off working with. It uses simple syntax, there's not too many lines to scroll through and it has a couple of bugs that'll need fixing. One of the first things I did when starting off with it was to reorder the functions so I could have a better idea of the 'flow' of the wm processes and how xlib works.
Thanks again pyknite for sharing it. smile


You're just jealous because the voices only talk to me.

Offline

#6 2012-09-26 01:13:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Good way to start with the WM programming?

TTWM's code is a complete mess.  I don't know what kind of fool is responsible for that collection of kludges! wink

I'll second the recommendation for TinyWM, but once you want to dig deeper I'd suggest looking at other non-reparenting window managers.  I don't know of any non-reparenting floating WMs other than TinyWM, so that may leave you with the tilers - many of which have been mentioned.

Dwm is a good choice.  That is some finely polished code that has some bright people working for some time to perfect it.  But it has the downside for learning that it does implement many more "complex" features.  It can also be hard to follow the program logic sometimes as there are so many function calls - you have to scroll back and forth through the code while trying not to lose your place ... bring your breadcrumbs.

In my own coding I try to minimize function calls - not for optimizing the code, as the compiler will handle this pretty well - but for making it more readable.  In every place where a series of actions will be executed in a linear order, I try to keep the commands presented in a linear order within the same function.  Along with this I avoid complicate macros or inline functions: if they'll be inlined anyways, there is no saving on resource use at run time, but only saving a few lines of code while sacrificing the ease of reading and understanding.

Also, if you have not found it yet, I highly recommend Christophe Tronche's Xlib guide.  I can't say I ever just read through it from start to finish (yet), but when I google any Xlib related function if there are any entries on tronche.com that is the first one (and then often the only one) I look at.

PS: there's nothing fancy about workspaces/desktops.  You just maintain a list of client windows on each desktop - or have "tags" associated with each client - then when the user changes desktops you just hide all windows that are not on that desktop/tag and show those that are.  Hiding can mean "unmapping" but I preferred an easier hack which I found the dwm authors also used: just move the window (XMoveWindow) off of the screen. Unmapping might even be problematic as it generates a set of events when unmapped and remapped.  This can be remedied and there may be good ways of doing this, but moving off screen works for me.

Last edited by Trilby (2012-09-26 01:32:22)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB