News for hackers. Stuff that matters.
Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @05:08AM (#29092434)
1. Wayland does support remote execution; see waypipe for an example.

2. X11 does lack critical features that lots of users need: GUI isolation (a very basic security measure that's otherwise been standard practice for decades), mixed DPIs, and perf on low-end ARM devices (compare Sway with dwm/openbox/i3 on a rbpi or pinebook and the difference is kinda shocking).

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @05:22AM (#29092508)
X worked just fine on early 90s hardware. Performance today is about implementation, nothing inherent about X.
Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @05:33AM (#29092568)
ARM chips did not exist in the early 90s, and compositors weren't the norm either. Current integrated graphics processors are optimized for a very different landscape. A typical X setup also includes a compositor to mitigate screen tearing.

Factor all this into account and I'd be interested in seeing an X setup without screen tearing that performs at least as well as Sway on a Pinebook or a rbpi.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @05:54AM (#29092658)
The first ARM dates to 1985. I don't know if there was ever an X11 server for Acorn RISC-OS, but there were for similar era Amiga's. But that misses the point, which was that current era ARM chips are orders of magnitude faster than the old 68k family Unix terminals and 486's I ran X on through much of the 90's.

You're right, compositors weren't a thing, but we're also talking CPUs several orders of magnitude slower, and where the blitter capabilities of what passed for GPUs had a throughput magnitudes slower than what my cellphone has today.

Re:How X Window Managers Work, and How to Write One (2014) by fredoralive on Wednesday November 03, 2021 @08:17AM (#29093574)
I'm not sure if RISC OS had an X11 server, but Acorn did offer an ARM Unix (RISC iX) in the late '80s, and it did have X11.
Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @06:05AM (#29092718)
I am only familiar with ARMv7 and later, which come with graphics chips optimized for for something different than what X was built for. In my own tests and from others who have tried the same, DWM & Co were noticeably slower; I'd imagine that running a current distro with a current X WM wouldn't be a great experience on 90s machines.

The difference will widen as Vulkan support in Wayland compositors seems to be outpacing the X equivalents; modern GPU development is starting shift away from OpenGL

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @07:15AM (#29093129)
X ran just fine on machines with graphics chips with no acceleration at all, just dumb frame buffers.

You're probably right that a modern X server optimised for modern PCs won't run well on those machines, but the point being that this has little to do with X the protocol, and everything to do with the implementation of the X server and to a certain extent with clients being optimised for different performance characteristics.

As for Vulkan, there's no reason you can't use Vulcan with X. It's again an implementation question, not a protocol issue.

Now, the X protocol is awful, to be clear. There are plenty of issues with X that were worth fixing. But the time it has taken to get Wayland to a usable state (many would argue it still isn't - I certainly have no interest in running Wayland other than with XWayland possibly given the current state) suggests that opting to start from scratch instead of upgrading X step by step was a relatively poor choice - the X protocol is easily upgradable.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @12:35PM (#29096983)
X ran "fine" on those machines if you were ok with all the problems of 80s-90s era graphics such as flickering, tearing, windows taking noticeable time to be redrawn, stale contents when resizing or when something else moves above them, the occasional "solitaire effect" where the back buffer doesn't get cleared, or any of that other fun stuff from dealing with expose events...

Also I think it should be obvious by now that upgrading X step by step isn't viable anymore. That was already tried for 30 years and reached its limits of what you can do without breaking the core protocol, which Wayland has already demonstrated how most of that can be discarded.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @01:56PM (#29098160)
Avoiding flickering and tearing is something we've known how to do since the early 80's. It's not a protocol issue, but an implementation issue. If you don't double-buffer and and/or sync updates, then sure.

Redraw time when the systems were slow enough to for the client app to not be fast enough to render the content, sure, there's no way of avoiding that. But again that is not a protocol issue. Wayland can't help you with that. Blitting the graphics onto the screen was back to being limited by the hardware from MIT-SHM arrived ~'91.

> Also I think it should be obvious by now that upgrading X step by step isn't viable anymore. That was already tried for 30 years and reached its limits of what you can do without breaking the core protocol, which Wayland has already demonstrated how most of that can be discarded.

Upgrading the core protocol has hardly been tried. What has been done is piling on extensions - ironically exactly the same mess happening with Wayland to try to get back to reasonable parity with X. But even most of those didn't go very far. E.g. none of them tried stripping out more than a tiny subset of legacy stuff.

The very first message an X client sends includes the protocol version. Nothing stops you from starting by bumping the major protocol to 12, removing whatever you like from the protocol if a client connects and asks for 12, and upgrade Xlib to ask for 12 first and try again with 11 if the server barfs. Nothing stops you from making a version of a server that just refuses to let clients asking for 11 to connect, and defer those to requiring a proxy to translate/implement whatever you strip out if you care rather than upgrade the clients.

I understand why people got fed up and did Wayland instead, but that was largely organisational, not technical.

If there had been the will they could have done a dozen iterations of the core X protocol in the time it has taken to get Wayland reasonably usable and removed things piece by piece instead. To take a concrete example, there are about half a dozen ways of rendering text in X. Nothing would have prevented saying that X12.0 has XRender by default so you don't need to query for it, and that no other text-like rendering operation than RenderCompositeGlyphs8/16/32 is supported and just yanking all of the font code out of the server. If anyone cared, taking the old code and implementing a client side library providing the old string drawing functions would keep compatibility easily enough.

Nobody seriously tried doing this, because the politics of it was maintaining full backwards compatibility or building something new.

Wayland was a technical solution to a political problem. Frankly a fork and iterating would have likely gotten buy-in much faster.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @02:25PM (#29098500)
Once you are talking about double/triple buffering every client, you are getting into an area where there are accelerated graphics and where fullscreen compositing isn't going to be a performance issue. Of course Wayland doesn't "solve" it but it does remove the old slow code paths. If you're on an SoC with a GPU then you want to use it as much as you can otherwise you are wasting CPU.

The rest of your comment doesn't really make any sense to me. Somebody could make X12 but I'm sure you understand that doing that would have all the same technical/organization challenges as Wayland. I don't know why you would think making an incompatible fork of the X server and then trying to convince everyone to use it is a simple endeavor, it's not. There is zero will to actually do that, I've heard similar suggestions to make X12 for the last 15-20 years, and nobody has ever cared enough to do it because the only reason anyone ever uses X is for compatibility with old software. Once you take that away, there's nothing left. The closest existing thing to an X12 is, well you guessed it, Wayland.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @05:49PM (#29100766)
> Once you are talking about double/triple buffering every client

Nobody is talking about double/triple buffering every client, but the final composited surface.

> you are getting into an area where there are accelerated graphics and where fullscreen compositing isn't going to be a performance issue

Double-buffering was viable and done on quite a lot of 1980's hardware. The point remains that this is not a protocol issue.

> Somebody could make X12 but I'm sure you understand that doing that would have all the same technical/organization challenges as Wayland. I don't know why you would think making an incompatible fork of the X server and then trying to convince everyone to use it is a simple endeavor, it's not.

I didn't suggest it would have been simple. I suggested it would have been simple than a well over decade long effort to write a new system from scratch.

The point being that the reasons for the existence of Wayland are not technical, but political, due to the lack of willingness in the Xorg core team to break compatibility at the time. And we're still paying the price.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @06:32PM (#29101312)
You need to double buffer the clients or you will still get flickering and noticeable redraw. You can see this with older X clients. It actually is a protocol issue because X was explicitly designed to do this.

You are presenting this as if it's some kind of decision between "break compatibility" and "start from scratch" when really those are a lot closer than you think. Realistically, most of the X server is still overdue for a major rewrite/refactor. But I really doubt anyone would ever volunteer to do that work at this point.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Thursday November 04, 2021 @04:00AM (#29104491)
No, you don't need to double buffer the clients if the clients are properly designed and flush the request queue cautiously rather than willy-nilly, and the server takes a minimum of care rather than just stupidly processing requests one by one. None of the clients I use give flickering or noticeable redraw.

There may certainly be cases where it'd be harder to avoid, but realistically this hasn't been a problem for most X users for decades. Of course I'm not doubting that it is a problem for some, but it's not for me and haven't been since the 90's.

Re:How X Window Managers Work, and How to Write One (2014) by qwerty456127 on Wednesday November 03, 2021 @06:27AM (#29092848)
> ARMv7 and later, which come with graphics chips optimized for for something different than what X was built for

Are they SO slow on the tasks they are not optimized for they can't even beat a 25-year-old GPU like S3 Trio?

> I'd imagine that running a current distro with a current X WM wouldn't be a great experience on 90s machines.

Why does it have to be? What do we get for this cost? The only things in which I would find a modern Linux better than a 90s Linux are full UTF-8 support, modern crypto and hardware drivers availability.

> The difference will widen as Vulkan

I don't know a single person (among many dozens of Linux users I personally know) who would need it. I can only imagine movie makers using Blender or something like that

Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @06:36AM (#29092908)
> Why does it have to be? What do we get for this cost? The only things in which I would find a modern Linux better than a 90s Linux are full UTF-8 support, modern crypto and hardware drivers availability.

A lot of exploit mitigations, especially spectre/meltdown mitigations, allocator hardening, auditd, toolchain hardening flags that introduce runtime checks, syscall filtering, etc. have introduced major slowdowns. I'm sure this isn't the only reason, but it's the only reason I am familiar with. Ask someone familiar with a different sector of osdev and they'd probably rattle off a few more.

I have noticed that lots of tasks that would be fast a decade or two ago are slow today on a rbpi: tasks like switching workspaces, switching browser tabs, etc. have noticeable delays. Sway makes switching workspaces and some window management functionality nearly instant in comparison. I've compared it with i3 and openbox; others have compared it with dwm. I'll see if I can find a link.

A lot of tasks become faster with GPU acceleration, which is why OpenGL and Vulkan accel are helpful.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @07:39AM (#29093323)
> Sway makes switching workspaces and some window management functionality nearly instant in comparison. I've compared it with i3 and openbox; others have compared it with dwm. I'll see if I can find a link.

i3/dwm (or any X window manager), unlike Sway (or any Wayland compositor) has nothing to do with client window contents rendering. X and Wayland works fundamentally differently in that respect. Under Wayland the compositor and wm is the same. Under X the server and wm are separate programs in separate processes, and the latter is not involved in rendering the client window contents, only the window chrome, if any.

Re:How X Window Managers Work, and How to Write One (2014) by qwerty456127 on Wednesday November 03, 2021 @09:35AM (#29094319)
I see. Quite a reasonable, detailed explanation, thank you. I didn't notice any visible difference in perceived performance (just using the PC to write code, browse the web and watch videos) when I switched spectre/meltdown mitigations on/off on my old Core 2 Duo PC though. It just always worked perfectly fast.

Meanwhile, I often don't need any network connection (when coding, watching pre-download videos, or running data/number-crunching or build scripts). Can I expect 90s-like efficiency if I disable all the mitigations and hardening stuff?

Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @12:56PM (#29097289)
There are...a lot of good reasons to keep the mitigations enabled. All nontrivial software has bugs, and hardening measures can keep some of the worst ones in check. Frankly, the Linux desktop needs more of this, not less.

That being said, one writeup explained how disabling several mitigations improved http server perf by several factors: https://talawah.io/blog/extreme-http-performance-tuning-one-...

Re:How X Window Managers Work, and How to Write One (2014) by pantalaimon on Wednesday November 03, 2021 @06:46AM (#29092974)
There are no problems with running Vulkan applications on X11.

You must confuse something here - wlroots recently got a Vulkan backend, meaning you can run it on top of Vulkan API.

It has nothing to do with what Graphics API the clients will use.

Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @07:17AM (#29093141)
I was referring to the fact that OpenGL is becoming a second class citizen among the silicon giants, with more attention being drawn to Vulcan/Metal/etc. Now that sway supports a Vulcan backend, it won't be left in the dust stuck on OpenGL.

I'm not aware of GNOME or KDE having similar improvements on their X backends or the same happening for X WMs.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @07:32AM (#29093263)
X WMs do not have anything to do with rendering. The conflation of the server/compositor with the window management is a Wayland thing, and one of the big regressions in flexibility that current Wayland compositors bring. You may be confusing X WMs with the X server or with the toolkits rendering backends.
Re:How X Window Managers Work, and How to Write One (2014) by qwerty456127 on Wednesday November 03, 2021 @05:45AM (#29092619)
What are, if any, use cases where one would need a compositor? Other than transparent window decorations, wobbling windows and overlay dock? These are kinda cool but not worth any additional complexity or hardware resources IMHO.

I have never seen any screen tearing in my life by the way. Despite I have always been generally using decade-old PCs with lowest-end (mostly built-in) GPUs and Raspberry Pi is the only way I watch TV. The only annoyance I have with Raspberry Pi is YouTube the website (not the actual video, it plays Ok) being rather slow.

Re:How X Window Managers Work, and How to Write One (2014) by Seirdy on Wednesday November 03, 2021 @05:55AM (#29092662)
If you try scrolling in a web browser, especially fast scrolling in small increments, you're likely to experience screen tearing or other problems in the "smoothness". Compositors are included by default on most X desktop environments primarily for this reason.

The delays and latencies for me have been noticeably lower when using Sway on ARM, which is quite surprising because I was expecting the opposite. I hadn't even tuned it for low input latency yet.

Re:How X Window Managers Work, and How to Write One (2014) by qwerty456127 on Wednesday November 03, 2021 @06:07AM (#29092723)
> If you try scrolling in a web browser, especially fast scrolling in small increments, you're likely to experience screen tearing or other problems in the "smoothness". Compositors are included by default on most X desktop environments primarily for this reason.

I see. Curious that I have never noticed anything like this though. I have always been disabling compositors as I realized I don't really care if my panel is transparent. Perhaps the problem just doesn't affect Intel graphics (Raspberry Pi browsing is slow anyway so fast scrolling just doesn't exist there).

UPDATE: I've just realized I've actually seen screen tearing many times - always within specific Windows apps ran with Wine, e.g. Total Commander.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @05:56AM (#29092673)
Screen tearing is largely a software issue anyway - the moment you have hardware capable of double buffering there's no excuse for it unless you don't have sufficient memory.
Re:How X Window Managers Work, and How to Write One (2014) by kaba0 on Wednesday November 03, 2021 @07:41AM (#29093330)
Have you tried playing a video? Or moving a window around fast? Without a compositor there will be tearing on X. With a compositor, X is just a useless middleman.
Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @07:47AM (#29093368)
There's nothing stopping an X server implementation from doing compositing natively.
Re:How X Window Managers Work, and How to Write One (2014) by kaba0 on Wednesday November 03, 2021 @08:15AM (#29093557)
Other than writing an X server implementation is akin to writing a web browser from scratch?
Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @08:25AM (#29093644)
There's absolutely no reason to write an X server from scratch to add native compositing support.

You're also massively overstating the complexity of an X server. Writing X servers that are advanced enough to be usable is something a lot of individuals have done. It's nothing like matching a modern browser. Incidentally, if I were to try to do this today, I'd gut a proxy like Xephyr and make it rootless to support older clients, and make the main server itself only support the subset of the X protocol modern clients speak.

Re:How X Window Managers Work, and How to Write One (2014) by qwerty456127 on Wednesday November 03, 2021 @10:10AM (#29094791)
> You're also massively overstating the complexity of an X server. Writing X servers that are advanced enough to be usable is something a lot of individuals have done.

If so, why are we observing apparent shortage of developers to maintain the actual Xorg? I can't believe there are no people interested in maintaining it in the whole world. I thought it's so complex it just requires much more expertise and dedication than anybody is ready to invest.

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @11:20AM (#29095918)
Because Xorg is a huge beast with plenty of legacy, and it's also not a very fun project to hack on because it's largely maintenance of stuff people only care about when it breaks.

E.g. support for a bunch of backends of which most are not worth supporting if you want to implement a server from scratch, but which Xorg has been saddled with, as well as support for a bunch of legacy X functionality that nobody would bother implementing if implementing a server from scratch because most clients never use it.

E.g. a major source of complexity is supporting various X visuals that are irrelevant today when you can decide to only support truecolor natively. Another is support for a bunch of drawing primitives that you might as well just ditch all but the very simplest of, and support for legacy clients via a proxy like Xephyr. That said, most of those drawing primitives are also supported by any 2d canvas style library like Cairo or Skia that does client side 2d rendering, so if you want to implement them for an X server, just picking up one of those libraries would be time far better spent than implementing it yourself.

It'd certainly be a lot of work, and a lot more work to write an X server from scratch that is a complete replacement for e.g. Xorg - you'd need to support a number of X protocol extensions, but most clients backends will fall back on core functionality if extensions are not available (you'd definitely want to support some of them, like Xrender and SHM though, or your server would be largely unusable with modern clients).

At the same time, if someone wants to write a new X server, it'd be silly to do the work of writing their own backends when the could just grab wlroots and build an X server on top of that. "Modern X11" can be reduced to a relatively narrow superset of Wayland functionality if you defer most of the weirder legacy functionality that is rarely but very occasionally used to a proxy like XWayland, Xephyr or XPRA (all of which do, that said, rely on Xorg code) and make people use those for clients that need it.

Honestly, I think this is the most likely/viable future for X on Linux. It'd drastically reduce the amount of code to maintain and share that burden with other projects, and would make it far more viable to keep maintaining X support for those of us who wants (part of) it.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @12:46PM (#29097135)
I really don't understand this line of thinking or what you are trying to accomplish. If you are dropping things from the X protocol to the point where it's only XInput2.2, SHM and DRI3, and then farming the rest out to Xephyr, then it's no longer X anymore. That is pretty much entirely what Wayland already is. So you might as well just build it as a Wayland server and call it a day.
Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @01:14PM (#29097552)
I'm not doing this, it's a thought experiment. I'm happy to stay with X for a long time if necessary.

But what you list is not enough, though. There are enough extra bits that goes well beyond what Wayland provides today, like ability to write a standalone wm without having to build a whole compositor, for example, that you'd end up with something quite substantially unlike Wayland if you went down that route and looked at which pieces of X11+extensions people are actually using. It'd be far less than full on legacy X11, but far more than just Wayland.

It doesn't matter if it's not X. Nobody but extreme purists would care if it's not exactly X. What will matter is if you lose capabilities.

E.g currently my preferred wm (bspwm) doesn't have a Wayland alternative, so a Wayland compositor isn't a viable option for me without changing my workflow. Sway might be nice, but it's different and I have no compelling reason to put in the effort to make a switch until running Xorg starts becoming problematic. One day, maybe I'll feel compelled to switch but it won't be soon.

Even so, Xorg will hang around for decades in the form of XWayland because of old X apps people still use (e.g. none of the terminals I have installed on my system except for gnome-terminal supports Wayland).

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @01:25PM (#29097699)
I still see no purpose to do that, with a lot of hacking it would be also possible to make XWayland work with window managers. But that also would be pretty pointless to do because those other parts of the X protocol are also bad and need to be replaced, you might as well just rewrite the window manager.

If you liked bspwm then you might want to try this: https://github.com/riverwm/river

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @02:01PM (#29098230)
And I see no purpose in switching to Wayland as long as Xorg keeps working just fine.

> If you liked bspwm then you might want to try this: https://github.com/riverwm/river

If I wanted to spend time redoing my configuration, maybe, but I have better things to spend my time on. So in however many years it takes before getting Xorg running starts taking more effort than switching. I'm not expecting that to happen anytime soon.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @02:15PM (#29098372)
It doesn't really work fine though, there are numerous really old bugs that never got fixed. Here's a sample:

https://gitlab.freedesktop.org/xorg/xserver/-/issues/386

https://gitlab.freedesktop.org/xorg/xserver/-/issues/333

https://gitlab.freedesktop.org/xorg/xserver/-/issues/380

https://gitlab.freedesktop.org/xorg/xserver/-/issues/249

https://gitlab.freedesktop.org/xorg/xserver/-/issues/260

https://gitlab.freedesktop.org/xorg/xserver/-/issues/258

And I'm sure you could find plenty more. All this stuff is fixed or is trivially fixable in Wayland, by the way.

"If I wanted to spend time redoing my configuration, maybe, but I have better things to spend my time on"

I don't understand, you were just talking about spending significantly more time rewriting the X server...

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @05:53PM (#29100825)
> It doesn't really work fine though, there are numerous really old bugs that never got fixed. Here's a sample:

It works fine for me. I gave my reason for why I won't consider switching to some Wayland compositor. None of the bugs you list affect me, so your suggestion I look at a Wayland compositor which would require me to spend time changing my entire config only to be left running XWayland anyway because the terminals I use are X11 based.

It would be a massive waste of my time for no benefit whatsoever.

And this is why X will stay around for a long time: There are lots of us with dependencies like this and no reasons to change things until things starts breaking.

> I don't understand, you were just talking about spending significantly more time rewriting the X server...

Read again. I have not once suggested I'm planning on rewriting an X server. I pointed out doing so would have been a better choice than starting over from scratch, and that the choice to start over from scratch is the reason people are still sticking with X.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @06:27PM (#29101251)
I guess you can consider yourself lucky that you're not affected by those bugs? Things are ostensibly already broken and have been for quite some time, some of those bugs are over 15 years old. If you only care about bugs that affect you then it's not even worth having a discussion about this, you can't expect everyone to wait to make changes until it's personally convenient for you. And if that's not what you meant then the other stuff is still there if you change your mind and decide to switch.

"I pointed out doing so would have been a better choice than starting over from scratch, and that the choice to start over from scratch is the reason people are still sticking with X."

I would urge you to look into how much work it would take to actually fix those bugs and push out incompatible server/libraries/etc to people and then come back and see if you'd like to revise this statement. Because that is what we are looking at here. Remember what you are asking here is for every toolkit and program to do a "if x12 then dostuff elseif x11 then do otherstuff" and weigh that versus "if wayland then dostuff elseif x11 then do otherstuff".

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Thursday November 04, 2021 @03:55AM (#29104459)
There are always bugs in complex software, so sure. I can also consider myself lucky that I'm not forced into using a Wayland compositor as it'd force me to change my workflows in all kinds of ways.

> If you only care about bugs that affect you then it's not even worth having a discussion about this, you can't expect everyone to wait to make changes until it's personally convenient for you

I'm not expecting anything other than to keep using the software which works for me. I'm not the one arguing for people to change setups that works for us. Use what works for you. If that's Wayland that's your choice. For me it's not - it involves putting effort into something that doesn't give me amy benefits. Nobody is arguing for you to do anything or not anything.

> I would urge you to look into how much work it would take to actually fix those bugs and push out incompatible server/libraries/etc to people and then come back and see if you'd like to revise this statement.

No, I wouldn't like to revise that statement, because none of the bugs are relevant for an updated protocol unless you choose to keep the things that are broken, since the "worst case" is to throw away and start over the same way Wayland did.

> Remember what you are asking here is for every toolkit and program to do a "if x12 then dostuff elseif x11 then do otherstuff" and weigh that versus "if wayland then dostuff elseif x11 then do otherstuff".

And it's obvious that the number of if x12 then dostuff would have been far smaller and/or amortized over longer time because you'd only need them in cases where you actually introduced a breaking change that couldn't be fixed by using functionality that would keep working the same on both.

Most modern X11 apps already don't use most of the functionality of X that is worth deprecating, and for many of those who do the solution would be to change to a request that'd be worth keeping, not to add an if x12. E.g. as I mentioned there are a number of different ways of rendering text with X. The most popular terminals are split roughly in two broad groups: Those who use the old server side rendering, and those who use XRender (a couple of outliers use OpenGL). Most of the ones I've looked at use Xlib etc. directly rather than toolkits, though some of the font stuff in Xlib is wrapping the server side functionality in ways that could be retargeted to use Freetype.

If you remove the former, then ~half of the terminals would need to get updated to use the latter method or forced to use a proxy (ditching most of them isn't really an option - many of the most feature-complete ones use X directly, and all of the ones I have looked at have users who swear by them and will keep using them until there is a feature complete replacement; many of them are decades old and their users still don't agree there's one worth switching to) or client-side reimplementation of the font rendering. But assuming you were to retain the XRender glyph rendering you wouldn't need to special case for this hypothetical x12, just upgrade apps to use XRender, and you could yank out all the font support in the server. Moving to Wayland on the other hand requires all of them to change

To date most of the terminals I've looked at haven't been updated with Wayland support, and many probably never will, making XWayland and so most of Xorg still hang around as long as they have users and someone cares. Given how long many of them have survived, I'm guessing you'll have to wait for their user bases to literally die out.

The X12 approach would have allowed starting to actually deploy the improvements stepwise more than a decade ago. Or more. E.g. the XFIXES extension happened in 2003 and was the first real attempt at some somewhat potentially breaking changes hidden behind an extension flag rather than a version change (and didn't allow the server to actually ditch the old code). Nothing other than politics stopped a more drastic approach.

This notion that there were technical barriers stopping an iteration of X is pure fiction.

Re:How X Window Managers Work, and How to Write One (2014) by DonHopkins on Wednesday November 03, 2021 @06:35AM (#29092904)
Mid 80s hardware, actually.

Recreational Bugs talk [1989] by "Sgt." David Rosenthal (author of the ICCCM, the Andrew Window Manager, and NeWS, and an old friend), who explained the 80's era X-Windows hardware model and war on drugs quite well here:

https://blog.dshr.org/2018/05/recreational-bugs.html

>"You will get a better Gorilla effect if you use as big a piece of paper as possible." -Kunihiko Kasahara, Creative Origami.

https://donhopkins.medium.com/the-x-windows-disaster-128d398...

>The color situation is a total flying circus. The X approach to device independence is to treat everything like a MicroVAX framebuffer on acid. A truly portable X application is required to act like the persistent customer in Monty Python’s “Cheese Shop” sketch, or a grail seeker in “Monty Python and the Holy Grail.” Even the simplest applications must answer many difficult questions:

WHAT IS YOUR DISPLAY?

    display = XOpenDisplay("unix:0");
WHAT IS YOUR ROOT?

    root = RootWindow(display, DefaultScreen(display));
AND WHAT IS YOUR WINDOW?

    win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1,
                              BlackPixel(
                                  display,
                                  DefaultScreen(display)),
                              WhitePixel(
                                  display,
                                  DefaultScreen(display)));
OH ALL RIGHT, YOU CAN GO ON.

(the next client tries to connect to the server)

WHAT IS YOUR DISPLAY?

    display = XOpenDisplay("unix:0");
WHAT IS YOUR COLORMAP?

    cmap = DefaultColormap(display, DefaultScreen(display));
AND WHAT IS YOUR FAVORITE COLOR?

    favorite_color = 0; /* Black. */
    /* Whoops! No, I mean: */
    favorite_color = BlackPixel(display, DefaultScreen(display));
    /* AAAYYYYEEEEE!! */
(client dumps core & falls into the chasm)

WHAT IS YOUR DISPLAY?

    display = XOpenDisplay("unix:0");
WHAT IS YOUR VISUAL?

    struct XVisualInfo vinfo;
    if (XMatchVisualInfo(display, DefaultScreen(display),
                         8, PseudoColor, &vinfo) != 0)
        visual = vinfo.visual;
AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST?

    /* Is that a SubstructureRedirectMask or a ResizeRedirectMask? */
WHAT??! HOW AM I SUPPOSED TO KNOW THAT? AAAAUUUGGGHHH!!!!

(server dumps core & falls into the chasm)

Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @07:28AM (#29093232)
> Mid 80s hardware, actually.

I'm aware it ran on mid 80's hardware, but I didn't personally have experience with X that far back, so I stuck to what I knew for a fact it handled fine :)

> WHAT IS YOUR ROOT?

A lot of these are macros in Xlib that obscures that they're "just" looking up things in the display info returned on opening the display, though.

The X protocol is messy in places, but Xlib is far worse than necessary. I'm currently toying with a pure Ruby X protocol implementation (client side only; "why?!?" I hear you ask - I guess I must be a masochist; the real reason is that I'm writing a terminal in Ruby and the C extension annoyed me; I only need a small subset of the X protocol in any case; the reason I'm writing a terminal is that I'd like to experiment with terminal extensions to integrate with my editor - also in Ruby - turtles all the way down... I guess this just conclusively proves that I'm a masochist), and thus was forced to learn that the initial display info returns the list of screens and the root, and the black pixel value and the white pixel value.

So there's no good reason for the client to keep being this complex other than inertia - few people write applications directly to xlib and so there's little incentive to make it better.

There are lots of things in X that would be nice to ditch, though. I just wish there'd been a more gradual approach.

In fact, I've seen some want to keep maintaining Xorg - if someone ends up doing so, I'd strongly recommend they'd take the Wayland approach of a rootless X server for legacy clients, and then doing a review of clients and aggressively deprecating features which are mostly unused by modern clients.

EDIT: In fact, an X proxy that re-implements deprecated features would be very simple - it "just" needs to understand enough of the protocol to pass on packets it doesn't want to handle, and to rewrite sequence numbers if needed. Then it could do nothing if it connects to a "legacy" X server, but intercept requests when connecting to an upgraded X server. There are already several X proxies of varying capability that could serve as a starting point - e.g. Xephyr and Xnest.

Re:How X Window Managers Work, and How to Write One (2014) by DonHopkins on Wednesday November 03, 2021 @10:18AM (#29094936)
The problem with pure reimplementations of XLib in other languages is that there's no way they can use the client side X extension libraries that are based on XLib.

I learned that the hard way when trying to figure out how to use Display PostScript with CLX in 1992, which is an X client library written in Common Lisp.

https://www.cliki.net/clx

Few people still write applications directly to XLib, but many do write applications directly to toolkits and libraries that DO depend on XLib.

So we're all stuck with XLib from now until eternity. If you replace it, you lose the entire ecosystem of client side extension libraries, so you have to reimplement them all from scratch.

At the time, that was a no-go if you wanted to use Adobe's proprietary Display PostScript extension, which was quite popular and included with most commercial X11 servers of the era. Even if most important X extensions are open source, how about about them NVIDIA drivers?

Display PostScript is simply an old example from 1992 of what I mean, that I wanted to use from Common Lisp via CLX, but couldn't. But it shows how this problem has been around for a long time, and is never going away. The only viable solution was to dump CLX and call XLib and the Display PostScript extension libraries directly from Lisp through a wrapper layer.

But now the problem with clients and toolkits depending on X11 extensions is much more entrenched, not just limited to high-end exotic graphics-rich apps that want to use Display PostScript to draw a nice pie chart.

That's because of how heavily all modern X11 toolkits and clients now depend on a plethora of X11 extensions and their XLib-based libraries -- just to measure the display, shape windows, listen for input, memory map pixmaps, and composite the first pixel on the screen -- because they've long since abandoned X11's horrible old built-in pixel-based rendering API, broken font model, leaky input system, etc, and switched to using full stacks of X11 extensions (via their XLib based libraries) instead.

Re:How X Window Managers Work, and How to Write One (2014) by yjftsjthsd-h on Wednesday November 03, 2021 @12:21PM (#29096790)
> That's because of how heavily all modern X11 toolkits and clients now depend on a plethora of X11 extensions and their XLib-based libraries

Then Wayland will be more a nightmare still, since they moved everything but core rendering into extensions and say "just use wlroots" to deal with it.

Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @12:59PM (#29097332)
No, you have it mixed up. Wlroots is on the server, the Xlib problem is explicitly with client libraries.
Re:How X Window Managers Work, and How to Write One (2014) by vidarh on Wednesday November 03, 2021 @12:37PM (#29096997)
Absolutely agree that a general purpose replacement for Xlib would be a massive pain, but providing sufficient support for the core protocol to let you add whichever request types you need is quite simple (and I lifted that from a decade old starting point and made it work).

And for my use I only need to support about a dozen requests types, and no third party libs, so it's not that bad. My starting point only linked with Xlib anyway, nothing else, and I verified which requests Xlib actually sent via xtruss before I started.

But of course, that's because I only want to actually use it for something very simple. If I wanted to do something more complex I'd wrap a higher level library instead.

Re:How X Window Managers Work, and How to Write One (2014) by sprash on Wednesday November 03, 2021 @07:43AM (#29093343)
You think this is bad? Just look at a native Wayland "Hello World" client [1]. This doesn't even print hello world. You have to do the text rendering yourself. And you need at least 500 more lines to implement the equivalent to a simple XGetImage() call.

1.: https://github.com/emersion/hello-wayland/blob/master/main.c

Re:How X Window Managers Work, and How to Write One (2014) by bitwize on Wednesday November 03, 2021 @10:51AM (#29095485)
Your toolkit should abstract all that away. We have these wonderful things called dynamic libraries, that X was designed for a world without because they didn't exist under Unix yet.
Re:How X Window Managers Work, and How to Write One (2014) by sprash on Wednesday November 03, 2021 @11:16AM (#29095873)
If toolkits can "abstract that away" they can do the same on X11 and there is even less reason for Wayland to exist. There is no reason for you to even care about X11/Wayland if you only work with toolkits. So stop participating in a discussion that doesn't concern you.
Re:How X Window Managers Work, and How to Write One (2014) by md8z on Wednesday November 03, 2021 @01:02PM (#29097383)
"they can do the same on X11 and there is even less reason for Wayland to exist."

Well actually it's the reverse: the more abstractions were put into toolkits, the more it became obvious that there was little reason to use everything in X11.

Re:How X Window Managers Work, and How to Write One (2014) by erik_seaberg on Wednesday November 03, 2021 @06:36AM (#29092907)
Waypipe ships client-rendered images across the network; datacenters would fall back to software rendering because there’s no way to take advantage of a user’s desktop GPU. I think the industry will continue moving to Javascript or Wasm apps as the most widely portable and accelerated remote display system we have.
Re:How X Window Managers Work, and How to Write One (2014) by andrewshadura on Wednesday November 03, 2021 @07:55AM (#29093424)
> Waypipe ships client-rendered images across the network

That's also exactly what most modern GUI toolkits do when they run on X11.

Re:How X Window Managers Work, and How to Write One (2014) by WalterGR on Friday November 05, 2021 @06:13AM (#29117311)
Sorry if I'm being obtuse, but... why would X11 toolkits need to ship client-rendered images across the network?

Doesn't the server tell the client what to render, and the rendering happens on the client? Why would that result then be shipped over the network?

https://en.wikipedia.org/wiki/X_Window_System

Re:How X Window Managers Work, and How to Write One (2014) by andrewshadura on Monday November 08, 2021 @07:59AM (#29148816)
Also, in X terminology, the server owns/controls the display, the client is the app that wants to draw a window on the server’s display. The classic architecture would be client telling server what to draw, but these days what really happens is that clients draw locally into a buffer and then tell X server to draw the contents of the buffer.
Re:How X Window Managers Work, and How to Write One (2014) by andrewshadura on Monday November 08, 2021 @07:57AM (#29148810)
That’s been tried, but most toolkits stopped doing that because it was unreliable, slow, and the number of primitives offered by X wasn’t sufficient for any modern GUI.