Implement CursorPositionChanged event for X11

This commit is contained in:
Pierre Krieger 2014-07-28 13:25:28 +02:00
parent 5764b9c243
commit 433c5b956e
2 changed files with 28 additions and 2 deletions

View file

@ -61,7 +61,7 @@ impl Window {
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
swa.colormap = cmap;
swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask |
ffi::VisibilityChangeMask | ffi::KeyPressMask;
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask;
swa
};
@ -168,6 +168,12 @@ impl Window {
events.push(SizeChanged(rs_event.width as uint, rs_event.height as uint));
},
ffi::MotionNotify => {
use CursorPositionChanged;
let event: &ffi::XMotionEvent = unsafe { mem::transmute(&xev) };
events.push(CursorPositionChanged(event.x as uint, event.y as uint));
},
_ => ()
}