Creating a window manager for Linux

2019-01-31 03:35发布

I want to create a simple stacking window manager (in C) for private use, mainly for the purpose of learning and challenging myself.

I've looked through twm's source code which has relatively few bells and whistles but it seems very low level since it's not based on a widget toolkit.1 Would using a toolkit such as GTK+ be preferable? I'm afraid that some of the code and libraries in twm might be too antiquated (edit: deprecated) and I want the window manager to use relatively modern libraries. For the sake of understanding I would also be interested in suggestions how to start a window manager from scratch — there aren't many tutorials for this purpose.

Update: For those thinking of similar projects: I ended up using Common Lisp and the CLX library. tinywm-lisp served as a basis and the brilliant CLFSWM and Stumpwm were a great help. For reference I used the CLX — Common LISP X Interface (PDF warning) and #xlib on Freenode.

8条回答
Evening l夕情丶
2楼-- · 2019-01-31 03:56

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

查看更多
乱世女痞
3楼-- · 2019-01-31 03:56

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.

查看更多
贪生不怕死
4楼-- · 2019-01-31 03:59

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

查看更多
叼着烟拽天下
5楼-- · 2019-01-31 04:04

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

see also Where are some good Xlib programming guides?

查看更多
Bombasti
6楼-- · 2019-01-31 04:14

Xmonad might be a good place to start.

查看更多
孤傲高冷的网名
7楼-- · 2019-01-31 04:18

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/

查看更多
登录 后发表回答