Skip to content

Commit

Permalink
Use pointer focus for scroll-factor window rule
Browse files Browse the repository at this point in the history
Instead of window under pointer position, to properly
deal with pointer grabs.
  • Loading branch information
bbb651 committed Jan 21, 2025
1 parent 312246a commit 3434ef2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,8 @@ impl State {
}

fn on_pointer_axis<I: InputBackend>(&mut self, event: I::PointerAxisEvent) {
let pointer = &self.niri.seat.get_pointer().unwrap();

let source = event.source();

// We received an event for the regular pointer, so show it now. This is also needed for
Expand Down Expand Up @@ -2167,14 +2169,16 @@ impl State {
}
}

self.update_pointer_contents();

let scroll_factor = match source {
AxisSource::Wheel => self.niri.config.borrow().input.mouse.scroll_factor,
AxisSource::Finger => self.niri.config.borrow().input.touchpad.scroll_factor,
_ => None,
};
let window_scroll_factor = self
.niri
.window_under_cursor()
let window_scroll_factor = pointer
.current_focus()
.and_then(|focused| self.niri.layout.find_window_and_output(&focused).unzip().0)
.and_then(|window| window.rules().scroll_factor);
let scroll_factor =
scroll_factor.map(|x| x.0).unwrap_or(1.) * window_scroll_factor.unwrap_or(1.);
Expand Down Expand Up @@ -2218,9 +2222,6 @@ impl State {
}
}

self.update_pointer_contents();

let pointer = &self.niri.seat.get_pointer().unwrap();
pointer.axis(self, frame);
pointer.frame(self);
}
Expand Down

0 comments on commit 3434ef2

Please sign in to comment.