Multiple Mouse Cursors in Wayland

(blinry.org)

66 points | by marvinborner 4 hours ago

16 comments

  • ofalkaed 1 hour ago
    I have never liked split keyboards but I might if each keyboard was also a mouse with its own cursor, it seems fun to develop the skill to work that way. Would also be useful at times if the the Thinkpad trackpoint and trackpad could each have their own cursor and I could leave one somewhere. Or maybe a cursor stack like pushd/popd, registers would probably work better; instead of virtual desktops just give me one massive desktop with cursor locations I can jump between, switch to cursor 3 it saves the location of the current cursor and jumps.
  • ben-schaaf 2 hours ago
    To add to the long list of caveats: This also breaks assumptions GUI toolkit and applications make about only one of their windows being focused at a time: `gtk_application_get_active_window`, `QApplication::activeWindow`, etc.
    • ed_mercer 2 hours ago
      I guess they could add a parameter cursorIndex defaulting to 0!
  • kelnos 2 hours ago
    I'm building a compositor now, and I've been thinking about multi-seat from the beginning, but I know there are lots of places that assume a single seat, and so this sort of thing won't work for me. It's actually a lot more work than you'd think to support this...
    • jchw 1 hour ago
      Given that a lot of the use case is interacting with two different programs simultaneously, even just supporting it at the compositor level is pretty valuable: then it should "just work" for that use case. You can't really do a whole lot about the fact that most Wayland clients are making assumptions about seats; well, you can, but that's a lot more work...
    • bch 1 hour ago
      > It's actually a lot more work than you'd think to support this...

      Like: how would one support multiple keyboards? Is there an experimental or logical model for that?

      • anilgulecha 13 minutes ago
        Multiple keyboards is trivial - unless you meant multiple active cursors. (If you've used a USB keyboard attahced to your laptop - you've already experienced multiple keyboards. Both work.)

        Multiple mice is esoteric.

      • Fire-Dragon-DoL 26 minutes ago
        It's not a direct answer, but Nucleus Coop (Windows only) allows playing multiple instances of the same videogame with different savefiles and allow using multiple keyboards and mice (is it mice for the hardware thing?)

        It's an incredible hacky piece of software that does work by putting together like 10 oss. Incredible and cool.

        They have some UX around this

    • jauntywundrkind 2 hours ago
      I keep thinking of trying to see how far I get re-doing Niri in River.

      The one other constraint that I'd really like to see relaxed is about displays, about being able to merge and subdivide screens as I please. Having a huge ultra-wide display really would be so much better if I could divide it up somehow. This is kind of the headline feature of stilch, which is a pretty neat compositor, https://github.com/wegel/stilch .

      Niri has some tickets on it too. Merging monitors into a big display, and splitting a display (moments before the multi-pointer ticket was filed in Niri), https://github.com/niri-wm/niri/discussions/1285 https://github.com/niri-wm/niri/discussions/3160

      There's been all kinds of rough incredibly hard things going on with Niri just trying to figure out how to handle some of the more interesting copy-paste scenarios, and with really weird sequencing issues across basically ephemeral inputs, that have really plagued the project and made life incredibly bad for downstream apps. This is just my opinion, man, but I think the lack of ambition about these ridiculous over the top features eventually starts hampering what turns out to be relatively prosaic asks. Better models for multi-seat, multi-cursor help scenarios like remote-desktop, and video-chat remote control, that at first don't seem needed, but are fundamentals that pay dividends if you shoot for them.

  • zImPatrick 1 hour ago
    cant read the entire article on ios because the left part is just somehow cut off :(
    • Zetaphor 38 minutes ago
      Same on Android, insane that people aren't validating for mobile in current year
      • DANmode 24 minutes ago
        Reader Mode works great.

        Setting a minimum width that works on your screen is a bad habit that’s luckily mostly dead, in favor of responsiveness.

  • AuthAuth 41 minutes ago
    I have been dreaming about a split keyboard with dual trackballs and two cursors for the past few months. This may be the kick i need to actually get on it.
  • kahf56 5 minutes ago
    Now I know why Web devs, frontend developers hate us
  • QuaternionsBhop 3 hours ago
    I've always thought this was a cool idea. It's obviously been on the minds of Wayland protocol developers since the beginning, otherwise it wouldn't be possible!
    • grumbel 15 minutes ago
      I thought it was the other way around, X11 has supported multiple cursor since 2009 and Wayland didn't add support for it since toolkit developers weren't making use of it anyway.

      Enabling in X works via:

          xinput list  # find second mouse id
          xinput create-master second
          xinput reattach <mouse-id> "second pointer"
      
      and to get rid of it:

          xinput reattach <mouse-id> 'Virtual core pointer'
          xinput remove-master 'second pointer'
      
      Works great for clicking, but keyboard doesn't work in some applications when enabled. Dragging windows might attach them to the wrong cursor and other issues. Playing around with xinput can also crash some apps (libgdk-3 here) or leave you in a state without a keyboard or mouse.
    • dmitrygr 1 hour ago
      Wayland: you can have two cursors but no, you can’t have screen sharing.
      • nvme0n1p1 1 hour ago
        Which desktop are you running where you can't figure out how to take a screenshot? Maybe some of the more tech-savvy folks here at HN can help you figure it out.
        • dmitrygr 1 hour ago
          Yes. Show me how to make zoom screen sharing work without pipewire and prayer.
          • opan 18 minutes ago
            Is there a reason you don't want to use pipewire?
          • nvme0n1p1 51 minutes ago
            Since you edited your post I'll rephrase my question: Which desktop are you running where you can't figure out how to share your screen? Maybe some of the more tech-savvy folks here at HN can help you figure it out.
            • dmitrygr 35 minutes ago
              KDE plasma. go wild.
              • nvme0n1p1 6 minutes ago
                Here's a post from 2023 where the majority of people say it just works, except for one guy who tweaked his env and broke it. https://www.reddit.com/r/kde/comments/18gfffw/is_zoom_still_...

                The fact you're griping about implementation details like pipewire makes me think you also tried micromanaging your env and broke something. If you use a fresh install and leave everything default, I'm sure it would work for you like it does for everyone else. I use KDE too btw.

        • fsckboy 1 hour ago
          screen sharing is not a static screencap that you would need to email or something
          • nvme0n1p1 50 minutes ago
            He edited his post to say something different. Nonetheless I'm leaving my original comment as is.
  • Dwedit 1 hour ago
    Focus of controls is the hard part. You end up needing a Per-seat version of focus in an application.
    • gizmo686 19 minutes ago
      Most of the focus issues should be solvable at the library level.
  • chmod775 54 minutes ago
    The more "typical" use for a feature like this is drawing tablets and touch screens. You don't necessarily want a touch/drawing tablet input to move your actual "main" mouse cursor.
    • gizmo686 21 minutes ago
      Wayland has a separate wl_touch type that is also associated to a wl_seat. So that use case can be accomplished on a single seat setup.
  • McGlockenshire 2 hours ago
    The original title, "State of multi-player Wayland" is a much better summary of the article. This ain't just about the pointers! In fact, the author is very explicit about that:

    > I think there could be a term that’s describing this concept even better – in the title of this post, I picked “multi-player”, to make clear that it’s mostly about multiple people who are collaborating. I’ve also seen “multi-cursor” or “multi-pointer” (which are missing the keyboard component).

  • bsder 40 minutes ago
    Maybe RedHat should contract this guy to finally get pointer warp implemented for Wayland everywhere it needs to be.
  • evertheylen 2 hours ago
    It's not as weird as you might think: laptops may have touchscreens (which can be multi-touch) on top of the "normal" cursor. IIRC, X.org can't really handle such cases cleanly.
    • kelnos 2 hours ago
      That's not what this article is about. You still only have one mouse cursor in that case, but two things (the touchscreen and touchpad) drive it.

      This is about actually having multiple, independent mouse cursors on the screen at once, with different input devices controlling different cursors.

      • minitech 2 hours ago
        Sometimes that's true, but sometimes (imo the superior approach) the touchscreen is independent from the cursor. I think touchscreen Chromebooks are like that, for example.
        • bee_rider 44 minutes ago
          Oh, that seems like it would be quite nice, actually. It is vaguely annoying when my touchscreen moves my mouse cursor.
  • jumperabg 1 hour ago
    Imagine working with two separate mouses at the same time - no keyboard.
  • nomel 2 hours ago
    Another possible use case might be mixed reality/VR displays, for simultaneous mouse cursor + eye tracking/control.
  • jauntywundrkind 2 hours ago
    On the web, PointerEvents and touch events both support multiple different cursors. https://developer.mozilla.org/en-US/docs/Web/API/Touch_event... https://developer.mozilla.org/en-US/docs/Web/API/PointerEven...
  • jchw 2 hours ago
    On the note of the two different kinds of seats, a tangent: better multi physical seat support is something I am passionate about, specifically, I want Windows-style "Fast User Switching" on Linux with RDP. Today's Linux RDP support usually acts like screen mirroring; you get a mirror of a physical seat. With GNOME I believe there is also now support to do remote login: you can log in remotely, and even disconnect and reconnect to a remote login session. But what you can't do is continue a physical session remotely or a remote session physically, and the reason why is sorta to do with seats. Sort of.

    See, when you start a graphical session on modern systemd-based Linux, a new logind session is created, and it is immutably tied to a seat. So you can't just remove the seat from a running logind session and then make it remote, or add the seat to a running logind session and make it physical. I actually tried patching systemd-logind to do this, but when I proposed it upstream, Lennart Poettering himself actually took the time to explain that this wasn't the intended way to do it: instead, you would actually just create a new logind session and drop the old one entirely, or literally whatever you want.

    Which to me sounded perposterous, but then I realized that it really wasn't that ridiculous. As it was, when you boot a desktop using systemd-logind, the desktop itself doesn't typically run much of anything directly in the session context anyway - the compositor and almost all services actually run as user services, as in systemd-land having more than one active desktop session per user isn't really supported. Okay so we can do this!

    And so I set out to prototype this with KDE, but there are still a few issues...

    - First and foremost, $XDG_SESSION_ID. Believe it gets set by the systemd PAM module somehow? I don't fully recall. Either way, it gets used by various programs to determine the current logind session, but if our graphical session can "roam" between them we need a mechanism that can handle changing over time. I propose we stuff the current logind session ID into a file in $XDG_RUNTIME_DIR instead.

    - Secondly, compositors need to be redesigned to handle this. Compositors today can hotplug displays and input devices - that's a good start. Unfortunately, at least kwin can't switch backends at runtime. You can really go one of two ways, and I tried a bit of both and either can work but both are a bit ugly: one is to make a single backend that can handle either case and the other is to allow switching the backend at runtime. Either way, when running remotely the card* DRM nodes are unavailable so you need to switch to renderD* nodes instead. You can also use both, and only use card* for scanout when available, but it seems a bit trickier.

    - Finally, I genuinely have no idea how this could or should be handled in non-systemd environments. I have admittedly forgotten how that all works. It would be rather lame to simply require logind for this to work, but sadly it is the path of least resistance at least at first.

    And maybe some more, but otherwise the concept does indeed broadly work. I mainly have only tested it in virtual machines with DRM native context, but I can see everything working switching in either direction at least once before things start to get screwed up. Even OpenGL clients and audio playback can move seamlessly! It's just like what Windows accomplished over 20 years ago!

    Aside from convenience and being cool, it would also solve a couple problems. No need to worry about the limit of only one session per user: just move your session with you. No need to worry about your physical session being unlocked when remotely connected: when you log in this way your physical seat gets disconnected from the session entirely and the display manager takes it back over.

    I actually would really like to at least make some progress on ground work that would be needed to make this happen, although I'm not really that sure that anybody cares. But either way this post's brief discussion about physical vs logical seats activated a few neurons so I couldn't help but dump this out.