Skip to content

Commit

Permalink
X11: remove CursorMoved event when gaining focus
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Aug 23, 2024
1 parent 7fbc211 commit 1cadba0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 0 additions & 16 deletions src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<F>(&mut self, xev: &XIFocusOutEvent, mut callback: F)
Expand Down
6 changes: 1 addition & 5 deletions src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1cadba0

Please sign in to comment.