-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add pointer location hint #1551
add pointer location hint #1551
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.
Sounds like a good idea in general.
62cd8a9
to
111f676
Compare
note: anvil build failing the CI lol. i didn't test with anvil, only niri. i'll implement it, just taking a while 'cause dealing with repos that have no |
honestly i couldn't get anvil working properly. i got it to start, and got a terminal within, but my niri wayland backend (to test the cursor constraints) doesn't seem to show up at all. However, the code is fairly simple so i've implemented what i think should be necessary. |
I'm fairly sure that Blender uses the pointer constraints location hint whenever you do a middle mouse or other drag. |
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.
Seems good to me.
@PolyMeilex Any additional remarks?
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 👍
Sorry for chiming in late, but what happens if the window is partially off-screen, and the location hint ends up off-screen? I guess it should be clipped to output bounds (this is compositor-specific, e.g. in niri you'd clip to the current output only, whereas in anvil you'd clip to all outputs), then if the pointer position ended up different from the location hint, emit the motion event? Alternatively, if the location hint is off-screen just don't follow it? Not sure what's the best approach here. |
|
I noticed that at the moment, there seems to be absolutely no way to utilize the value of zwp_locked_pointer_v1::set_cursor_position_hint, not least because there is no good way to be notified of when its state changes, but Smithay's pointer handling seems to have no way to actually inform it about a cursor position hint.
This PR fixes that, by adding a method to
PointerConstraintsHandler
to notify the downstream compositor, and a method toPointerHandle
to update the location field. Because it keeps track of the old focus as a separate field, i reckon this isn't going to cause any issues, and if it does cause issues, it's entirely opt-in.PointerConstrainsHandler::cursor_position_hint
receives surface-local coordinates.PointerHandle::set_location_hint
expects global coordinates. It is up to the compositor to correctly map the surface-local coordinates to global coordinates.I've already implemented this in niri. That pull request contains a video comparison of a real client (which also happens to be niri) and a concrete benefit to having the pointer location hints in Smithay.
Some care had to be taken when calling
PointerConstraintsHandler::cursor_position_hint
to make sure we don't deadlock. I may or may not have caused deadlocks several times when implementing this, where the only remedy was a hard reset of my hardware. Oops.