12 ms·
Improving cursor rendering on Wayland
- Vilian 3y agoxorg and it's problems is so funny
- sprash 3y agoIt's a Wayland problem if it is really problem at all though. The author complains that XCursor themes take too much space on disk (They will live uncompressed in VRAM anyways). Considering we are talking about Megabytes in the age of Terabytes HDDs, as long as you don't want to install thousands of XCursor themes on the same machine this is really a non-issue.
- jiehong 3y agoAnother more important problem discussed is a lack of cursor sizes.
- cesarb 3y ago> Considering we are talking about Megabytes in the age of Terabytes HDDs, Most distributions still use a "Live CD" format, actually a "Live DVD" nowadays (with a few hacks to make it also work as a USB pen drive image), for their installers, and that limits the installation image size (which also includes enough packages for an offline install of a desktop environment) to a bit more than 4GB (they fit into a common 8GB USB pen drive). So it being the "age of Terabyte HDDs" does not matter, for packages expected to be installed on a normal desktop system.
- walteweiss 3y agoDoes it make sense though? Any USB drive is so super cheap these days, you can easily get something like 128 Gb for $15. Even if you live in an area where it’s not as easy (e.g. not very developed places), you’re likely to find, say, 32 Gb for less than $10. So I don’t know, maybe someone needs that 4 or 8 Gb limitation, but I believe it’s a non-issue in most cases. Also, on top of that, we do have a very speedy Internet I’m so many places. Which means if you’re limited here, you can go with the net-installer. If you’re limited on both, more likely it’s a very niche case and you can have a spare large disk to download everything offline.
- prmoustache 3y agoDo we have to waste just for the sake of wasting?
- walteweiss 3y agoDo you mean time and energy for optimising things that make no sense, so you have no time and energy to optimise things that make sense?
- immibis 3y agoNot optimising things that "make no sense" is how we ended up with operating systems needing gigabytes of RAM just to boot, and AAA video games taking over 100GB each. A reasonably efficient system is the sum of reasonably efficient parts, or else you end up in UniformlySlowCode hell.
- destructionator 3y ago> So it being the "age of Terabyte HDDs" does not matter, for packages expected to be installed on a normal desktop system. But neither does the "size on disk" because the ACTUAL size on disk might be reduced by gzip/bzip2/xz/zstd/whatever is invented later. Even if the program using the package doesn't support compression, it supports filesystems and filesystems often support some kind of transparent compression. It isn't a hard problem to solve.
- Izkata 3y agoThe one I made for myself decades ago is 632K, so possibly not even megabytes.
- destructionator 3y agothis article is describing basically wayland adopting the x way of doing mouse cursors just with newer file formats lol
- deleted 3y ago[deleted]
- saurik 3y agoThe article essentially says--whether this is a good idea or not--that GTK is the one hold-out, which I wasn't really expecting as a punchline; why is GTK not implementing this?
- rcxdude 3y agoIt's a wholly expected punchline to anything wayland: by most accounts Gnome is one of the worst offenders in the death-by-comittee wasteland that is standardising protocols in wayland.
- jchw 3y agoAs far as I can tell, nobody has filed an issue on Gitlab for wp-cursor-shape, nor posted an MR. https://gitlab.gnome.org/GNOME/gtk/-/merge_requests?search=wp-cursor-shape https://gitlab.gnome.org/GNOME/gtk/-/merge_requests?search=w... https://gitlab.gnome.org/GNOME/gtk/-/issues/?search=wp-cursor-shape https://gitlab.gnome.org/GNOME/gtk/-/issues/?search=wp-curso... Nothing on Mutter either: https://gitlab.gnome.org/GNOME/mutter/-/issues/?search=wp-cursor-shape https://gitlab.gnome.org/GNOME/mutter/-/issues/?search=wp-cu... https://gitlab.gnome.org/GNOME/mutter/-/merge_requests?search=wp-cursor-shape https://gitlab.gnome.org/GNOME/mutter/-/merge_requests?searc... It looks like the old GTK mailing lists were moved to Discourse at: https://discourse.gnome.org https://discourse.gnome.org - so I tried searching wp-cursor-shape: https://discourse.gnome.org/search?expanded=true&q=wp-cursor-shape https://discourse.gnome.org/search?expanded=true&q=wp-cursor... Maybe it can be found under other terms of course, but all I'm saying is, before picking up the pitchforks, maybe it'd be worth asking if they'd just accept an MR. Yes, I know many (myself included) are not thrilled with GNOME's approach to Wayland, but it's not going to be any more productive to just assume bad faith, at some point you just gotta push forward.
- PennRobotics 3y agohttps://gitlab.gnome.org/GNOME/mutter/-/issues/3276 https://gitlab.gnome.org/GNOME/mutter/-/issues/3276 ?
- deleted 3y ago[deleted]
- mouse_ 3y ago"Well lol just draw a png haha Well, no, it's not that simple. Rasters are annoying. Raster means an image is stored with pixels, for example a png, or an mp4. The problem with rasters is that when you resize them, the computer has to take a wild guess at what it should look like." The problem with any display this software is going to run on is that it is also made with pixels. GTK foundation tried this approach for years, putting all their eggs into this basket, and recently having a reckoning and admitting this approach has not been working. Pixels are here to stay.
- zamadatix 3y agoBy this argument now that GTK supports directly rendering vector fonts sharply at arbitrary pixel densities we should switch back to bitmap fonts so GTK fonts can be bitmap rescaled again. I.e. the recent GTK reckoning you're referring to is actually about avoiding an extra raster rescale for exactly the reasons quoted, not about wanting more of it.
- immibis 3y agoWhy can't GTK be asked for the pixel size the display server needs instead of converting them to yet another vector format and rendering them on the display server?
- deleted 3y ago[deleted]
- zamadatix 3y agoThe display server needs to be able to render the cursor or decide the cursor information even when no GTK (or other) apps are running. When it does so it needs to change the size of the cursor based on the display it's on. This size may not always be a whole number of pixels and may or may not change in the middle of a session. If you ever did cursor effects like macOS scaling the cursor on fast movement you'd need a way to handle that per frame size change request as well. In all it just doesn't make sense to move the logic for rendering the cursor into application frameworks. I think it'd be best if "another vector format" was really "another cursor format which allows the actual cursor data to be tagged with a format". That way every time someone wanted to change the cursor protocol to allow compressed bitmaps or animated files or different vector formats it didn't require a whole new cursor file format to do it. Think something like MKV but for cursor data.
- jiehong 3y agoWhat is this config.hl file format? At first, I thought it’s hlc [0], but I couldn’t find confirmation in the git repo either. [0]: https://www.linode.com/docs/guides/introduction-to-hcl/ https://www.linode.com/docs/guides/introduction-to-hcl/
- notresidenter 3y agoIt's the hyperland <https://hyprland.org https://hyprland.org> config format.
- jchw 3y agoHmm, this leaves me with mixed feelings. It's obviously easier if everyone just adopts libhyprcursor instead of implementing a spec themselves and everyone having to iron out interoperability issues. Hyprlang doesn't look large, it's probably on the same order of magnitude as your average JSON decoder/encoder, but OTOH it's kind of a bespoke language versus other more "standard" options and I think this is likely to hinder adoption more than anything else. It's another "thing" whereas the desktop is already full of INIs, XMLs and JSON files. Then again, I have no stake in the matter. I think if Vaxry wants this to be adopted though, dropping it onto the world like this is probably not the most likely case to get there. It probably would've been worth bugging maintainers for other compositors (kwin, sway?) to see if they had any input/thoughts on the matter. I can only imagine Hyprlang as a dependency would've come up immediately as a discussion topic (I could be very wrong though.)
- notresidenter 3y agoThis is a first-party package from the Hyprland organization. This is meant to be used by people that use Wayland+Hyprland and want a better cursor. I don't think the idea is to make the package itself attractive but to make the Wayland+Hyprland switch attractive by saying: look, here are all the things we do better, including cursors.
- jchw 3y ago
- koterpillar 3y agoHow are cursors stored and drawn on let's say macOS? Honest question, comparing with X is easy but not exactly state of the art.
- flohofwoe 3y agoTL;DR: it's integrated with the rest of Cocoa. macOS cursors are provided by an NSCursor class which can either be one of the standard cursor image or provided through an NSImage object, which supports a number of data types (among the usual pixel-based formats like PNG or JPEG also PDF), it looks like applications can also register their own data formats via a class called NSImageRep.
- RVuRnvbM2e 3y agoHuh. So it's very similar to the Wayland protocol described in the blog post.
- aquova 3y agoI've been experimenting with using Hyprland (a Wayland WM) on my laptop, and ironically Qt apps have been the ones that misbehave the most. Everything seems happy to use my preferred icon theme, but when hovering over a Qt app, the sizing greatly changes. I've mostly just gotten used to it (plus I never really got their overall theming correct) but I might have to try this out and see if it fixes my issues.
- diggan 3y agoI gave Hyprland a try some weeks/months ago, and seemingly it had a video memory leak where after some hours of usage, it ended up taking more than 5GB of VRAM, with no signs of slowing down. I found one issue (https://github.com/hyprwm/Hyprland/issues/2945 https://github.com/hyprwm/Hyprland/issues/2945) mentioning something similar, but no resolutions as of yet, so not sure what's going on. Gnome3 doesn't manifest the same issue, so worth checking out if it happens to you if you're curious about moving from Gnome to Hyprland.
- account42 3y ago> In the beginning of wayland, and in the core design spec, it's the client's job to draw the cursor. I mean, it kind of makes sense, as some apps might want to draw a custom cursor (e.g. games) Wait what. That's even more insane than client-side decorations.
- diggan 3y agoWhat exactly is insane here? That games/applications might want to draw custom cursors?
- __s 3y agoAny other system has a cursor hide feature that games/applications opt into. Everything else should have the compositor overlay the cursor This is particularly important because most applications aren't designed to render at monitor framerate, whereas games make an exception because they tend to be full screen applications & tend to render at a high framerate already
- yxhuvud 3y agoThis is inconvenient for someone writing a custom client as it is yet another feature to support, but it really doesn't matter for anything that involves framerates unless you start to change the cursor every frame or so. Normally you will just respond to events and it takes a bunch of work and it is irritating you have to do it, but it isn't computationally costly as it typically won't happen often.
- RussianCow 3y agoMy understanding is that most modern games use the OS capabilities for drawing their custom cursor to the screen instead of just hiding it and drawing their own with custom code. The reason for this is that you don't want the cursor to lag when the game experiences delays or when the framerate is poor. Off the top of my head, Crysis was an example of a game that did this wrong, as the cursor would get really choppy in game menus when the framerate was poor.
- 3y ago
- planede 3y agoUh, if gtk apps draw the cursor client side, what happens if such an app freezes?
- yxhuvud 3y agoThen the cursor doesn't change while it is above the app. You can still move it.
- bri3d 3y agoClients draw the cursor image, they don't render it to the screen or blit it. Basically, in the "old Wayland way", the Wayland compositor gave the client a surface and said "hey, draw something into this and I'll make it your cursor" and then the compositor well, composited it, using either true hardware cursor or an overlay layer of some kind. If the app froze, the cursor would still move, it just might not be updated. This seems clean architecturally but turns out to suck because now every client needs some kind of cursor drawing library in it, hopefully the same one everyone else is using so that cursor theming works and you don't get a different default mouse cursor in every app. So then Wayland introduced wp_cursor_shape, which is where the client instead says "hey, draw a 'standard pointer' cursor over me please." But, the "old" client-drawn way is still supported and used, for example in GTK apps. This proposal seems to just be a really complicated recommendation to change the file format used behind wp_cursor_shape, and a plea for "old" apps to either adopt this format/library or stop using client rendering. I think that switching to wp_cursor_shape pretty much Makes Sense for most apps, but the article didn't really sell me on this file format.
- yxhuvud 3y agoOh, that looks really neat. No support in mutter yet, though I haven't seen any dismissal either, so who knows if it will eventually gain support.
- 3836293648 3y agoAnd this lead to stupid problems like the cursor sometimes just not rendering over some apps, like Alacritty
- deleted 3y ago[deleted]
- magistr4te 3y agoreally not a fan of using the hyprland format for configuration. If this is supposed to be widely adapted, untying it from hyprland is necessary.
- zokier 3y ago> A max 96x96 Bibata cursor, a single cursor, is about 2MB. Umm this does not pass smell test.. 96x96x4=36864 bytes of raw pixel data. How does that become 2MB?!
- aquova 3y agoI have that exact icon theme installed, so I went and checked, and you're right. Most of the cursors look to be in the 160 KiB range (which includes all the sizes together), with only the ones that include animations getting into the MiBs
- dist-epoch 3y agoI'm pretty sure that by "single cursor" they mean "cursor pack". Yeah...
- thayne 3y agoSome suggestions for improving adoption of this: 1. Don't have a dependency on hyprlang. Other projects will probably be averse to that. Use a more common configuration language, using a common library. 2. Have a shim layer so that hyprcursor cursors can be used by applications that use the XCursor API (maybe have a drop in replacement library for libxcursor that delegates to hyprcursor). 3. Have a specification so other implementations can use the cursor format as well, in case other compositors/clients don't like your implementation for some reason.
- formerly_proven 3y ago> 1. Don't have a dependency on hyprlang. Other projects will probably be averse to that. Use a more common configuration language, using a common library. Use XDG ini.
- blueflow 3y agoWhat is XDG ini?
- reactordev 3y agoXDG is the freedesktop group I believe. https://specifications.freedesktop.org/ https://specifications.freedesktop.org/
- arisudesu 3y agoWhy are all these problems? Wasn't this solved already years ago in another software, I mean, Xorg? Why do we need to revisit the problem again?
- NoahKAndrews 3y agoI think what X did is still the standard, which this article explains is pretty suboptimal. Sometimes crappy solutions stick around until someone pushes for something better.
- TylerE 3y agoWe're in the position in the first place due to Xorgs decades of highly dubious technical decisions. For one, "network first" for a GUI is not a sane model, and that is only more and more true as more "compute" is pushed onto the GPU.
- radarsat1 3y agoDoesn't the CPU/GPU bottleneck which is already assumed to be slow actually provide the perfect opportunity for abstraction over a network protocol? Sending "what to draw" and "how" (shaders) over the wire infrequently and issuing cheap draw commands on demand? I think GPUs provide a better situation for a network first model than was available when X was designed.
- Spunkie 3y agoIs displaying a few hundred KB of data on the screen really enough of a "problem" that it warrants putting image libs and potentially other dependencies in the middle of something as basic as cursor rendering?
- minitech 3y agoDid you read the part that starts with “Well, no, it's not that simple”?
- matheusmoreira 3y ago> instead of being a caveman and making symlinks all over the place And what's wrong with that?
- TZubiri 3y ago1968: Mother of all demos presents mouse 1980: Personal Computers with mouse become popular, apple Lisa, Microsoft Windows 1 2000: Touch devices with stylus are popular 2007: Apple releases Iphone with finger touch 2015: Conversational interfaces like Alexa, Siri start becoming available. 2022: ChatGPT presents a huge tech improvement in conversational interfaces. 2024: "Actually let's rebuild this technology from the 80s from the bottom up. That's what we need" I do not regret moving away from open source/free software.
- sp1rit 3y agoThe thing I like about the Xcursor image format is that it so extremely simple[0]. Every semi-competent developer should be able to implement a parser/writer for the format in under an hour. But encoding the images with PNG does make sense, given the wide availability of libpng and the potential file size savings. I don't know how the feel about SVG support. One the one hand using vector graphics for cursors seems like a great idea but SVG is a very complex format, with the only real parser available being librsvg, which massively increases toolchain complexity. Too bad PostScript doesn't support transparency. [0]:https://www.x.org/releases/X11R7.7/doc/man/man3/Xcursor.3.xhtml https://www.x.org/releases/X11R7.7/doc/man/man3/Xcursor.3.xh...
- layer8 3y ago> PostScript I’m not sure we want a turing-complete language as a cursor format. ;) But I agree that a simpler vector format than the kitchen sink that is SVG would be good.
- iforgotpassword 3y agoMakes me think of the haiku icon format.
- thayne 3y agoI think the world is badly in need of a simple, modern, and widely available vector graphics format.
- open592 3y agoSurprised that Wayland would go the route of entirely deferring to the client for cursor rendering instead of providing a default implementation and exposing an api which client can use to assume control.
- deleted 3y ago[deleted]
- DaSHacka 3y agoWayland provides little by design, so this is quite typical. For example: Screensharing is handled by pipewire [0], changing keyboard layouts aren't defined [1] by wayland, and generally anything Wayland devs think would 'corrupt' their protocol. They leave most things to the compositor to implement, which leads to significant fragmentation as every compositor implements it differently. Long gone are the days of xset and xdotool working across nearly every distro due to a common base, now the best you'll get is running a daemon as root to directly access `/dev/uinput` [2] or implementing each compositors accessibility settings (if they have them) as a workaround. [0] https://superuser.com/questions/1221333/screensharing-under-wayland#1296805 https://superuser.com/questions/1221333/screensharing-under-... [1] https://unix.stackexchange.com/questions/292868/how-to-customise-keyboard-mappings-with-wayland#355428 https://unix.stackexchange.com/questions/292868/how-to-custo... [2] https://github.com/ReimuNotMoe/ydotool https://github.com/ReimuNotMoe/ydotool
- jorvi 3y agoI believe the Wayland spec writers / devs themselves have admitted that due to how strenuous working on X ended up being for them, they erred too much on the cautious side and underscoped Wayland.
- iforgotpassword 3y agoA form of second system syndrome, swing the pendulum too much in the opposite direction. Someone called the Wayland devs "shell shocked X devs".
- deleted 3y ago
- layer8 3y agoSince the Xcursor format is extensible, why not just define new chunk types for PNG and SVG? Such an approach could provide two-way compatibility.
- redder23 3y agoMakes total sense to make cursors SVG, kind of crazy that nobody has done this b4 and that it's that outdated. Then yet again, handling SVG takes a lot more than some uncompressed images. So my question is how many resources, ram ... does it actually take to make some 200kb SVG as a cursor compared to some old uncompressed picture that might be bigger, but it's simply put on the screen 1:1. I guess it COULD be just about the unit process but if it's full SVG support than cursors can now be animated and be calculating all kinds of shit inside the SVG.
- Someone 3y ago> Makes total sense to make cursors SVG s/SVG/a vector format/ I would think hard before supporting full SVG, as it opens a can of worms. https://www.w3.org/TR/SVG11/script.html#ScriptElement https://www.w3.org/TR/SVG11/script.html#ScriptElement: “A ‘script’ element is equivalent to the ‘script’ element in HTML and thus is the place for scripts (e.g., ECMAScript)”
- sebazzz 3y agoMost SVG renderers implement a subset of SVG, and that is just fine.
- Eduard 3y agoI want a color-inverting cursor for Wayland. MS windows has it for 30 years.
- animatethrow 3y agoFor many years the XOR sprite cursor was patented, but the patent seems to have expired in 2013. One of us should make the request to the GNOME/KDE/Wayland/DE people and link the expired patent: https://patents.google.com/patent/US5471570A/en https://patents.google.com/patent/US5471570A/en EDIT: The linked patent seems to only cover 1 bit inversion, not full color inversion. I can't find the patent for the full color, but recall reading that a patent stopped the adoption of a nice color inverting cursor for Linux that Windows has had for so long. If Windows has had it for as long as you say, then perhaps any relevant patents have expired?
- viraptor 3y agoThat patent is only for MSB XOR though and seems to be only for hardware. That's not the only way to do it if someone wanted to achieve the result of better visibility.
- BearOso 3y agoXcursor doesn't predate PNG. Heck, it came alongside a tool, xcursorgen, that could be used to process pngs and generate the binary cursor files. Xcursor appeared somewhere around 2002-2003 as an extension of Xrender. Before that X had monochrome cursors. There are some legacy X specifics in the theme format that would necessitate something more modern. IIRC, Xrender used a hash of hard-coded X pixmaps to find the cursor files to match. That's why some of the filenames are a long string of hex digits. The rest are predefined X cursor names.
- Findecanor 3y agoInstead of SVG, I wonder if not the ideal format would be Haiku's Vector Icon Format (HVIF) [1][2]. It has binary files that are much smaller and it too supports multiple levels of detail for different sizes. I heard somewhere that Haiku would use it for its own cursors, but my google searches for getting that verified have not been fruitful. [1]: https://www.haiku-os.org/news/2006-11-06_icon_facts/ https://www.haiku-os.org/news/2006-11-06_icon_facts/ [2]: https://www.haiku-os.org/articles/2006-11-13_why_haiku_vector_icons_are_so_small/ https://www.haiku-os.org/articles/2006-11-13_why_haiku_vecto...