Skip to content

Commit

Permalink
move mouse move-scroll exclusivity to hid module
Browse files Browse the repository at this point in the history
  • Loading branch information
galister committed Sep 10, 2024
1 parent b0a33a1 commit 13d9284
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/backend/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,13 @@ where
);
}

let scroll_threshold = 0.1;
let mut haptics: Option<Haptics> = None;

// Pass mouse motion events only if not scrolling
// (allows scrolling on all Chromium-based applications)
if app.input_state.pointers[idx].now.scroll.abs() <= scroll_threshold {
haptics = hovered.backend.on_hover(app, &hit);
}
let haptics = hovered.backend.on_hover(app, &hit);

pointer = &mut app.input_state.pointers[idx];

if pointer.now.scroll.abs() > scroll_threshold {
if pointer.now.scroll.abs() > 0.1 {
let scroll = pointer.now.scroll;
if app.input_state.pointers[1 - idx]
.interaction
Expand Down
5 changes: 4 additions & 1 deletion src/hid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl HidProvider for UInputProvider {
self.desktop_origin = origin;
}
fn mouse_move(&mut self, pos: Vec2) {
if self.current_action.pos.is_none() {
if self.current_action.pos.is_none() && self.current_action.scroll.is_none() {
self.current_action.pos = Some(pos);
}
self.current_action.last_requested_pos = Some(pos);
Expand All @@ -256,6 +256,9 @@ impl HidProvider for UInputProvider {
fn wheel(&mut self, delta: i32) {
if self.current_action.scroll.is_none() {
self.current_action.scroll = Some(delta);
// Pass mouse motion events only if not scrolling
// (allows scrolling on all Chromium-based applications)
self.current_action.pos = None;
}
}
fn commit(&mut self) {
Expand Down

0 comments on commit 13d9284

Please sign in to comment.