Skip to content
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

Add restore_focus argument to PointerInnerHandle::unset_grab #1173

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Oct 18, 2023

Used in ClickGrab to prevent motion events from occurring with every button event. Otherwise, behavior should be unchanged. This matches the argument taken by KeyboardInnerHandle::unset_grab.

This seems like the simplest solution. It would also be possible to add a method to the PointerGrab trait indicating if focus should be restored, but that's complicated since unset_grab can't access the
grab when it's Borrowed, so it would have to add a bool to GrabStatus::Borrowed, etc.

This still doesn't send a frame, but since this takes a serial and a time, it probably will be sent along with other pointer events, and hopefully part of a frame. The Wayland spec isn't all that specific
about when things can/should be part of a frame...

Calling motion is also incorrect with pointer constraints, but grabs other than ClickGrab generally shouldn't exist while a constraint is active. It would be good to enforce that some way.

The first commit here is a change I had as part of an attempt at a different approach, which turned out more complicated; but this part seemed a bit neater.

Fixes #1148.

Somewhat simpler since each callback simply passes it to a function
taking `&mut`.
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2023

Codecov Report

Attention: 67 lines in your changes are missing coverage. Please review.

Comparison is base (028db93) 22.34% compared to head (b34ccf0) 22.34%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1173      +/-   ##
==========================================
- Coverage   22.34%   22.34%   -0.01%     
==========================================
  Files         151      151              
  Lines       23418    23421       +3     
==========================================
  Hits         5233     5233              
- Misses      18185    18188       +3     
Flag Coverage Δ
wlcs-buffer 19.41% <0.00%> (-0.01%) ⬇️
wlcs-core 19.08% <0.00%> (-0.01%) ⬇️
wlcs-output 7.87% <0.00%> (-0.01%) ⬇️
wlcs-pointer-input 21.15% <11.84%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/input/pointer/grab.rs 9.29% <0.00%> (ø)
src/wayland/selection/data_device/dnd_grab.rs 0.00% <0.00%> (ø)
...c/wayland/selection/data_device/server_dnd_grab.rs 0.00% <0.00%> (ø)
anvil/src/shell/grabs.rs 0.00% <0.00%> (ø)
src/desktop/wayland/popup/grab.rs 0.00% <0.00%> (ø)
src/input/keyboard/mod.rs 12.69% <0.00%> (ø)
src/input/pointer/mod.rs 34.11% <15.51%> (-0.25%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Used in `ClickGrab` to prevent `motion` events from occurring with every
`button` event. Otherwise, behavior should be unchanged. This matches
the argument taken by `KeyboardInnerHandle::unset_grab`.

This seems like the simplest solution. It would also be possible to add
a method to the `PointerGrab` trait indicating if focus should be
restored, but that's complicated since `unset_grab` can't access the
grab when it's `Borrowed`, so it would have to add a bool to
`GrabStatus::Borrowed`, etc.

This still doesn't send a `frame`, but since this takes a serial and a
time, it probably will be sent along with other pointer events, and
hopefully part of a `frame`. The Wayland spec isn't all that specific
about when things can/should be part of a `frame`...

Calling `motion` is also incorrect with pointer constraints, but grabs
other than `ClickGrab` generally shouldn't exist while a constraint is
active. It would be good to enforce that some way.

Fixes Smithay#1148.
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Drakulix Drakulix merged commit 396accd into Smithay:master Oct 19, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Every wl_pointer::button event is followed immediately by a wl_pointer::motion
3 participants