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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions anvil/src/shell/grabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<BackendData: Backend> PointerGrab<AnvilState<BackendData>> for MoveSurfaceG
handle.button(data, event);
if handle.current_pressed().is_empty() {
// No more buttons are pressed, release the grab.
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);
}
}

Expand Down Expand Up @@ -254,7 +254,7 @@ impl<BackendData: Backend> PointerGrab<AnvilState<BackendData>> for ResizeSurfac

// It is impossible to get `min_size` and `max_size` of dead toplevel, so we return early.
if !self.window.alive() {
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);
return;
}

Expand Down Expand Up @@ -346,7 +346,7 @@ impl<BackendData: Backend> PointerGrab<AnvilState<BackendData>> for ResizeSurfac
handle.button(data, event);
if handle.current_pressed().is_empty() {
// No more buttons are pressed, release the grab.
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);

// If toplevel is dead, we can't resize it, so we return early.
if !self.window.alive() {
Expand Down
2 changes: 1 addition & 1 deletion smallvil/src/grabs/move_grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl PointerGrab<Smallvil> for MoveSurfaceGrab {

if !handle.current_pressed().contains(&BTN_LEFT) {
// No more buttons are pressed, release the grab.
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion smallvil/src/grabs/resize_grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl PointerGrab<Smallvil> for ResizeSurfaceGrab {

if !handle.current_pressed().contains(&BTN_LEFT) {
// No more buttons are pressed, release the grab.
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);

let xdg = self.window.toplevel();
xdg.with_pending_state(|state| {
Expand Down
6 changes: 3 additions & 3 deletions src/desktop/wayland/popup/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ where
event: &MotionEvent,
) {
if self.popup_grab.has_ended() {
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, true);
self.popup_grab.unset_keyboard_grab(data, event.serial);
return;
}
Expand Down Expand Up @@ -591,7 +591,7 @@ where
let state = event.state;

if self.popup_grab.has_ended() {
handle.unset_grab(data, serial, time);
handle.unset_grab(data, serial, time, true);
handle.button(data, event);
self.popup_grab.unset_keyboard_grab(data, serial);
return;
Expand All @@ -610,7 +610,7 @@ where
.unwrap_or(false)
{
let _ = self.popup_grab.ungrab(PopupUngrabStrategy::All);
handle.unset_grab(data, serial, time);
handle.unset_grab(data, serial, time, true);
handle.button(data, event);
self.popup_grab.unset_keyboard_grab(data, serial);
return;
Expand Down
18 changes: 9 additions & 9 deletions src/input/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,24 @@ impl<D: SeatHandler + 'static> KbdInternal<D> {

fn with_grab<F>(&mut self, seat: &Seat<D>, f: F)
where
F: FnOnce(KeyboardInnerHandle<'_, D>, &mut dyn KeyboardGrab<D>),
F: FnOnce(&mut KeyboardInnerHandle<'_, D>, &mut dyn KeyboardGrab<D>),
{
let mut grab = ::std::mem::replace(&mut self.grab, GrabStatus::Borrowed);
let mut grab = std::mem::replace(&mut self.grab, GrabStatus::Borrowed);
match grab {
GrabStatus::Borrowed => panic!("Accessed a keyboard grab from within a keyboard grab access."),
GrabStatus::Active(_, ref mut handler) => {
// If this grab is associated with a surface that is no longer alive, discard it
if let Some(ref surface) = handler.start_data().focus {
if !surface.alive() {
self.grab = GrabStatus::None;
f(KeyboardInnerHandle { inner: self, seat }, &mut DefaultGrab);
f(&mut KeyboardInnerHandle { inner: self, seat }, &mut DefaultGrab);
return;
}
}
f(KeyboardInnerHandle { inner: self, seat }, &mut **handler);
f(&mut KeyboardInnerHandle { inner: self, seat }, &mut **handler);
}
GrabStatus::None => {
f(KeyboardInnerHandle { inner: self, seat }, &mut DefaultGrab);
f(&mut KeyboardInnerHandle { inner: self, seat }, &mut DefaultGrab);
}
}

Expand Down Expand Up @@ -533,8 +533,8 @@ impl<D: SeatHandler + 'static> KeyboardHandle<D> {
// forward to client if no keybinding is triggered
let seat = self.get_seat(data);
let modifiers = mods_changed.then_some(guard.mods_state);
guard.with_grab(&seat, move |mut handle, grab| {
grab.input(data, &mut handle, keycode, state, modifiers, serial, time);
guard.with_grab(&seat, |handle, grab| {
grab.input(data, handle, keycode, state, modifiers, serial, time);
});
if guard.focus.is_some() {
trace!("Input forwarded to client");
Expand All @@ -556,8 +556,8 @@ impl<D: SeatHandler + 'static> KeyboardHandle<D> {
let mut guard = self.arc.internal.lock().unwrap();
guard.pending_focus = focus.clone();
let seat = self.get_seat(data);
guard.with_grab(&seat, move |mut handle, grab| {
grab.set_focus(data, &mut handle, focus, serial);
guard.with_grab(&seat, |handle, grab| {
grab.set_focus(data, handle, focus, serial);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/input/pointer/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl<D: SeatHandler + 'static> PointerGrab<D> for ClickGrab<D> {
handle.button(data, event);
if handle.current_pressed().is_empty() {
// no more buttons are pressed, release the grab
handle.unset_grab(data, event.serial, event.time);
handle.unset_grab(data, event.serial, event.time, false);
}
}

Expand Down
Loading
Loading