-
Notifications
You must be signed in to change notification settings - Fork 175
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
Pointer constraints protocol #872
Conversation
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.
Looks good for a first draft!
9616c04
to
d99e3ef
Compare
d99e3ef
to
a5efd34
Compare
f6c0263
to
b7c081b
Compare
eb9f8fc
to
265a296
Compare
54e03ea
to
4504e1e
Compare
I've implemented pointer confinement in Anvil; confining to just the window boundary, ignoring the region. Handling this correctly seems complicated. The logic in wlroots is slightly complicated (https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/util/region.c#L190-256), but more significantly seems to depend on the I think this is good enough to merge now, at least given the part that's incomplete is the Anvil implementation. |
4504e1e
to
2d23ead
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #872 +/- ##
==========================================
- Coverage 22.88% 22.76% -0.13%
==========================================
Files 143 144 +1
Lines 23050 23365 +315
==========================================
+ Hits 5275 5319 +44
- Misses 17775 18046 +271
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Depends on Smithay/smithay#872. For some reason, pointer confinment isn't working correctly here at the moment, even though the code matches Anvil... May need solution to Smithay/smithay#1126 for behavior to be correct.
I am slightly confused, because I am pretty sure we have to deal with this for input_regions of surfaces already. So I am not sure, why the same code wouldn't work here? |
Yeah, I was thinking of the clamping part. Just ignoring movement if the new position would be outside the region might work alright. Technically less pixel-perfect. Also with a really weird region that could jump over a tiny area that isn't in the region to another that is, but that's even less likely to be an issue (I'm not sure exactly how other implementations handle these cases).
|
Oh absolutely and yes the issues above can in theory happen. But I think implementing it this way in anvil is better, than not implementing it at all. Especially because compositors are likely going to copy&paste anvil's implementation. 😅 |
Similar to implementations for `Seat`. `PartialEq` was already implemented.
2d23ead
to
b634d6a
Compare
A pointer constraint is unique per surface and pointer. Creating a constraint when one already exists is a protocol error. Technically the spec says it should be a protocol error to add a constraint for the same "seat", but as things are implemented in Smithay it's easier to tie it to the `PointerHandle`. This provides `activated`/`deactivated` helpers, which is somewhat similar to the API wlroots provides. Adds implementation in anvil. This implementation doesn't currently handle regions, which requires a non-trivial algorithm / data structure. But that should be good enough for an initial implementation in Anvil.
b634d6a
to
d978a2b
Compare
This isn't doing any fancy pointer warping, but setting a region seems to work now, with Smithay/client-toolkit#407. Just testing if the pointer ends up outside the region and dropping the event, instead of clamping, seems to be working alright. |
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.
LGTM
The protocol implementation should generally work, though there's some more work still needed to get the implementation in Anvil fully functional. And testing, docs, etc.