Creating a window manager for Linux

南笙酒味 提交于 2019-11-29 20:42:52

Whatever you do, use XCB and not Xlib. It' modern, asynchronous, simpler and gives you direct access to the X11 protocol.

A very minimalistic WM is wm2. I haven't read the source code and hence I don't know if it is a teaching example. Of course you can use libraries that already do much of the abstraction and drawing work for you like gdk and gtk. But since this project is only for personal learning, I'd go the hard way and use Xlib directly.

Here are some links that might be useful for you:

Have a look at the code for dwm. The codebase is beautiful and easy to understand. The entire thing is about 2000 lines.

I've written an in-depth tutorial series that shows you how to write an X11 window manager in C++:

In addition, you can check out a simple example window manager, basic_wm, at

It's heavily commented for pedagogical purposes.

On Xlib vs XCB - I would recommend Xlib over XCB if you're first starting out. XCB is more efficient, but it's much more low-level and much more verbose (think assembly language for the GUI). You don't want to burden yourself with premature optimization until you already have a prototype working.

http://code.google.com/p/partiwm/ is an attempt to write a window manager (tiling, not stacking) from scratch, it might be useful to you to read through the code.

Havoc P

metacity uses gtk for certain UI elements. See its HACKING and README.

see also Where are some good Xlib programming guides?

For the sake of understanding I would also be interested in suggestions how to start a window manager from scratch

You may want to have a look at the aewm window manager. The code is small and it does the basics quite well. It's written in C and uses Xlib.

http://www.red-bean.com/decklin/aewm/

Xmonad might be a good place to start.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!