I Hate Programming Wayland Applications

55 points by gioele


mrexodia

Don't get me wrong: I'm not expecting that e.g. DPI aware mult-monitor applications using several input devices, mixed refreshrates and hot-plugging of devices "just works"

In my opinion this is exactly what you should expect. What’s the point of an abstraction if it cannot handle complex cases like that?

moverest

I share the author's frustration.

It seems like Wayland was never designed to build a desktop experience but as the most modular composition system and then the desktop part was added as an afterthought and on a ad-hoc basis. Thus you end-up with all this idiosyncrasy. I can think of at least three ways to handle scaling and you'll probably need to implement them all as a fallback. Let's not even get started on fact that different compositors implement a different set of protocols and they sometimes behave differently. At this point, I'm not even sure there's a good way to fix this mess.

To be fair, if you write your application on top of a toolkit (e.g. GTK, Qt) or a library (e.g. SDL, winit), it hides all of that. The downside is that then you're then reliant on them to support all the Wayland features you need.

gir

I share the author's frustration, because I've been at this exact place.

I have this tiny C/X11 program, xvisualbell, that simply blinks your screen (all displays) to get your attention. Notice how the whole program fits on a single page, or under 50 lines of code including blanks and comments.

I attempted to port this to libwayland twice (using hello-wayland as a starting point, and - embarrassingly - even an LLM). Not only did I not get it to work, the code to draw a simple window easily blows up to 300-400 lines (while missing any of the xvisbell "features").

Since it doesn't hurt to ask: If someone could port this thing for me, I'd love to pay you 100€, or a charity of your choice double that.

intelfx

So, the author uses a super-high-level, super-primitive SDL1-esque immediate mode drawing library under X11, and then complains that he cannot replicate the simplicity when using the lowest-level API possible under Wayland (roughly equivalent to raw xcb)?

Color me unimpressed.

jmtd

Entertaining and depressing in equal measure

dpc_pw

The internal programming model is not a big problem as long as it has no issues preventing better higher level primitives. Lots of people complain about Vulkan in a similar fashion: "so much work to do things that were simpler in OpenGL".

The thing is - you typically don't need to use lowest layer available. If it's possible to build nice higher level libraries, use these and be happy. Just like we all don't need to write machine code by hand.

Lots of tech is best when it has inconvenient but precise and efficient lowest layer plumbing and then many choices of higher level layers with good UX.