From 500dcca9b70c9b8968f3dbcfe06c4177ca7fd66a Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 23 Mar 2025 09:00:23 +0300 Subject: input: Suppress release from Pick grab clicks Otherwise, it would trigger something inside the window. --- src/input/pick_color_grab.rs | 3 +++ src/input/pick_window_grab.rs | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/input/pick_color_grab.rs b/src/input/pick_color_grab.rs index 3484b66e..1d79f68f 100644 --- a/src/input/pick_color_grab.rs +++ b/src/input/pick_color_grab.rs @@ -120,6 +120,9 @@ impl PointerGrab for PickColorGrab { return; } + // We're handling this press, don't send the release to the window. + data.niri.suppressed_buttons.insert(event.button); + if let Some(tx) = data.niri.pick_color.take() { let color = Self::pick_color_at_point(handle.current_location(), data); let _ = tx.send_blocking(color); diff --git a/src/input/pick_window_grab.rs b/src/input/pick_window_grab.rs index 9a3b22ae..9c2615b4 100644 --- a/src/input/pick_window_grab.rs +++ b/src/input/pick_window_grab.rs @@ -60,16 +60,22 @@ impl PointerGrab for PickWindowGrab { handle: &mut PointerInnerHandle<'_, State>, event: &ButtonEvent, ) { - if event.state == ButtonState::Pressed { - if let Some(tx) = data.niri.pick_window.take() { - let _ = tx.send_blocking( - data.niri - .window_under(handle.current_location()) - .map(Mapped::id), - ); - } - handle.unset_grab(self, data, event.serial, event.time, true); + if event.state != ButtonState::Pressed { + return; } + + // We're handling this press, don't send the release to the window. + data.niri.suppressed_buttons.insert(event.button); + + if let Some(tx) = data.niri.pick_window.take() { + let _ = tx.send_blocking( + data.niri + .window_under(handle.current_location()) + .map(Mapped::id), + ); + } + + handle.unset_grab(self, data, event.serial, event.time, true); } fn axis( -- cgit