From 1216cd0b67ca3c915b510b78e593de8c44044318 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 12 Apr 2024 09:48:29 -0700 Subject: [PATCH] Add `unset` method to input grab traits Fixes https://github.com/pop-os/cosmic-comp/issues/403. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/shell/grabs/menu/mod.rs | 2 ++ src/shell/grabs/mod.rs | 14 ++++++++++++++ src/shell/grabs/moving.rs | 4 ++++ src/shell/layout/floating/grabs/resize.rs | 12 ++++++++---- src/shell/layout/tiling/grabs/resize.rs | 4 ++++ src/shell/layout/tiling/grabs/swap.rs | 2 ++ 8 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72659874..b8fd56e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4506,7 +4506,7 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/smithay//smithay?rev=ba0121a#ba0121aaed065c30ee4c42834126cce481cb0e57" +source = "git+https://github.com/smithay//smithay?rev=033df94#033df9407104df60751438131687bac25d20e506" dependencies = [ "appendlist", "ash", diff --git a/Cargo.toml b/Cargo.toml index 2d2119e2..bf9e423d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,4 +118,4 @@ inherits = "release" lto = "fat" [patch."https://github.com/Smithay/smithay.git"] -smithay = {git = "https://github.com/smithay//smithay", rev = "ba0121a"} +smithay = {git = "https://github.com/smithay//smithay", rev = "033df94"} diff --git a/src/shell/grabs/menu/mod.rs b/src/shell/grabs/menu/mod.rs index 86f46f67..7426830a 100644 --- a/src/shell/grabs/menu/mod.rs +++ b/src/shell/grabs/menu/mod.rs @@ -634,6 +634,8 @@ impl PointerGrab for MenuGrab { fn start_data(&self) -> &PointerGrabStartData { &self.start_data } + + fn unset(&mut self, _data: &mut State) {} } impl MenuGrab { diff --git a/src/shell/grabs/mod.rs b/src/shell/grabs/mod.rs index 8306ef54..0181deb1 100644 --- a/src/shell/grabs/mod.rs +++ b/src/shell/grabs/mod.rs @@ -313,6 +313,13 @@ impl PointerGrab for ResizeGrab { ResizeGrab::Tiling(grab) => PointerGrab::start_data(grab), } } + + fn unset(&mut self, data: &mut State) { + match self { + ResizeGrab::Floating(grab) => PointerGrab::unset(grab, data), + ResizeGrab::Tiling(grab) => PointerGrab::unset(grab, data), + } + } } impl TouchGrab for ResizeGrab { @@ -377,4 +384,11 @@ impl TouchGrab for ResizeGrab { ResizeGrab::Tiling(grab) => TouchGrab::start_data(grab), } } + + fn unset(&mut self, data: &mut State) { + match self { + ResizeGrab::Floating(grab) => TouchGrab::unset(grab, data), + ResizeGrab::Tiling(grab) => TouchGrab::unset(grab, data), + } + } } diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index 51c21818..220b12fc 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -575,6 +575,8 @@ impl PointerGrab for MoveGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) {} } impl TouchGrab for MoveGrab { @@ -632,6 +634,8 @@ impl TouchGrab for MoveGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) {} } impl MoveGrab { diff --git a/src/shell/layout/floating/grabs/resize.rs b/src/shell/layout/floating/grabs/resize.rs index 0354baf3..77c9cd79 100644 --- a/src/shell/layout/floating/grabs/resize.rs +++ b/src/shell/layout/floating/grabs/resize.rs @@ -162,13 +162,11 @@ impl PointerGrab for ResizeSurfaceGrab { match self.release { ReleaseMode::NoMouseButtons => { if handle.current_pressed().is_empty() { - self.ungrab(); handle.unset_grab(data, event.serial, event.time, true); } } ReleaseMode::Click => { if event.state == ButtonState::Pressed { - self.ungrab(); handle.unset_grab(data, event.serial, event.time, true); } } @@ -266,6 +264,10 @@ impl PointerGrab for ResizeSurfaceGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) { + self.ungrab(); + } } impl TouchGrab for ResizeSurfaceGrab { @@ -288,7 +290,6 @@ impl TouchGrab for ResizeSurfaceGrab { seq: Serial, ) { if event.slot == >::start_data(self).slot { - self.ungrab(); handle.unset_grab(data); } @@ -317,7 +318,6 @@ impl TouchGrab for ResizeSurfaceGrab { } fn cancel(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _seq: Serial) { - self.ungrab(); handle.unset_grab(data); } @@ -327,6 +327,10 @@ impl TouchGrab for ResizeSurfaceGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) { + self.ungrab(); + } } pub struct ResizeGrabMarker(AtomicBool); diff --git a/src/shell/layout/tiling/grabs/resize.rs b/src/shell/layout/tiling/grabs/resize.rs index 0502962d..a9eaf1d4 100644 --- a/src/shell/layout/tiling/grabs/resize.rs +++ b/src/shell/layout/tiling/grabs/resize.rs @@ -462,6 +462,8 @@ impl PointerGrab for ResizeForkGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) {} } impl TouchGrab for ResizeForkGrab { @@ -521,4 +523,6 @@ impl TouchGrab for ResizeForkGrab { _ => unreachable!(), } } + + fn unset(&mut self, _data: &mut State) {} } diff --git a/src/shell/layout/tiling/grabs/swap.rs b/src/shell/layout/tiling/grabs/swap.rs index 95f131f0..b3f59407 100644 --- a/src/shell/layout/tiling/grabs/swap.rs +++ b/src/shell/layout/tiling/grabs/swap.rs @@ -99,4 +99,6 @@ impl KeyboardGrab for SwapWindowGrab { fn start_data(&self) -> &KeyboardGrabStartData { &KeyboardGrabStartData { focus: None } } + + fn unset(&mut self, _state: &mut State) {} }