Hyprland: A dynamic tiling Wayland compositor(hyprland.org) |
Hyprland: A dynamic tiling Wayland compositor(hyprland.org) |
"...there is still a lot of boilerplate involved in writing a compositor, much more than for an X11 window manager, namely setting up your own rendering code, registering and storing input devices and screens in your own data structures, passing input events to windows, calculating bounds for bars and other overlays (courtesy of layer-shell) and others. X11 handles all of this for you..."
https://tudorr.ro/blog/technical/2021/01/26/the-wayland-expe...
<edit> Several people mentioning wlroots. I can't say I've ever attempted it myself, but if you take a look at the blog post above, the author is very clear on the fact that even with the benefit of wlroots (which they highly praise) writing a Wayland compositor is still a lot more work than writing an X11 window manager (which they have also done, so they are something of an authority). wlroots doesn't abstract everything away, it just gives you a bunch of useful tools.
"With Wayland, you handle everything, even with wlroots."
It is hard to quantify how much buggy, or less buggy, are "amateur" Wayland compositors compared to their X11 counterparts. While it is true that a Wayland compositor programmer has to code by hand a lot of boilerplate as I explained in the article, now that the absolute ugliest yet-still-essential parts have been abstracted away in the scene graph API (before, if you didn't implement damage tracking, you had to basically say goodbye to your laptop's battery), besides the other ugly yet-still-essential parts that are already the entirety of wlroots, now compositor writers have the sweet-spot where they can integrate the special behaviour their compositor is all about with nicer graphics, rendering, input handling etc. IMO, this actually leaves room for less bugs, and all around a much better, and stable, experience, than what one would get with an X11 WM + a X11 compositor on top.
And, looking at this compositor, Hyprland, it looks like just that. It's a nice dynamic tiling compositor, but it also has some very slick graphics, animations, config system. Looks like nothing I've seen before in the ricing space. And by quickly looking through its source code, it looks like it benefited massively from wlroots and from the scene graph API, plus all the other Wayland protocol extensions that are implemented ready-to-use in wlroots. Great work from the community!
[0] There was a subtle mechanism-not-policy error where they made screenshots impossible without some back-channel being available. In hindsight, there should have been mechanisms for sharing buffers at the protocol level. "Can't share" turned out to be a forced policy, and the wrong one.
And because screenshots are a privileged operation, this will always need to go through a back-channel anyway to handle the security aspect. Otherwise you'll end up with a repeat of X11 again where any Wayland client connected to the server can scrape the screen at all times. So for desktop use there's really no reason to ever put it in a Wayland protocol. The design from the beginning was to keep privileged operations (like screenshots and input grabs) out and that still holds true now.
That comparison is a bad one to make. Compared to just a window manager, that's correct. But you have to compare Wayland compositors to X11 compositors and for that it's about the same amount of work. Either one expects you to bring your own rendering because that's the main benefit of writing a compositor.
It also might make sense to compare X11 window managers to compositor plugins. The reason people seem to prefer wlroots is precisely because it offers more power and more control over the just writing a window manager.
The observable effect of this is that the long tail of niche projects like X11 window managers, custom toolkits or small applications (that don't carry around extremely heavy dependencies like GTK/Qt) gets decimated. The assumption that this is done on purpose is plausible.
Shoutout for Cardboard, an awesome Wayland compositor and a rare example of Scrolling Tiling window management.
eg. wlroots
And frankly, for putting together a window manager the proper choice of action is extending an already existing compositor.
If you speak about a probably working one instead of a toy one the difference between X11 and wlroots isn't that big AFIK.
It's just that with X11 you could create a toy compositor with very little lines of code and that's not possible anymore.
But then toy compositors also kinda don't matter in the grater picture so it's not really a problem.
> Arch, NixOS and openSUSE Tumbleweed are very supported. For any other distro (not based on Arch/Nix) you might have varying amounts of success. However, since Hyprland is extremely bleeding-edge, distros like Pop!_OS, Ubuntu, etc. might have major issues running Hyprland.
and
> This project is under development and is constantly changing.
It’s not practical to expect that they will support every distro from the get-go, when they are actively developing it.
Hyperland's wiki only lists "Dwindle" and "Master" layouts, which from the description are strictly less versatile than i3 (and Sway?) in exchange for convenience if those layouts are what you want. Does it even have something as flexible as i3? (and Sway?)
That alone is interesting enough to get me to look at switching..
Just so that I know beforehand, can transparency, gaps, animation be turned off?
One of the first things I do on a new device is to disable animations and similar "eye candy". On Gnome it's hidden, but can be changed with gnome-tweek-tools ; on Android it's hidden too, in the developer options that you have to unlock (7 taps on build number).
In both cases, those animations easily lose frames and are distracting, without talking about the frivolous power spending on portable devices, but they are enabled by default and not easily removed.
It bugs me to jo end that wrong priorities seem to apparently be the norm.
I don't remember which extension I use to work around that; maybe this one: https://extensions.gnome.org/extension/1317/alt-tab-switcher...
Having a compositor that does desktop zoom is very nice too, although not quite in the same class of features as those eyecandy animations. Frustratingly, Kwin won't let you set a mousewheel keybind for this zoom effect, a senseless limitation. You can get around this with xbindkeys though, using config like this:
"qdbus6 org.kde.kglobalaccel /component/kwin invokeShortcut view_zoom_in"
Mod4 + Super_L + b:4
"qdbus6 org.kde.kglobalaccel /component/kwin invokeShortcut view_zoom_out"
Mod4 + Super_L + b:5
I have no clue how you'd fix this if you're using Kwin/Wayland..1: https://macos-defaults.com/dock/mineffect.html#set-to-genie-...
Have you ever heard of Phoenix? https://github.com/kasper/phoenix/. Despite googling around for this exact topic, with 3.8k stars I had never heard of it. Apparently someone has created slim, JS scriptable interface that is basically tailor made toward creating your own tiling WM. I just installed it and loaded one of the examples: https://github.com/nik3daz/spin2win. And what it does is basically ignores the built-in spaces and creates truly virtual desktops by just hiding and resizing windows. And it works pretty well. The response time between switching "desktops" is basically instant.
However I'm not sure Swish solves the big benefit of i3/bspwm for me, which is the lightning-quick virtual desktop and "send to desktop" functionality of a tiling WM on linux. Having two apps open side by side is useful, but not quite as useful as having two apps open full screen on virtual desktops 1 and 2, and the switch between them being totally instantaneous.
I recall that yabai can achieve this with SIP disabled. It somehow injects code to disable the Space switching animation, so hotkeys to switch Spaces become instant.
There is a small risk that we end up with competing, mutually incompatible ways of taking screenshots on a Linux desktop. If someone wants to "install Wayland", technically they might end up having to research which framework they have to work with to make a Zoom call and screen share, which could be incompatible with Google Meets and screen sharing. Indeed, that dynamic will force centralisation on a specific set of libraries just like X used to with drivers - for no particular reason other than they didn't feel like scoping out the original specification a little more practically. If all the Wayland compositors are going to be expected to use the same library, they may as well have included it as an appendix back in '08 and saved all the mucking around in the mean time.
This is hardly the end of the world and I do think the people involved in Wayland made a good attempt. But hindsight is 20/20 and the wart is now quite obvious.
It depends on the app. Chances are older apps needs to be updated to use the portal.
>There is a small risk that we end up with competing, mutually incompatible ways of taking screenshots on a Linux desktop.
No, there's only one way. Use the XDG screenshot portal. It's not a library, it's a standard API the desktop implements.
>for no particular reason other than they didn't feel like scoping out the original specification a little more practically
There was a reason. They didn't scope it out because they couldn't. Privileged operations need to be implemented using OS-specific security facilities. There's no way to make this work correctly just with Wayland. On Linux it needs a sandbox, and those are very different in scope and design from a window system.
>But hindsight is 20/20 and the wart is now quite obvious.
No, there's no wart. Or rather, if there is a wart, it's on the OS itself and how it does security. Linux didn't have a way to do this kind of sandboxing before, so someone had to invent that too. Efforts to hack sandboxing into X11 (see Qubes OS) have run into these same problems.
"The protocol is great, you just need to rebuild your Audio/Visual stack to support it" is certainly a reasonable take when dealing with something as weird as X. But, and I say this with a certain level of sympathy, bit it showcases a deep inflexibility in the design of Wayland.
Taking screenshots is not that hard by default. I'm very glad that someone is taking on the mammoth task of improving the linux graphics stack, but it is obvious that they designed screenshots out of the system then had to work for a decade to design them back in by reworking the way multimedia is done, and de-facto we're only going to be able to use Wayland in conjunction with XDG standards making sure that implementing the light protocol in a light compositor is a mistake. That isn't the end of the earth, it is no worse than what we do now - but it is a glaring weakness in the Wayland protocol that could have found a way to be usable from 2008 -> 2018.
I'll admit it is a little bit janky (which the author admits/warns about). But it seriously does work better than yabai. This config (using Phoenix) basically abandons the native "Spaces" functionality and does everything by just maintaining an internal window state and moving windows around fast. So you don't have to disable SIP (a big thing for me, since I want to use this at work). I'm seriously kind of blown away, this is miles better than apps that people are paying for, and it was just sitting here in this guy's github fork.
It is super disappointing this is the best that Mac can do though. There is no reason there shouldn't be a mostly-native (ie, less janky) tiling wm solution on the platform.
Severe over engineering, unstable interfaces, massive boiler plate and huge development overhead is preventing the long tail "at the protocol level".
As example: Compare the Wayland "Hello World" [1] with X11 "Hello World" [2]. If you want to add the ability to take screenshots it gets exponentially worse. (Also the Wayland version is not even capable to render strings.)
1.: https://github.com/emersion/hello-wayland/blob/master/main.c
No, all those can be solved with client libraries. X11 had Xlib and the other client libraries. Those X11 libraries don't make sense in Wayland, but the client libraries that stayed relevant (freetype, cairo, etc) can still be used.
>If you want to add the ability to take screenshots it gets exponentially worse.
No, in both modern X11 or Wayland, you should use the same API for screenshots: the XDG screenshot portal.
>Also the Wayland version is not even capable to render strings.
Sure it is, but you have to use client-side rendering. Client-side rendering is also the norm in X11, since decades ago when Xft was released as another one of those client libraries. That X11 hello world is short because it's using obsolete APIs.
There is no easy way to open a Window and render a string. Period! You either need to write it yourself completely (as OP stated) or you can use Gtk/Qt or other heavy weight "client libraries" (cairo and freetype do not create Wayland windows and therefore are not applicable here).
Look at the code again! If you really think that the code at [1] is in any way a great solution as compared to [2] we are going to disagree.
> No, in both modern X11 or Wayland, you should use the same API for screenshots: the XDG screenshot portal.
ZERO screenshot apps on X11 use XDG screenshot portal, they all use XGetImage(). Mainly because the assumption that a dbus-daemon is always running everywhere is mostly false. Also XDG screenshot portal is simply not a good solution. It is cumbersome to use, contains tons of edge-cases and pulls a dbus dependency for something that could be solved much simpler with onboard OS-functionality without the need for extra daemons and weird binary protocols
> Client-side rendering is also the norm in X11, since decades ago when Xft was released
Besides the point, but you are still wrong. Xft does server-side rendering via XRender. The cache is rendered only once on the client but that's a technicality, spline tessellation was supposed to go into the server but Keith Packard had more important things to do at the time.
Yes, if you want to use a secure system then you need to only go through secure APIs. If you cut out security in the name of making a "light" compositor then you just lose the ability to run sandboxed apps correctly, so it's crippling your desktop for no good reason. The XDG portal was built as a secure API to support Flatpak but it doesn't actually need Flatpak. The compositor is what needs to implement it so any sandbox can use it.
Yes, there is. Use a client library. That's what they're for.
>You either need to write it yourself completely (as OP stated) or you can use Gtk/Qt or other heavy weight "client libraries"
This is exactly the same as in X11. Remember Xlib is one of those heavy weight client libraries. The X11 example you showed uses Xlib.
>Look at the code again! If you really think that the code at [1] is in any way a great solution as compared to [2] we are going to disagree.
I don't think either of them are great. I'm saying that's comparing apples to oranges.
>ZERO screenshot apps on X11 use XDG screenshot portal, they all use XGetImage().
They shouldn't. Like most parts of X11, XGetImage is an obsolete API. You don't want to use that in modern clients.
>Mainly because the assumption that a dbus-daemon is always running everywhere is mostly false.
No, dbus is used by basically all modern desktop environments on Linux. If you don't have dbus available you're going to have a lot more problems running normal Linux apps than just dealing with the differences between X11 and Wayland.
>Also XDG screenshot portal is simply not a good solution. It is cumbersome to use, contains tons of edge-cases and pulls a dbus dependency for something that could be solved much simpler with onboard OS-functionality without the need for extra daemons and weird binary protocols
X11 is also one of those weird binary protocols that isn't onboard OS-functionality and has more edge-cases, so according to this XGetImage isn't a good solution either.
>Xft does server-side rendering via XRender.
No, you've got rendering mixed up with compositing. With Xft, the rendering of font data to pixels is still done in the client. XRender, despite the name, is frequently only used to composite surfaces together. That's doing the same thing that Wayland is doing.
How is obsolete and what makes XDG portal a better option?
Aside from that, it's the slowest and worst possible option in X11 because it copies the pixels into the socket. To handle large images you want to at least use MIT-SHM. XGetImage should only be used as a fallback. Or better, just don't use X11 APIs at all.