X Window System Basics (2014)
magcius.github.io
magcius.github.io
You can get to all the contents here: https://magcius.github.io/xplain/article/index.html
Summary of the contents:
i. Introduction & Table of Contents
ii. X Window System Basics
iii. Advanced Window Techniques
iv. Adding Transparency
v. Regional Geometry
vi. Basic 2D Rasterizationhttps://www.youtube.com/watch?v=By7qcgaqGI4
I left a small retrospective the last time this got posted here. I believe what I’m doing now is far more interesting. https://news.ycombinator.com/item?id=21041340
I am amazed that people try to force limited and unfinished Wayland instead of X11. I recently had RHEL on ThinkPad T14 at work - which by default uses Wayland - yet even employer by default switches settings to X11 because EVERYTHING works there as desired - including screen sharing and/or recording.
... and for my personal stuff? I have ZERO issues with X11 on FreeBSD - why would I switch to Wayland if everything works as desired on X11? FreeBSD of course supports Wayland and you can use it there if you wish - but I just do not see the point of it. I do not have ANY screen flickering or other issues on X11.
Not to mention that A LOT of stuff is X11 only and not ported (and never will be) to Wayland.
Can we just not do this useless flamewar under every similar topic’s thread? Especially that no, noone wants to force Wayland, they want something that is under active maintenance, which X11 is not anymore, since every maintainer of it left/migrated to Wayland.
> Not to mention that A LOT of stuff is X11 only and not ported (and never will be) to Wayland.
Hmm, only if the goddamn maintainers of X11 who came up with Wayland thought of that. They could have named it something like W11.. no, XWayland!
Personally, I suspect that if the Wayland developers simply dropped maintenance of Xorg completely--no more patches, no more XWayland or at least completely disassociate XWayland from Xorg--that a community would step up and carry Xorg forward. As it is, that erstwhile community remains largely hidden, maintaining out-of-tree patches. But if that community faced the prospect of 1) being able to take back the reigns of Xorg, and 2) if not, Xorg vanishes today, then it would likely become much more motivated, organized, and proactive. (Whether it would be capable of carrying Xorg forward is a different question.) Alternatively, it might create the environment for projects like Arcan to shine.
I don't. That community was sorely needed several years ago, but failed to show up.
Only the compositor has access to the composited image therefore is the only program able to make screenshots and full screen sharing. Furthermore, efficient sharing of single application windows is only possible with direct memory access to the buffer which also is something the compositor does/has. The Display protocol is the only sensible place to negotiate access to GPU resources.
No, GPU resources can come from any number of other places. That's literally the purpose of direct rendering. Any applications using GPU compute can produce them without requiring a connection to the display server. There's no reason to put that in Wayland or restrict it to the compositor. There's already a much better protocol for sharing GPU buffers: Pipewire. Dbus is only there to act as the glue between a Wayland compositor and Pipewire.
And xwayland exists so porting isn’t much of an issue.
But yeah, despite all that i’m on x11 still as well. I need to use proprietary nvidia drivers and I don’t want to run full gnome or whatever to make that run smoothly. I’ll probably be dead before dwm stops working on an updated system.
I’m a security engineer, and I can’t think of many threat models in which an attacker can snoop clipboard contents but can’t do much worse things, which I assume is why neither macOS nor Windows has ever bothered with clipboard isolation.
(It’s entirely possible I’m under-thinking it!)
Afaik macOS doesn’t allow clipboard access in that naive way and you do get access in wayland, it is just not this “uncontrolled”.
No, I don't think it's "okay." I just think it's indistinguishable from running arbitrary code, which is much worse anyways.
Again, ask yourself: what is the specific threat model in which an attacker can run a process that continually polls the clipboard, but can't do anything else?
> Afaik macOS doesn’t allow clipboard access in that naive way and you do get access in wayland, it is just not this “uncontrolled”.
You can try this for yourself: the `pbcopy` and `pbpaste` utilities on macOS allow uncontrolled access to the clipboard without any entitlements. These are well-known utilities that are baked into macOS, and are widely used by tools like password managers to programmatically control the clipboard.
More generally, you can look up the NSPasteboard and UIPasteboard APIs that Apple offers on macOS and iOS. There are no special entitlements required for either.
From a historical perspective, the "why Wayland?" question is incredibly obvious IMO. The old Linux graphics stack consisted of the dumb Linux framebuffer and fbcon, and the separate Xorg stack with all its DDX/UMS drivers that required root-level permissions, and only provided a graphics API for ... Xorg. Your options were either Xorg, or the framebuffer, which IIRC didn't always support all of the available display modes.
Wayland was part of a wider push to rewrite the Linux graphics stack, with the new stack of KMS/DRM/DRI3/Mesa being a huge improvement over the 2000s Linux GUI stack. This came at the cost of old UMS and DRI drivers, making e.g. PowerPC Mac GPUs largely useless now (very unstable and incapable of suspend-to-RAM), while unifying mode-setting between the kernel and userland (no more praying the video card doesn't crash when ctrl-alt-f2'ing), also allowing for an arbitrary number of shared video buffers to be created (including by non GLX video applications) which makes compositors work in a not-hacked-together sense, but also allows for e.g. hardware video decoders to work in a not-hacky way.
Coupled with the addition of evdev to replace the Xorg DDX stuff like all the custom peripheral drivers, and you finally had a kernel-level API for accessing your video and input hardware. These were all prerequisites for the idea of "Wayland", decoupling the video and input layers from the display server and creating a low level API for window server things, so that you can have both small window servers (e.g. wlroots-based compositors) as well as "thick" environments (Mutter/KWin-based desktops).
Part of what makes this confusing is a lot of these benefits trickled down to Xorg itself. Nowadays evdev (and libinput) have replaced the old DDXs on Xorg, and I think most distros have switched to using xf86-video-modesetting, which could be thought of as "Wayland-style rendering on Xorg", in the sense it uses pure DRM and Mesa to render instead of GPU-specific DDX drivers.
So Xorg has gotten a lot of the benefits of Wayland's development "for free" anyway. This is intentional, as you mention, a lot of things will never be ported to Wayland. Wayland is not a replacement for X11, but an API for implementing the display server at a lower level than X11 allowed, while allowing us to implement full X11 compatibility "for free", by embedding Xorg in the form of Xwayland.
I think this makes a ton of sense for the majority of desktop-environment level compositors like Mutter (GNOME) and KWin (Plasma), which were already massive and implemented so much of their own functionality outside of Xorg, that it made sense to just let them do their own compositing. Same with GTK and Qt, which were already doing "their own rendering" outside of X.
Didn't mean for this to become an apologetic rant for Wayland, but as a "wayland skeptic" myself I feel like most anti-wayland arguments miss the forest for the trees (screen sharing not working). As an olive branch, though, I'll also add I don't think the wayland version of the big compositors like Mutter or KWin actually do much for end users, and it's pretty shameful how they've been launched with so many bugs, with no compelling user story beyond "better scaling" and "flicker".
Mesa was in X before Wayland was a thing.
Pretty much the only problem I have with it, is lack of good screen-recording software. OBS is a bit of an overkill for short screen-casts.
I'm not sure if there are any compositor specific interfaces or why they would be used when xdg portals exist.
The xorg people phylosophy seems to be: if it works, fix it. Since xorg forked XFree86 the quality has gone down.
Some of the things they did off the top of my head:
* Render extension. This enabled all sorts of things, like easier drawing and scaling of pixmaps, or better font handling.
* Less monolithic build, phase out imake. This allowed iterating various components at different rates.
* Better auto configuration - less need to write a config file for the most common configurations.
XCB was also a good idea. I don't think it lived up to full potential because interest in writing code for X waned.
I think one thing that was lost to history are some of the proprietary X servers, such as those by Sun and SGI. The XFree86/Xorg lineage is missing their input.
Better until you compile a new kernel and realize that you don't have keyboard and mouse in X because it insists using an obscure (event ?) interface. And then press the power button to restart.
It's obvious that the plot to kill x.org is being advanced not just by insider "maintainers" who work for OTHER COMPANIES while doing NOTHING when it comes to maintenance of x.org, they're actively trying to kill it off with the help of people like you. Wayland disgusts me, and I go to great lengths to avoid trash that MS and Amazon want to shove up my ass or down my gullet.
You, your whole operation, it's as insufferable as the Rust "advocacy" that goes way beyond shilling at this point. It's not cute, fully, or clever. You're not helping.
I don't see any real alternatives to it that go as far as Rust does for safety.
I'm not a Wayland fan due to the lack of keylogging (Needed for global shortcuts and easily writing daemons that use keyboard input) and screenshotting as standard features, but it's not like it's being forced on people, the community as a whole is demanding stronger and stronger security guarantees, "All your stuff has access to all your other stuff" doesn't seem to be good enough for many people.
But don't we model this type of protocol today with the web?
But I've felt that the terminology of server side rendering w.r.t. the web seems to imply something else in my mind. I agree with your comment but, to me, nothing actually gets rendered on the server - the code TO render in the client gets constructed on the server, e.g. a web page, partial page etc and sent to the client to be interpreted for display in a graphical environment (the browser).
Splitting hairs, technically a bitmap graphic could be said to be rendered remotely and it's display is simply a transfer function - sorry, I realise I'm been overly pedantic.
I don't think it is strange when you consider that terminals (including some with graphical capabilities) where common back in the day, with multiple terminals connecting to a single beefy computer.
In fact there were even dedicated X terminals (basically cheap computers running an X server) in the early 90s:
Part of it is, of course, that it is not just the Linux standard. It's also the FreeBSD, OpenBSD, NetBSD, DragonflyBSD, GNU HURD, Minix 3, Solaris, OpenSolaris/Illumos, AIX, HP/UX, z/OS, and OpenVMS standard.
I am sure I missed some currently-maintained OSes in there.
X is a core part of the interoperable, cross-platform, open systems world, as it has been for decades. Since most of those will never undertake large new development now, it will probably never be replaced in this, but some of those systems will keep running the world for decades to come, until the collapse of technological civilisation.
Personally, since nobody can kill off or totally replace X, my suggestion is that we collectively decide what bits we don't need any more, and cut it down to the core stuff that we need to keep.
Byte-swapped clients just were banished.
Why not get ruthless and strip out all the ancient stuff that nobody uses in the 21st century, keep just the essentials, and call the result X12?
I am no expert in this area but I gather that most of the font server stuff is obsolete now. It is probably safe to assume only 24-bit colour now. In the mid-1990s I ran X11 over DECnet on VAX/VMS. I am sure everything but TCP/IP can go now. I am willing to bet there is lots of other stuff that could be removed, leaving a smaller, more maintainable core that someone somewhere is going to need for years to come.
Why does it seem strange? It's the same as what you do when you run, say, a web browser locally. (The only difference is, we do not call the browser "web server.")
I think Wayland is an admirable project in a lot of ways, but it's practically speaking a bit of a disappointment. In 5-10 years they're likely to have sorted stuff out and it's probably going to be worth switching to by then.
... and I'm a happy Mac user, haven't been deep in Linux-on-the-Desktop land in over a decade, and still felt that way.
You can perhaps write a more efficient graphics library now, but what if in a few decades the servers are way more powerful again compared to the clients/terminals?
But TBH i think most distros either use X server based environments or do not provide a default OOTB environment at all.
RHEL has deprecated xorg-server and will provide support for those x11 DE/WM via rootful xwayland sessions.
RHEL also bring us: systemd, dbus, pulseaudio, GNOME 3 etc.
I think is it safe to consider now that everything they do is hostile for linux and stay away as much as possible from their "technology".
IPv6 and Wayland have a lot in common.
X runs on more platforms than Wayland because...it was ported to them. Just like things use Python 3 because they were ported to it.
This is also understating the reach of X I think: it's widely used in the embedded world, is seeing increasing support in BSDs, and has even been used on macOS (https://github.com/owl-compositor/owl). People have even used it to embed an entire compositor inside a GTK app (https://github.com/alexlarsson/wakefield).
That isn't to say that libwayland has a lot of Linux-isms in it, but afaik they're not really structural as much as there is lack of interest to generalize things more. Heck, the protocol-oriented architecture would even make it easier for anything Linux-esque to be removed in favor of alternative protocols.
I have no intention of writing one in any usable sense, but it would be cool to write up a toy one.
- X Toolkit Intrinsics Programming Manual - X Toolkit Intrinsics Reference Manual
However they have very little to do with how modern operating systems (Windows, MacOS) deal with that stuff.
As for toys, I'd recommend reading about Dear ImGui [1]. It handles everything you mentioned while being self-contained so you can see how everything works from top to bottom. Many talks and articles have been written about it though I can't vouch for any of them.
Xplain – Explaining X11 for the rest of us (2017) - https://news.ycombinator.com/item?id=24197528 - Aug 2020 (89 comments)
X Window System Basics (2014) - https://news.ycombinator.com/item?id=21118633 - Sept 2019 (20 comments)
Xplain – Explaining X11 for the rest of us - https://news.ycombinator.com/item?id=12042548 - July 2016 (44 comments)
XPlain – Explaining X11 for the rest of us - https://news.ycombinator.com/item?id=8019346 - July 2014 (65 comments)
Xplain: Explaining X11 for the rest of us - https://news.ycombinator.com/item?id=6978274 - Dec 2013 (19 comments)