News for hackers. Stuff that matters.
Re:RubyWM – an X11 window manager in pure Ruby by roenxi on Monday January 22, 2024 @07:38AM (#39088835)
Could we please have a comment about why this is an X11 WM rather than a Wayland compositor? Technical issues or a stylistic choice?
Re:RubyWM – an X11 window manager in pure Ruby by p_l on Monday January 22, 2024 @08:03AM (#39089039)
Outside of any personal preferences of author, Wayland compositors are just more complex. Even with availability of libraries like wlroots.

After all, a Wayland WM is not just a WM, it also has to run and handle display server including talking with HW if you want any sensible performance.

Re:RubyWM – an X11 window manager in pure Ruby by kaba0 on Monday January 22, 2024 @01:38PM (#39093421)
Because a window manager on X is roughly the equivalent of a Gnome extension. That’s just a design question where we draw boundaries.
Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @08:30AM (#39089329)
It's an interesting question...

Writing a Wayland compositor from scratch means writing the whole display server. Wlroots readme describes it as "about 60,000 lines of code you were going to write anyway".

For comparison my wm is <1k lines.

So they're not equivalent - writing a Wayland compositor from scratch is more like writing the whole X server first, before even starting the WM.

I could use wlroots or another compositor as a starting point. I did look at it, but I'm still on X, and have no compelling reason to switch. Yet, anyway, and that adds to the "cost" for me in terms of disruption.

Where I could translate TinyWM into a few dozen lines of Ruby in a couple of hours and switch to actually using it and build from there, and "just" suffer some nuisance that I can slowly chip away at when I have time, even getting a basic wlroots binding + minimal compositor running seemed like a far more complex project.

I'm itching to figure out how to eat my way further down the stack, but I can't justify spending time on it unless I see a viable way of doing it (relatively) piecemeal.

E.g. I can restart my wm without exiting my X session, and so without losing any open applications. That gets far more disruptive for replacing the X server (whether by another X server or a Wayland compositor), and also allows for a far faster cycle - I can spot a problem, fix it, restart the WM and keep working without having to close everything...

I think if I was to do a Waylabd compositor, a first step would be to put things like window management beyond an IPC boundary, just like with X.

Re:RubyWM – an X11 window manager in pure Ruby by yxhuvud on Monday January 22, 2024 @08:50AM (#39089493)
> I think if I was to do a Waylabd compositor, a first step would be to put things like window management beyond an IPC boundary, just like with X.

Isn't that already the case, by protocol definition? At least compositor and clients talk to each other over a pipe of some sort. It is actually a bit problematic because the way it is done put noticeable restrictions on both sides on processing things in time, because if it is full then shit hit the fan.

Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @10:26AM (#39090436)
Not in Wayland, no. The only boundary is between the client and compositor. With X there is a boundary between the client and server, and between the server, wm, and compositor.

With Wayland the compositor serves the same function as both the X server, wm, and compositor in one. There's nothing inherent stopping the addition of extensions to allow the same split as in X (but the server/compositor split probably wouldn't be worth keeping - the WM is easier to split out because it's far less latency sensitive)

Re:RubyWM – an X11 window manager in pure Ruby by kaba0 on Monday January 22, 2024 @01:37PM (#39093413)
That’s not true in this respect. This all is just an implementation detail, not mandated one way or another by Wayland.
Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @02:17PM (#39094013)
While it's not mandated, as I pointed out ("There's nothing inherent stopping the addition of extensions to allow the same split as in X"), I'm not aware of a single Wayland compositor for which it isn't true. If there is one, I'd love to hear about it.
Re:RubyWM – an X11 window manager in pure Ruby by markstos on Monday January 22, 2024 @01:15PM (#39093063)
TinyWM for wlroots is also less than 1,000 LoC. ( https://github.com/swaywm/wlroots/blob/master/tinywl/tinywl.... )

> I can restart my wm without exiting my X session

Sway also has a "reload" feature that preserves all open applications.

Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @02:28PM (#39094148)
Yikes. This is a great illustration of why I've steered clear of Wayland, when even with wlroots you end up with that much code to do that little.

TinyWM for X is 50 lines.

> Sway also has a "reload" feature that preserves all open applications.

As far as I understand, sway's reload just reloads the configuration. If Sway crashes, or you kill Sway's process, there's nothing left holding the sockets to the clients open, or managing the display - that's equivalent to killing the X server, not the wm.

With an X wm, as long as your x session isn't set up to quit when the wm quits, you can brutally shut down the wm, or it can crash, and the windows stay open, and you can restart your wm - or start another wm entirely - without losing any windows.

Re:RubyWM – an X11 window manager in pure Ruby by yjftsjthsd-h on Monday January 22, 2024 @04:38PM (#39095830)
FWIW, there is some effort to let QT applications survive compositor crash in a way that would be even more resilient than with X11: https://www.phoronix.com/news/Qt-Wayland-Compositor-Restart

Of course, that's a new feature they're working on, only helps QT apps, and requires the toolkit to track state (and by the same virtue, looks like it would have worked fine with X11 if they wanted to). So this is more of an interesting related tidbit rather than a disagreement.

Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @08:16PM (#39098128)
That's an interesting approach. It'd be easy enough to do for my own X apps as I'd mostly need to flush some caches and recreate windows and pixmaps. It'd generally be terminals that are most painful to use, and the terminal would be nearly trivial since they keep an buffer of the text anyway and so can trivially recreate the view once they succeed in reopening the window (the font rendering caches glyphs, and caches graphics contexts; just flushing those caches client side would make the terminal recreate them as needed)

Whether X or Wayland it would certainly make experimenting less painful. Browsers doesn't matter that much given they're reasonably decent at restoring.

(Another option there is xpra - "screen for X")

Fewer and fewer reasons not to start writing an X server ;)

Re:RubyWM – an X11 window manager in pure Ruby by yjftsjthsd-h on Tuesday January 23, 2024 @01:48AM (#39100313)
> It'd generally be terminals that are most painful to use, and the terminal would be nearly trivial since they keep an buffer of the text anyway and so can trivially recreate the view once they succeed in reopening the window

The cheap version of this is just using tmux/screen, but yeah honestly I suspect a lot of programs are easy to make recreate their GUI state if you care to bother, it's just that not everyone does (or should; it's a trade off and display servers aren't usually that crashy).

Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Tuesday January 23, 2024 @05:14PM (#39110707)
I wouldn't care either if I wasn't contemplating at some point getting my hands dirty with that layer too ;)
Re:RubyWM – an X11 window manager in pure Ruby by zokier on Monday January 22, 2024 @01:30PM (#39093291)
> I think if I was to do a Waylabd compositor, a first step would be to put things like window management beyond an IPC boundary, just like with X.

Afaik river does something in that direction https://github.com/riverwm/river

> Dynamic layouts generated by external, user-written executables. A default rivertile layout generator is provided.

> Scriptable configuration and control through a custom Wayland protocol and separate riverctl binary implementing it.

Re:RubyWM – an X11 window manager in pure Ruby by vidarh on Monday January 22, 2024 @02:59PM (#39094583)
i3wm, bspwm, etc, and many others have provided APIs like that "forever". The problem is that they're async and sit "besides" or "after" the actual window management.

E.g. one of the things I disliked about bspwm was that while I could get a feed of events and act on them, I couldn't intercept and modify or reject requests, so e.g. when a new window opened, bspwm would place it, and issue an event, and before my script could reconfigure the window it'd already be visible, so to get a floating desktop the way I wanted I ended up with windows flashing up in one location and then moving.

Put another way: The plethora of Wayland compositors is a strong demonstration of how these compositors don't give sufficient control via their external APIs, or people would write window managers for one or more of those compositors instead of writing more compositors.