-
Notifications
You must be signed in to change notification settings - Fork 3.1k
wayland: add support for tabel input #16276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wayland: add support for tabel input #16276
Conversation
36504fa
to
92498d3
Compare
Is this something GNOME won't implement or something that simply has never been reported? sway falls back to pointer events if a client doesn't support touch or tablet protocols, it would be much simpler to add this fallback in Mutter than go around fixing every single client |
Looking at https://gitlab.gnome.org/GNOME/mutter/-/issues/2226 from three years ago, I think it is unfortunately the former, at least at that time. PS: I agree by the way that mouse emulation in the compositor would be better, Labwc did the same as Sway for tablet input and that feels much more robust to me (that is, the Labwc implementation, I never looked that detailed at Sway and can't comment on how well it works there). |
Note that it is completely broken in mpv, at least for osc.lua. Sway reset pointer position to "real" mouse pos when all fingers leave the touch screen. By the time osc.lua processes the touch, the pointer is in another place. Making all buttons non- And there is no good way to "fix" or workaround that. Because we have no idea if the move was real or it was emulated switch to mouse. So proper native touch support might be the only way forward. |
Download the artifacts for this pull request: Windows |
We already have native touch support, this is about tablet support. And sway translating tablet events to pointer events works perfectly in mpv. I can't say for touch events as I don't have a touch device, and would need to rip out touch support from mpv to even test it. |
Doesn't work on my end. |
What doesn't work? Touch or tablet? If touch doesn't work that's a mpv bug, or a bug with sway/wlroots sending us touch events (not one with translating touch to pointer events). edit: I checked and it's a sway bug with touch input, works on river. |
That cannot work. Let's say an application has no tablet support and uses libdecor to draw window decorations, which (let's say) also doesn't support tablets. The user can now drag the window by its decorations in sway because sway sends emulated pointer events. But then the application adds support for tablet events and now the user can no longer interact with the window decorations because sway no longer sends emulated events and libdecor still doesn't support tablet events. |
f331ef9
to
b3db60b
Compare
I think this is pretty much ready from my side, moving the window by dragging the window with the stylus works now and with that I think the stylus support is solid. That said, I think I got the wiring correctly, but a keen eye is very welcome, especially for shutting things down. Let me know what you think and if it's worth it. @mahkoh I contributed to the tablet support for labwc, which also uses mouse emulation for clients that do not support the tablet protocol. If you have a case with a reproduction scenario where it doesn't or shouldn't work, could you open an issue there since I would be curious to play with it. |
What I described above should be easy enough to reproduce in any application that uses both libdecor and supports tablet input. You might have to enable CSD in your compositor for libdecor to do anything. |
b3db60b
to
0661c5e
Compare
0f9c657
to
efdd136
Compare
53ceec3
to
051710c
Compare
CI for the latest pipeline on master fails with the same errors like the latest pipeline for this PR, so I don’t think this is on me. |
Flaky windows CI is new mpv contributor hazing ritual don't worry |
I don't understand, why is this Windows related? EDIT: Build with GCC 15 is fixed in #16293 |
ec3fd89
to
b124133
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late here but I finally took a look.
8a80379
to
66c6d04
Compare
The tablet protocol is supported in the current winimum wayland-protocols version, so we can always build this. Note that this is still the unstable version, once the minimum required wayland-protocol version is 1.35, the stable version of protocol can be included.
Tablets require their own tablet manager and tablet seats since multiple tablets/pens can be connected to a single seat. So this is unfortunately a lot of wiring.
This ensures that tablet objects are properly destroyed on removal or shutdown, even if we are not really interested in tablet events.
Setup tablet tool events, we want to use motion, tip and button events later.
This ensures that tablet pad objects are properly destroyed on removal or shutdown, even if we are not (yet) interested in tablet pad events.
This ensures that tablet pad objects that belong to a group, thus rings and strips, are all properly destroyed on removal or shutdown. Note that event listeners for ring a strip are not added since we are not (yet) interested in them and they are not needed for proper destroy.
85a74a7
to
f168c50
Compare
Always update the pointer cursor and all tablet tool cursors together. Also ensure a visible cursor on proximity-in.
Just simple mouse emulation for now.
Upgrade tablet input to first class citizen similar like touch input, but more simple since use case for now is mouse emulation only. Keep state for coordinates and in-proximity. Introduce property for disabling tablet input. Introduce Client-API property `tablet-pos`.
Expose all buttons state to the Client-API for usage in e.g. lua.
f168c50
to
d6dad88
Compare
@Dudemanguy thanks a lot for your review! Is there anything left I need to address? GitHub says that there are still changes requested, but I can’t see any open discussions anymore. I got two of your earlier points only by mail, hence the double check, but may be GitHub is just slightly confused today… |
That's just how github works. I have to give it another review to change it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it turns out that I do have a tablet in my closet that can test this. Seems to work well for me (previously mentioned issues I cannot reproduce) and the code looks good now. This is a pretty big wayland protocol so nice work on going through all of it.
Very cool that this PR has landed. Thanks a lot to all of you for the guidance and patience! |
This is a draft PR about adding support for tablet/stylus input for Wayland.The motivation behind this is that this PR lets me control mpv on a Gnome Wayland session with a tablet/stylus as I'm usually using a tablet as a full mouse replacement. Gnome Desktop unfortunately doesn't offer a mouse fallback for tablet input when a client doesn't support the tablet protocol, so a stylus can't interact with the mpv window there at all.This is still early draft, but functional (tested on Gnome and labwc/wlroots) except for drag&drop like operations. It still needs polishing, some refactoring to avoid code duplication (cursor visibility) and splitting commits and better commit messages, but I wanted to create this PR in this state for general feedback. The main question is: is there interest in tablet/stylus support and does this PR has a chance of getting merged? The tablet protocol is not that simple and a lot of boilerplate code is needed for just a few basic handlers. I hope not, but I would understand if this is too much for an edge case.Lua script demonstrating the client properties:
tablet-input.lua
Thanks for creating and maintaining mpv and looking forward to some general early feedback!