mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
Implement CursorPositionChanged event for X11
This commit is contained in:
@@ -18,6 +18,7 @@ pub type GLXPixmap = XID;
|
|||||||
pub type GLXWindow = XID;
|
pub type GLXWindow = XID;
|
||||||
pub type Pixmap = XID;
|
pub type Pixmap = XID;
|
||||||
pub type Status = libc::c_int; // TODO: not sure
|
pub type Status = libc::c_int; // TODO: not sure
|
||||||
|
pub type Time = libc::c_ulong;
|
||||||
pub type Visual = (); // TODO: not sure
|
pub type Visual = (); // TODO: not sure
|
||||||
pub type VisualID = libc::c_ulong; // TODO: not sure
|
pub type VisualID = libc::c_ulong; // TODO: not sure
|
||||||
pub type Window = XID;
|
pub type Window = XID;
|
||||||
@@ -241,7 +242,7 @@ pub struct XClientMessageEvent {
|
|||||||
pub l: [libc::c_long, ..5],
|
pub l: [libc::c_long, ..5],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[reprc(C)]
|
#[repr(C)]
|
||||||
pub struct XResizeRequestEvent {
|
pub struct XResizeRequestEvent {
|
||||||
pub type_: libc::c_int,
|
pub type_: libc::c_int,
|
||||||
pub serial: libc::c_ulong,
|
pub serial: libc::c_ulong,
|
||||||
@@ -252,6 +253,25 @@ pub struct XResizeRequestEvent {
|
|||||||
pub height: libc::c_int,
|
pub height: libc::c_int,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct XMotionEvent {
|
||||||
|
pub type_: libc::c_int,
|
||||||
|
pub serial: libc::c_ulong,
|
||||||
|
pub send_event: Bool,
|
||||||
|
pub display: *mut Display,
|
||||||
|
pub window: Window,
|
||||||
|
pub root: Window,
|
||||||
|
pub subwindow: Window,
|
||||||
|
pub time: Time,
|
||||||
|
pub x: libc::c_int,
|
||||||
|
pub y: libc::c_int,
|
||||||
|
pub x_root: libc::c_int,
|
||||||
|
pub y_root: libc::c_int,
|
||||||
|
pub state: libc::c_uint,
|
||||||
|
pub is_hint: libc::c_char,
|
||||||
|
pub same_screen: Bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[link(name = "GL")]
|
#[link(name = "GL")]
|
||||||
#[link(name = "X11")]
|
#[link(name = "X11")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ impl Window {
|
|||||||
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
|
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
|
||||||
swa.colormap = cmap;
|
swa.colormap = cmap;
|
||||||
swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask |
|
swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask |
|
||||||
ffi::VisibilityChangeMask | ffi::KeyPressMask;
|
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask;
|
||||||
swa
|
swa
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,6 +168,12 @@ impl Window {
|
|||||||
events.push(SizeChanged(rs_event.width as uint, rs_event.height as uint));
|
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));
|
||||||
|
},
|
||||||
|
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user