I hate Xlib
remlab.net
remlab.net
AwesomeWM started as a tiling WM built for the new frontier, before xcb crumbled around it. After about four years with scant updates, the maintainer's statement that he didn't see a future for it with the community abandoning its central technology, and a precipitous increase in "I just want this dumb thing to build so I can use my computer" keyboard-smashing sessions, I switched back to KDE. These days, a Windows 10 VM with passthru'd sound, USB, and GPU is my primary workstation environment.
I hear Wayland will be ready for the big time any day now. Been hearing that for the last three years or so. Maybe we can have a Year of the Wayland Desktop before a Year of the Linux Desktop.
I'm no fan of X, but the books documenting it were from an era when the UNIX industry was flush with cash and printed technical writing was at its peak.
It pains me to flip through my volumes of printed O'Reilly X books, knowing how much time and care was put into documentation for such a technical abomination.
https://www.oreilly.com/library/view/xlib-reference-manual/9...
There are probably things Wayland don't do well - I seem to recall people complain about screen sharing - but for my needs, it Just Works and I never think about it.
Julien Danjou, original awesomewm author, ruminates on the X11 saga and the resistance to XCB in [0], dated 2010-06-01.
While that post expresses the bleak outlook for X11 and the Freedesktop project in general, it seems the real clincher about the freeze on awesomewm comes from a LWN article from November 2011 [1], which quotes Julien thus:
"The missing parts are advanced stuff like new XInput and multi-touch support, but we were blocked by XCB for those, and users seem to be able to live without them. Now, since everyone seems really happy with the 3.4 branch, I think it's enough that we just keep maintaining it."
Taken together, my interpretation at the time -- and I think the general community consensus -- was that the hours and days spent rebuilding cairo to enable the XCB backend and then rebuilding anything that depended on it, which was (is?) basically every substantial Gtk application, were not going to get any easier.
Venturing into the comments on that article and seeing the links to issues with users pleading for distro packagers to enable XCB out of the box brings the old days flooding right back.
[0] https://julien.danjou.info/thoughts-and-rambling-on-the-x-pr...
Whether it's going to take off on the desktop or not is a completely different matter :-). There's a lot more hardware there, with a lot more different requirements, and there are very few people still working full-time on Linux desktop technology. It doesn't help that the barrier of entry is pretty high. There's no documentation, a lot of the code is a moving target... it's pretty hard to get started with this thing when you're working in your free evenings.
I still prefer how awesome does layouting, but I can get over that.
There are still a few rough edges, but if you can handle using a tiling WM, you can handle using sway. I think this time I won't have to go back to X.
XCB wasn't the first non-Xlib way to talking to an X11 server that had this problem. We had the same problem in the 90's when we wanted to use Display PostScript with Common Lisp which was talking to X with CLX, an alternative to Xlib written in Lisp.
Is there a reason you can't catch this with static analysis tests? Also, I don't really see this as an issue with xlib any more than I see it as an issue with a careless developer who didn't read documentation or check or examples.
Currently browsers run multiple processes for their UI and the loaded websites. Back when this wasn't the case it took just a single badly behaving site to hang everything.
http://www.call-with-current-continuation.org/rants/icccm.tx...
(original mailing list hosting is no longer available)
In fact, it's so bad that basic functionality such as how to choose the correct encoding for text content, is not only underspecificed, but the specification that does exist is worded in such a way that unless you read the entire document, including completely separate sections, you will inevitably use the wrong encoding.
Emacs gets this completely wrong, Chrome gets it kinda wrong, and pretty much no one gets it completely right.
Ice Cube: The Lethal Weapon
One of the fundamental design goals of X was to separate the window manager from the window server. “Mechanism, not policy” was the mantra. That is, the X server provided a mechanism for drawing on the screen and managing windows, but did not implement a particular policy for human-computer interaction. While this might have seemed like a good idea at the time (especially if you are in a research community, experimenting with different approaches for solving the human-computer interaction problem), it can create a veritable user interface Tower of Babel.
If you sit down at a friend’s Macintosh, with its single mouse button, you can use it with no problems. If you sit down at a friend’s Windows box, with two buttons, you can use it, again with no problems. But just try making sense of a friend’s X terminal: three buttons, each one programmed a different way to perform a different function on each different day of the week — and that’s before you consider combinations like control-left-button, shift-right-button, control-shift-meta-middle-button, and so on. Things are not much better from the programmer’s point of view.
As a result, one of the most amazing pieces of literature to come out of the X Consortium is the “Inter Client Communication Conventions Manual,” more fondly known as the “ICCCM”, “Ice Cubed,” or “I39L” (short for “I, 39 letters, L”). It describes protocols that X clients must use to communicate with each other via the X server, including diverse topics like window management, selections, keyboard and colormap focus, and session management. In short, it tries to cover everything the X designers forgot and tries to fix everything they got wrong. But it was too late — by the time ICCCM was published, people were already writing window managers and toolkits, so each new version of the ICCCM was forced to bend over backwards to be backward compatible with the mistakes of the past.
The ICCCM is unbelievably dense, it must be followed to the last letter, and it still doesn’t work. ICCCM compliance is one of the most complex ordeals of implementing X toolkits, window managers, and even simple applications. It’s so difficult, that many of the benefits just aren’t worth the hassle of compliance. And when one program doesn’t comply, it screws up other programs. This is the reason cut-and-paste never works properly with X (unless you are cutting and pasting straight ASCII text), drag-and-drop locks up the system, colormaps flash wildly and are never installed at the right time, keyboard focus lags behind the cursor, keys go to the wrong window, and deleting a popup window can quit the whole application. If you want to write an interoperable ICCCM compliant application, you have to crossbar test it with every other application, and with all possible window managers, and then plead with the vendors to fix their problems in the next release.
In summary, ICCCM is a technological disaster: a toxic waste dump of broken protocols, backward compatibility nightmares, complex nonsolutions to obsolete nonproblems, a twisted mass of scabs and scar tissue intended to cover up the moral and intellectual depravity of the industry’s standard naked emperor.
Using these toolkits is like trying to make a bookshelf out of mashed potatoes. - Jamie Zawinski
I39L caught my eye, I think it’s one of the earliest abbreviations of that form that I have seen. Do you know where it came from?
Do these libraries assume that XInitThreads() was called? If they do they could all link against an "libxinitthreads" library where XInitThreads() is called in a constructor function.
Are you asking if it is technically possible? Yes, because libraries are just code + data, and you can trivially just duplicate the library functionality in your own library.
Are you trying to eliminate library dependencies for some kind of demoscene competition? You could just use the framebuffer.
Are you trying to write portable code that doesn’t depend on particular libraries being installed? That’s possible too, in various ways, such as dynamic linking.
Are you doing a homework assignment and want to render graphics, but the rules for the homework state “no libraries”? Also possible, but I would recommend talking to the teacher to clarify things.
Do you just need to display something simple to the user? You can use ASCII art and set colors by writing ANSI escape sequences, and you can also use emoji. Some people use this to make command-line applications with some simple graphics.
Finally, when you say “without any libraries” do you mean to include the standard library, or is that library OK?
In general I find the “without using libraries” questions that people ask a bit vague and difficult to answer.
Wayland clients don't have to. For OpenGL, OpenGL ES there's EGL, for Vulkan, it's the other way and Vulkan provides extensions for WSI (window system integration).
There's something crazy like 64 ways to join to vectors. 100s of dot/dash combinations for drawing a line, caching of color maps, etc. etc. etc.
See the 'X-Windows Disaster' section 'Myth: X is "Device Independent"':
https://medium.com/@donhopkins/the-x-windows-disaster-128d39...
Myth: X is “Device Independent”
X is extremely device dependent because all X graphics are specified in pixel coordinates. Graphics drawn on different resolution screens come out at different sizes, so you have to scale all the coordinates yourself if you want to draw at a certain size. Not all screens even have square pixels: unless you don’t mind rectangular squares and oval circles, you also have to adjust all coordinates according to the pixel aspect ratio.
A task as simple as filing and stroking shapes is quite complicated because of X’s bizarre pixel-oriented imaging rules. When you fill a 10x10 square with XFillRectangle, it fills the 100 pixels you expect. But you get extra “bonus pixels” when you pass the same arguments to XDrawRectangle, because it actually draws an 11x11 square, hanging out one pixel below and to the right!!! If you find this hard to believe, look it up in the X manual yourself: Volume 1, Section 6.1.4. The manual patronizingly explains how easy it is to add 1 to the x and y position of the filled rectangle, while subtracting 1 from the width and height to compensate, so it fits neatly inside the outline. Then it points out that “in the case of arcs, however, this is a much more difficult proposition (probably impossible in a portable fashion).” This means that portably filling and stroking an arbitrarily scaled arc without overlapping or leaving gaps is an intractable problem when using the X Window System. Think about that. You can’t even draw a proper rectangle with a thick outline, since the line width is specified in unscaled pixel units, so if your display has rectangular pixels, the vertical and horizontal lines will have different thicknesses even though you scaled the rectangle corner coordinates to compensate for the aspect ratio.
If you can read current scanline and have per window swap chain (hardware layer), it might be possible to completely avoid UI latency and tearing by drawing just before scanout. Apart from latency introduced by the display device itself.
Of course it might tear if the scanline chasing drawing thread is context switched away at a bad moment.
This technique is explained better at [0]. The point is mainly that you can combine this with GPU hardware multiple swap chains (layers).
This is never going to be a general solution, though. Just for some special cases where it's both possible to draw fast enough to chase current scanline. Also not all GPUs have multiple swap chains available per display.
[0]: https://www.blurbusters.com/blur-busters-lagless-raster-foll...