Send mouse position after focused/cursorenter events (#349)

* Update mouse pos after cursor enter event

* Update mouse position on windows focus

* Send device_id

* Update other device id

* Fix windows import

* Remove deque for vec

* Just send event

* Use correct push_back method

* Push correct event
This commit is contained in:
stuart nelson 2017-11-26 15:43:13 -05:00 committed by Victor Berger
parent fae10c6072
commit 0f14e63b34
3 changed files with 48 additions and 4 deletions

View file

@ -460,8 +460,13 @@ impl EventsLoop {
physical_device.reset_scroll_position(info);
}
}
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: CursorEntered { device_id: mkdid(xev.deviceid) } });
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: CursorEntered { device_id: mkdid(xev.deviceid) } })
let new_cursor_pos = (xev.event_x, xev.event_y);
callback(Event::WindowEvent { window_id: wid, event: CursorMoved {
device_id: mkdid(xev.deviceid),
position: new_cursor_pos
}})
}
ffi::XI_Leave => {
let xev: &ffi::XILeaveEvent = unsafe { &*(xev.data as *const _) };
@ -474,7 +479,13 @@ impl EventsLoop {
let window_data = windows.get_mut(&WindowId(xev.event)).unwrap();
(self.display.xlib.XSetICFocus)(window_data.ic);
}
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(true) })
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(true) });
let new_cursor_pos = (xev.event_x, xev.event_y);
callback(Event::WindowEvent { window_id: wid, event: CursorMoved {
device_id: mkdid(xev.deviceid),
position: new_cursor_pos
}})
}
ffi::XI_FocusOut => {
let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) };