24

我想创建一个简单的堆叠窗口管理器(中C)供私人使用,主要是为了学习和挑战自己。

我查看了twm的源代码,它的花里胡哨的东西相对较少,但它似乎非常低级,因为它不是基于小部件工具包。1使用 GTK+ 之类的工具包会更好吗?我担心其中的一些代码和库twm可能过于陈旧(编辑:不推荐),我希望窗口管理器使用相对现代的库。为了理解起见,我也对如何从头开始启动窗口管理器的建议感兴趣 - 没有很多用于此目的的教程。

更新:对于那些考虑类似项目的人:我最终使用了 Common Lisp 和CLX 库tinywm-lisp作为基础,出色的CLFSWMStumpwm提供了很大帮助。作为参考,我在 Freenode 上使用了CLX — Common LISP X InterfacePDF 警告) 。#xlib

4

8 回答 8

24

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

于 2010-08-13T17:01:04.283 回答
10

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.

于 2014-12-10T04:01:42.957 回答
6

一个非常简约的 WM 是wm2。我没有阅读源代码,因此我不知道它是否是一个教学示例。当然,您可以使用已经为您完成大量抽象和绘图工作的库,例如gdkgtk。但是由于这个项目只是为了个人学习,我会很努力地直接使用Xlib。

以下是一些可能对您有用的链接:

于 2010-08-12T23:07:53.850 回答
6

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

于 2011-07-21T06:06:15.577 回答
2

http://code.google.com/p/partiwm/尝试从头开始编写窗口管理器(平铺,而不是堆叠),通读代码可能对您有用。

于 2010-08-12T22:34:01.807 回答
2

metacity 对某些 UI 元素使用 gtk。请参阅其 HACKING 和 README。

另请参阅哪里有一些好的 Xlib 编程指南?

于 2010-08-13T16:57:28.970 回答
2

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/

于 2010-11-30T22:43:44.683 回答
0

Xmonad might be a good place to start.

于 2010-09-25T09:27:19.570 回答