编写窗口管理器的现代方法
我正在尝试编写一个窗口管理器。 (实际上,我已经编写了一个操作系统和一个编译器,但这不是重点。)
XLib 和 xcb 并不完全令人讨厌,至少按照 win32 标准来看,但它们绝对是非常糟糕的。老了,不太适合像样的抽象,让我的生活更轻松。不仅如此,现代高级语言还明显缺乏良好的绑定。
我的问题是:现在所有这些低级的东西真的有必要吗?是否存在可以为我封装所有讨厌的东西的库?我依稀记得启蒙运动的人曾经做过这样的事,但是却找不到任何东西。或者像 GDK 这样的现代小部件库是否具有足够的功能,我不需要接触 Xlib 层?
任何具有 Java 绑定的库都特别令人感兴趣......
I'm trying to write a window manager. (Actually, I have written an OS and a compiler, but that's beside the point.)
XLib and xcb aren't exactly nasty, at least not by, say, win32 standards, but they are definitely very old and don't lend themselves nicely to decent abstractions to make my life easier. Not only that, but there's a distinct lack of good bindings for modern high-level languages.
My question is: is all this low-level stuff really necessary these days? Do libraries exist that will encapsulate all the nasty stuff for me? I have a vague memory that the Enlightenment people had done such a thing, but can't find anything. Or do modern widget libraries like, say, GDK have enough functionality that I wouldn't need to touch the Xlib layer?
Any libraries with Java bindings are of particular interest...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个迟到的答案,所以也许它不再有太大的相关性,但无论如何我都会发布它,因为其他人可能正在寻找它......
我问了自己同样的问题并得出的结论是不存在这样的问题的事情,尤其是在 Java 中。虽然某些小部件工具包(例如 qt)为您提供了使用现有显示结构并从现有 xlib 窗口句柄创建小部件的可能性,但您仍然需要使用 xlib/xcb 来完成与 X 服务器通信的繁琐工作wm具体操作。正如其他人所说,其他库(例如 GDK 和 enlightenment)也提供了相当好的基本抽象工作。
尽管如此,我对所有这些都使用 C/C++ 的事实并不满意,并且坐在我懒惰的屁股上等待有人用 Java 为我完成工作不是一个选择,我开始编写自己的库,它允许您用 Java 构建您自己的模块化 WM。
https://github.com/Zubnix/trinityshell
This is a late answer so maybe it doesn't have much relevance anymore but I'll post it anyway since other people might be looking for it...
I have asked myself the same question and came to the conclusion that there exists no such thing, especially not in Java. While certain widget toolkits, like qt, offer you the possibility to use an existing display struct and create widgets out of existing xlib window handles, you'll still have to use xlib/xcb to do the nasty job of communicating with the X server for wm specific operations. Other libraries, as stated by others, like GDK and the enlightenment also offer a pretty good job of basic abstraction.
Still, I wasn't happy with the fact that all of these use C/C++ and sitting on my lazy ass waiting until somebody did the work for me in Java wasn't an option, I started writing my own library that allows you to build your own modular WM, in Java.
https://github.com/Zubnix/trinityshell
如果您所说的“低级内容”指的是 C 语言,那么从技术角度来看,这是没有必要的;您可以使用 XCB 的 XML 生成任何语言的绑定。
然而,如果你所说的“低级东西”是指在 X 协议级别进行处理,那么,是的,这是必要的(如果你不想拔掉你的头发)。窗口管理器必须在 X11 协议级别工作,因此使用“高级”的东西只会让您的生活变得困难。事实上,XCB 的诞生正是因为 Xlib 的层次太高,掩盖了太多底层,很容易出错,很难甚至不可能完全控制。 (此外,从 X 的角度来看,XCB 并不是“非常古老”;直到最近几年,所有主要 Linux 发行版才终于开始完全使用 XCB。)
If by "low-level stuff" you mean the C language then no, it isn't necessary from a technical standpoint; you could use XCB's XML to generate bindings for any language.
However, if by "low-level stuff" you mean dealing at the X protocol level then, yes, it is necessary (if you don't want to pull your hair out). A Window Manager must work at the X11 protocol level, so using something "high level" will only make your life difficult. In fact, XCB was created precisely because Xlib was too high-level, masking too much underneath so it was easy to make mistakes, and making it difficult or impossible to have full control. (Also, XCB is not "very old" from an X perspective; it is only in the last few years that all the major Linux distributions finally started fully using XCB.)