From 1cadba072c16540f35d883b2f02853998407cd3e Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 16 Aug 2024 16:25:07 +0200 Subject: [PATCH] X11: remove `CursorMoved` event when gaining focus --- src/changelog/unreleased.md | 1 + src/platform_impl/linux/x11/event_processor.rs | 16 ---------------- src/platform_impl/linux/x11/mod.rs | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 5d797b034d..d7c75431c8 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -131,3 +131,4 @@ changelog entry. ### Fixed - On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name. +- On X11, bringing the window into focus will not emit a `WindowEvent::CursorMoved` anymore. diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 09bb02912c..8418c05d1c 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -1216,7 +1216,6 @@ impl EventProcessor { self.target.update_listen_device_events(true); let window_id = mkwid(window); - let position = PhysicalPosition::new(xev.event_x, xev.event_y); if let Some(window) = self.with_window(window, Arc::clone) { window.shared_state_lock().has_focus = true; @@ -1235,21 +1234,6 @@ impl EventProcessor { ); self.update_mods_from_query(window_id, &mut callback); - - // The deviceid for this event is for a keyboard instead of a pointer, - // so we have to do a little extra work. - let pointer_id = self - .devices - .borrow() - .get(&DeviceId(xev.deviceid as xinput::DeviceId)) - .map(|device| device.attachment) - .unwrap_or(2); - - let event = Event::WindowEvent { - window_id, - event: WindowEvent::CursorMoved { device_id: mkdid(pointer_id as _), position }, - }; - callback(&self.target, event); } fn xinput2_unfocused(&mut self, xev: &XIFocusOutEvent, mut callback: F) diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index c2d3041e89..00f259248c 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -1040,9 +1040,6 @@ fn mkfid(w: u32) -> crate::event::FingerId { pub struct Device { _name: String, scroll_axes: Vec<(i32, ScrollAxis)>, - // For master devices, this is the paired device (pointer <-> keyboard). - // For slave devices, this is the master. - attachment: c_int, } #[derive(Debug, Copy, Clone)] @@ -1082,8 +1079,7 @@ impl Device { } } - let mut device = - Device { _name: name.into_owned(), scroll_axes, attachment: info.attachment }; + let mut device = Device { _name: name.into_owned(), scroll_axes }; device.reset_scroll_position(info); device }