aboutsummaryrefslogtreecommitdiff
path: root/src/input/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-18 18:32:17 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-18 19:06:40 +0300
commitfe660a253b445163ff243d7eab842d40937a6bd1 (patch)
tree6c36d6e1d7a09ce26d1aa0fc931b6070fd21540c /src/input/mod.rs
parentad49e5820a857dea88cfb26ef71d56ffe88ca91d (diff)
downloadniri-fe660a253b445163ff243d7eab842d40937a6bd1.tar.gz
niri-fe660a253b445163ff243d7eab842d40937a6bd1.tar.bz2
niri-fe660a253b445163ff243d7eab842d40937a6bd1.zip
Don't activate window when pressing the Mod+MMB view gesture
Avoid unnecessary movement.
Diffstat (limited to 'src/input/mod.rs')
-rw-r--r--src/input/mod.rs53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs
index d7c9cea4..8f923473 100644
--- a/src/input/mod.rs
+++ b/src/input/mod.rs
@@ -2024,6 +2024,37 @@ impl State {
self.niri.pointer_hidden = false;
self.niri.tablet_cursor_location = None;
+ if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {
+ let mod_down = match self.backend.mod_key() {
+ CompositorMod::Super => mods.logo,
+ CompositorMod::Alt => mods.alt,
+ };
+ if mod_down {
+ if let Some(output) = self.niri.output_under_cursor() {
+ self.niri.layout.activate_output(&output);
+
+ let location = pointer.current_location();
+ let start_data = PointerGrabStartData {
+ focus: None,
+ button: button_code,
+ location,
+ };
+ let grab = SpatialMovementGrab::new(start_data, output);
+ pointer.set_grab(self, grab, serial, Focus::Clear);
+ self.niri
+ .cursor_manager
+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll));
+
+ // FIXME: granular.
+ self.niri.queue_redraw_all();
+
+ // Don't activate the window under the cursor to avoid unnecessary
+ // scrolling when e.g. Mod+MMB clicking on a partially off-screen window.
+ return;
+ }
+ }
+ }
+
if let Some(mapped) = self.niri.window_under_cursor() {
let window = mapped.window.clone();
@@ -2142,28 +2173,6 @@ impl State {
// FIXME: granular.
self.niri.queue_redraw_all();
}
-
- if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {
- let mod_down = match self.backend.mod_key() {
- CompositorMod::Super => mods.logo,
- CompositorMod::Alt => mods.alt,
- };
- if mod_down {
- if let Some(output) = self.niri.output_under_cursor() {
- let location = pointer.current_location();
- let start_data = PointerGrabStartData {
- focus: None,
- button: button_code,
- location,
- };
- let grab = SpatialMovementGrab::new(start_data, output);
- pointer.set_grab(self, grab, serial, Focus::Clear);
- self.niri
- .cursor_manager
- .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll));
- }
- }
- }
};
self.update_pointer_contents();