diff --git a/src/ei/ei_ifs/ei_device.rs b/src/ei/ei_ifs/ei_device.rs index 9ada5f88..37ff2b45 100644 --- a/src/ei/ei_ifs/ei_device.rs +++ b/src/ei/ei_ifs/ei_device.rs @@ -7,7 +7,7 @@ use { ei_object::{EiObject, EiVersion}, }, fixed::Fixed, - ifs::wl_seat::PX_PER_SCROLL, + ifs::wl_seat::{CursorPositionType, PX_PER_SCROLL}, leaks::Tracker, rect::Rect, scale::Scale, @@ -22,6 +22,7 @@ use { }, }, }, + CursorPositionType::Motion, linearize::LinearizeExt, std::{cell::Cell, rc::Rc}, thiserror::Error, @@ -227,7 +228,7 @@ impl EiDeviceRequestHandler for EiDevice { if let Some((x, y)) = self.absolute_motion.take() { let x = Fixed::from_f32(x); let y = Fixed::from_f32(y); - seat.motion_event_abs(time, x, y); + seat.motion_event_abs(time, x, y, Motion); } { let mut need_frame = false; diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index c4d50f0e..326d34a2 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -108,6 +108,7 @@ use { }, wire_ei::EiSeatId, }, + CursorPositionType::Warp, ahash::AHashMap, jay_config::{ input::FallbackOutputMode as ConfigFallbackOutputMode, @@ -2012,7 +2013,7 @@ pub async fn handle_position_hint_requests(state: Rc) { req.new_pos.0 + (current_pos.0 - req.old_pos.0), req.new_pos.1 + (current_pos.1 - req.old_pos.1), ); - req.seat.motion_event_abs(state.now_usec(), x, y); + req.seat.motion_event_abs(state.now_usec(), x, y, Warp); } } @@ -2033,7 +2034,13 @@ pub async fn handle_warp_mouse_to_focus(state: Rc) { continue; } let (x, y) = (Fixed::from_int(x), Fixed::from_int(y)); - seat.motion_event_abs(state.now_usec(), x, y); + seat.motion_event_abs(state.now_usec(), x, y, Warp); } } } + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum CursorPositionType { + Motion, + Warp, +} diff --git a/src/ifs/wl_seat/event_handling.rs b/src/ifs/wl_seat/event_handling.rs index ef3448d3..1b416394 100644 --- a/src/ifs/wl_seat/event_handling.rs +++ b/src/ifs/wl_seat/event_handling.rs @@ -18,7 +18,8 @@ use { }, }, wl_seat::{ - CHANGE_CURSOR_MOVED, CHANGE_TREE, Dnd, MarkMode, SeatId, WlSeat, WlSeatGlobal, + CHANGE_CURSOR_MOVED, CHANGE_TREE, CursorPositionType, Dnd, MarkMode, SeatId, + WlSeat, WlSeatGlobal, tablet::{TabletPad, TabletPadId, TabletTool, TabletToolId}, text_input::TextDisconnectReason, wl_keyboard::WlKeyboard, @@ -49,6 +50,7 @@ use { }, wire::WlDataOfferId, }, + CursorPositionType::Motion, isnt::std_1::primitive::IsntSliceExt, jay_config::{ input::SwitchEvent, @@ -595,10 +597,16 @@ impl WlSeatGlobal { let pos = output.global.pos.get(); x += Fixed::from_int(pos.x1()); y += Fixed::from_int(pos.y1()); - self.motion_event_abs(time_usec, x, y); + self.motion_event_abs(time_usec, x, y, Motion); } - pub fn motion_event_abs(self: &Rc, time_usec: u64, x: Fixed, y: Fixed) { + pub fn motion_event_abs( + self: &Rc, + time_usec: u64, + x: Fixed, + y: Fixed, + cursor_position_type: CursorPositionType, + ) { self.for_each_ei_seat(|ei_seat| { ei_seat.handle_motion_abs(time_usec, x, y); }); @@ -611,7 +619,7 @@ impl WlSeatGlobal { self.state.for_each_seat_tester(|t| { t.send_pointer_abs(self.id, time_usec, x, y); }); - self.cursor_moved(time_usec); + self.apply_cursor_position(time_usec, cursor_position_type); } pub fn motion_event( @@ -666,7 +674,7 @@ impl WlSeatGlobal { ); }); self.set_pointer_cursor_position(x, y); - self.cursor_moved(time_usec); + self.apply_cursor_position(time_usec, Motion); } pub fn motion_absolute_event( @@ -678,7 +686,7 @@ impl WlSeatGlobal { ) { let x = Fixed::from_f32(rect.x1() as f32 + x_normed * rect.width() as f32); let y = Fixed::from_f32(rect.y1() as f32 + y_normed * rect.height() as f32); - self.motion_event_abs(time_usec, x, y); + self.motion_event_abs(time_usec, x, y, Motion); } pub fn button_event(self: &Rc, time_usec: u64, button: u32, state: ButtonState) { @@ -1283,9 +1291,15 @@ impl WlSeatGlobal { }); } - fn cursor_moved(self: &Rc, time_usec: u64) { + fn apply_cursor_position( + self: &Rc, + time_usec: u64, + cursor_position_type: CursorPositionType, + ) { self.pos_time_usec.set(time_usec); - self.changes.or_assign(CHANGE_CURSOR_MOVED); + if cursor_position_type == Motion { + self.changes.or_assign(CHANGE_CURSOR_MOVED); + } self.apply_changes(); }