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.
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.
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.
发布评论
评论(8)
无论您做什么,请使用 XCB 而不是 Xlib。它现代、异步、更简单,让您可以直接访问 X11 协议。
Whatever you do, use XCB and not Xlib. It' modern, asynchronous, simpler and gives you direct access to the X11 protocol.
我编写了一个深入的教程系列,向您展示如何用 C++ 编写 X11 窗口管理器:
此外,您可以在
出于教学目的,它受到了大量评论。
关于 Xlib 与 XCB - 如果您是第一次开始使用,我会推荐 Xlib 而不是 XCB。 XCB 更高效,但它的级别更低且更冗长(想想 GUI 的汇编语言)。在原型已经可以工作之前,您不想让过早的优化给自己带来负担。
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.
一个非常简约的 WM 是 wm2。我还没有阅读源代码,因此我不知道这是否是一个教学示例。当然,您可以使用已经为您完成大量抽象和绘图工作的库,例如 gdk 和gtk。但由于这个项目仅供个人学习,所以我就硬着头皮直接使用Xlib。
以下是一些可能对您有用的链接:
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:
查看 dwm 的代码。代码库漂亮且易于理解。整个事情大约有2000行。
Have a look at the code for dwm. The codebase is beautiful and easy to understand. The entire thing is about 2000 lines.
http://code.google.com/p/partiwm/ 是一种尝试编写从头开始创建一个窗口管理器(平铺,而不是堆叠),阅读代码可能对您有用。
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.
metacity 对某些 UI 元素使用 gtk。请参阅其黑客攻击和自述文件。
另请参阅哪里有一些好的 Xlib 编程指南?
metacity uses gtk for certain UI elements. See its HACKING and README.
see also Where are some good Xlib programming guides?
您可能想看看 aewm 窗口管理器。代码很小,而且基础知识做得很好。它是用 C 编写的并使用 Xlib。
http://www.red-bean.com/decklin/aewm/
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 可能是一个不错的起点。
Xmonad might be a good place to start.