Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-platform-consistent mouse events from X11 #3874

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 },
};
Comment on lines -1248 to -1251
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tracked this down to #348.

While I do think this is a valid use-case, the current implementation is incorrect, because its also emits an event if the cursor is not inside the window.

For this to be solved we need to do it across all platforms and do it correctly.
My proposition would be to emit a CursorEntered when focus is gained if the cursor is inside the window.

On the other hand this might also be addressed by #2648.

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