forge
Explore
Log in

Don't you dare go Hollow

Don't activate window when pressing the Mod+MMB view gesture

Browse files at this commit

fe660a253b445163ff243d7eab842d40937a6bd1Ivan MolodetskikhParent: ad49e58
Avoid unnecessary movement.
src/input/mod.rsmodified+31 -22
@@ -2024,6 +2024,37 @@ impl State {
2024 self.niri.pointer_hidden = false;2024 self.niri.pointer_hidden = false;
2025 self.niri.tablet_cursor_location = None;2025 self.niri.tablet_cursor_location = None;
2026 2026
2027+ if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {
2028+ let mod_down = match self.backend.mod_key() {
2029+ CompositorMod::Super => mods.logo,
2030+ CompositorMod::Alt => mods.alt,
2031+ };
2032+ if mod_down {
2033+ if let Some(output) = self.niri.output_under_cursor() {
2034+ self.niri.layout.activate_output(&output);
2035+
2036+ let location = pointer.current_location();
2037+ let start_data = PointerGrabStartData {
2038+ focus: None,
2039+ button: button_code,
2040+ location,
2041+ };
2042+ let grab = SpatialMovementGrab::new(start_data, output);
2043+ pointer.set_grab(self, grab, serial, Focus::Clear);
2044+ self.niri
2045+ .cursor_manager
2046+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll));
2047+
2048+ // FIXME: granular.
2049+ self.niri.queue_redraw_all();
2050+
2051+ // Don't activate the window under the cursor to avoid unnecessary
2052+ // scrolling when e.g. Mod+MMB clicking on a partially off-screen window.
2053+ return;
2054+ }
2055+ }
2056+ }
2057+
2027 if let Some(mapped) = self.niri.window_under_cursor() {2058 if let Some(mapped) = self.niri.window_under_cursor() {
2028 let window = mapped.window.clone();2059 let window = mapped.window.clone();
2029 2060
@@ -2142,28 +2173,6 @@ impl State {
2142 // FIXME: granular.2173 // FIXME: granular.
2143 self.niri.queue_redraw_all();2174 self.niri.queue_redraw_all();
2144 }2175 }
2145-
2146- if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {
2147- let mod_down = match self.backend.mod_key() {
2148- CompositorMod::Super => mods.logo,
2149- CompositorMod::Alt => mods.alt,
2150- };
2151- if mod_down {
2152- if let Some(output) = self.niri.output_under_cursor() {
2153- let location = pointer.current_location();
2154- let start_data = PointerGrabStartData {
2155- focus: None,
2156- button: button_code,
2157- location,
2158- };
2159- let grab = SpatialMovementGrab::new(start_data, output);
2160- pointer.set_grab(self, grab, serial, Focus::Clear);
2161- self.niri
2162- .cursor_manager
2163- .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll));
2164- }
2165- }
2166- }
2167 };2176 };
2168 2177
2169 self.update_pointer_contents();2178 self.update_pointer_contents();