
X Window System Basics (2014) - Ivoah
https://magcius.github.io/xplain/article/x-basics.html
======
tedunangst
Previously:
[https://news.ycombinator.com/item?id=21039848](https://news.ycombinator.com/item?id=21039848)

~~~
Jasper_
Author here. I don't want to copy/paste my entire postmortem in here, so I'll
link to the thread from a few days ago which has some extra context into why I
started this series, and why I stopped it, as well as future projects I've
since moved on to.

[https://news.ycombinator.com/item?id=21041340](https://news.ycombinator.com/item?id=21041340)

~~~
Crinus
> pick up a piece here or there, and go on straight to bashing Wayland,
> gleefully unaware that I was one of the people making it.

Don't worry, you working on Wayland doesn't make it any less sucky, it is
broken at a design level so unless you had a fundamental effect on the design,
you don't bear any blame for its state :-P.

(though a better approach would be to try and fix X11's issues instead of
intentionally breaking it and replacing it altogether)

~~~
Jasper_
That's exactly the comment that makes me feel validated in leaving the Linux
and FOSS worlds behind. Why would you post something like that?

~~~
Crinus
Because i believe Wayland is fundamentally worse at a design level than X11.
Why else would i post something like that?

And i too have lost interest on Linux (on the desktop at least) over time
(incidentally also working on games but that is just a coincidence) and a main
reason for that is all the push that Wayland gets despite its shortcomings
from various big players. Wayland is most likely going to become the primary
tech behind Linux desktop, but that wont be due to its merits, it will be due
to the push it gets from companies with money.

Xorg is not a simple project and most people who may want to work on it will
be hobbyists who more likely than not, wont be able to keep up with whatever
breakage Wayland introduce. You can already see this sort of inability to keep
up with "modern Free Desktop" breakage by looking at the projects that are
developed by hobbyists in their free time and how slow they are in adapting
from Gtk2 to Gtk3 - some still haven't fully adapted, yet Gtk is now breaking
things again with Gtk4.

If only all that breakage was for something worthwhile. But in reality there
is absolute no reason, yet is forced on everyone. Desktop programs in the 80s
drew buttons, checkboxes, input fields and sliders. Desktop programs in the
90s drew buttons, checkboxes, input fields and sliders. Desktop programs in
the 2000s drew buttons, checkboxes, input fields and sliders. Desktop programs
in the 2010s drew buttons, checkboxes, input fields and sliders. I am
absolutely sure that desktop programs in 2020s, 2030s, 2040s and forward will
continue to draw buttons, checkboxes, input fields and sliders. There is no
reason to break those programs, no reason to waste anyone's time rewriting
programs that already work just to keep up with lower layer breakage, no
reason to introduce additional dependencies just so you can avoid the
breakage, no reason to waste time learning how to do the exact same stuff only
now in a slightly different way, no reason to do any of that _at all_.

From my perspective Wayland has no reason to exist. At least no reason that
has to do with what would be better for everyone _NOT_ involved in its
development.

While Windows has its issues (e.g. i do not like how it forces composition -
also a reason i dislike Wayland - and how they remove customization options in
a very hacky way) it is still better than Wayland (e.g. my old code still
works without changes, i can write code that manipulate arbitrary windows,
despite the hacks it is still very fast, etc). At least from my perspective.
But i feel like choosing the least of two evils (not that X11 is perfect, but
i'd prefer if all the wasted effort that went to Wayland was spent on
improving Xorg).

So i decided to stick with Windows. The only way i could see myself doing what
i believe is right is work full time on Xorg, toolkit(s) that take advantage
of Xorg (instead of treating it as a dumb bitmap terminal) _and_ programs that
work with these toolkits. But i cannot do that and even if i could, the
constant FUD against X11 from Wayland developers and fans make me wonder if it
would be worth the effort in the first place.

FWIW i do not mind Wayland existing (even though i see no point in it
personally) as much as i do not mind Arcan existing - or Qt existing, Gtk3
existing, ZSH existing, Ruby existing and any other project that provides an
alternative option to another project. What i _do_ mind is the manipulation
going on to force me (indirectly mainly, through all the efforts going on -
yes i know that technically nobody puts a gun on my head) to use Wayland. If
i'm going to be forced something might as well be something i dislike less and
due to the vast majority using it it has less problems.

Hence, Windows.

~~~
Jasper_
Well, I won't respond to any of that, I will just say that I was one of the
core designers of Wayland, and I've had a very fundamental impact on the
design. I understand both X11 and Wayland quite well. So thanks for the
insults, I guess.

This is exactly the sort of comment that got me tired of working on Xplain,
and why I quit working on Linux entirely. My one wish is that you treat the
FOSS graphics communities with more respect in the future. There's a lot of
people who have years and years of experience solving problems and dealing
with this stuff every day, and their opinions hold a lot of merit.

~~~
Crinus
> So thanks for the insults, I guess.

I'm not sure what you found insulting, i was commenting on Wayland itself and
the companies that push it. The closest i could think of is the "blame for its
state" bit but that was obviously said jokingly as tongue-in-cheek (even with
the ":-P" smiley).

Do you see disliking Wayland, disliking the forces that push it and not seeing
a point at it existing as insults to yourself?

> treat the FOSS graphics communities with more respect in the future

A "community" isn't a person to be treated with anything, if i'm to treat
someone with respect it will be a person, not something vague like a
community.

Also disliking a piece of work doesn't mean that i disrespect (or respect) the
person who worked on it. I honestly do not know you so i have no reason to
disrespect (or respect) nor insult you (something that from my perspective i
didn't do). I do know about Wayland and i have many reasons to dislike it, but
that dislike doesn't extend to a general dislike or disrespect of you. It is
Wayland i dislike, not you.

> There's a lot of people who have years and years of experience solving
> problems and dealing with this stuff every day, and their opinions hold a
> lot of merit.

Sure, but there are also a lot of people who can simply be wrong despite their
experience, for a variety of reasons. Appeals to authority aren't to be taken
at face value. Also in my post above i'm not judging the people who created
the work, i'm judging the work and (also) how it i feel is enforced on me
despite my will.

Some people might get too attached to their work and feel any attack towards
it is an insult to themselves, but to me that does not sound like a reason to
not criticize that work - or any work - especially when that works is
affecting me.

Also i think that if you feel insulted by people criticizing your work you may
not have a good time working as a games developer :-P.

------
suhail
This is also one of my favorite and most helpful posts I’ve found working with
X so far: [http://jichu4n.com/posts/how-x-window-managers-work-and-
how-...](http://jichu4n.com/posts/how-x-window-managers-work-and-how-to-write-
one-part-i/)

------
anaphor
The XCB tutorial is quite good as well
[https://xcb.freedesktop.org/tutorial/](https://xcb.freedesktop.org/tutorial/)

Also, if you want to do simple graphics stuff with X11, then I highly
recommend looking at
[https://www.cairographics.org/](https://www.cairographics.org/) instead of
trying to use the builtin drawing functions that come with X11.

~~~
app4soft
Additionally, if you want create good looking modern UI take a look on _mlib_
[0] toolkit (built on top of X11) used for _AzPainter_ [1] drawing program.

[0]
[https://github.com/Symbian9/azpainter/tree/master/mlib](https://github.com/Symbian9/azpainter/tree/master/mlib)

[1]
[https://github.com/Symbian9/azpainter/](https://github.com/Symbian9/azpainter/)

------
jolmg
For those that miss it, there's multiple pages. If you go back one page (by
hitting the left arrow link), you get an introduction and table of contents.

------
Sir_Cmpwn
I don't have anything this cool and interactive, but for those interested I've
been working on a comprehensive Wayland book:

[https://wayland-book.com](https://wayland-book.com)

It's a little over halfway done.

~~~
sandov
I bought it yesterday and was curious about what software you used to generate
the html viewer. I liked it.

~~~
Sir_Cmpwn
[https://github.com/rust-lang-nursery/mdBook](https://github.com/rust-lang-
nursery/mdBook)

Thanks for buying it, I hope you like it :)

------
person_of_color
How does X interact with your graphics card?

~~~
Jasper_
That boils down to two main questions:

1\. How do X11 clients render using your GPU, like using OpenGL or Vulkan?

2\. How does an X11 server talk to your graphics card to get stuff on screen?

Clients render through a magic secret backdoor. libGL.so / the Vulkan ICD,
provided by the vendor talks to their graphics driver, and then there's
typically an Xorg extension to do the buffer handoff. In the open-source
world, the libGL.so is mesa, it talks to the kernel using a kernel API called
"DRM" (Direct Rendering Manager) to render your graphics to a buffer, and then
the resulting rendered buffer is shoved across and composited using an Xorg
extension known as DRI3, which is initialized as part of the video driver.
Most of the open source xf86-video-* drivers support DRI3.

For the latter question, the X11 server has a series of video drivers that can
take the buffers you have and show them on screen. I won't go into the exact
details of how these buffers are composited (it's not very pretty, but the
typical approach these days is the server itself using GL the same way a
client would to composite the buffers together), but ultimately a final
composited scanout buffer comes out the other side, which is sent to the
screen through some driver-specific mechanism. In the open-source world, this
mechanism is called "Kernel Mode-Setting", or "KMS", and it's part of the
kernel DRM APIs mentioned above.

------
sicnus
Logged in to upvote this because it used the correct: X Window System and not
X Windows (Grrrr...) Man X folks! [Apparently OP did.]

