aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/x11/ffi.rs34
-rw-r--r--src/x11/mod.rs11
2 files changed, 42 insertions, 3 deletions
diff --git a/src/x11/ffi.rs b/src/x11/ffi.rs
index 51e70b4..dd7fa7b 100644
--- a/src/x11/ffi.rs
+++ b/src/x11/ffi.rs
@@ -43,6 +43,33 @@ pub static CWDontPropagate: libc::c_ulong = (1<<12);
pub static CWColormap: libc::c_ulong = (1<<13);
pub static CWCursor: libc::c_ulong = (1<<14);
+pub static NoEventMask: libc::c_long = 0;
+pub static KeyPressMask: libc::c_long = (1<<0);
+pub static KeyReleaseMask: libc::c_long = (1<<1);
+pub static ButtonPressMask: libc::c_long = (1<<2);
+pub static ButtonReleaseMask: libc::c_long = (1<<3);
+pub static EnterWindowMask: libc::c_long = (1<<4);
+pub static LeaveWindowMask: libc::c_long = (1<<5);
+pub static PointerMotionMask: libc::c_long = (1<<6);
+pub static PointerMotionHintMask: libc::c_long = (1<<7);
+pub static Button1MotionMask: libc::c_long = (1<<8);
+pub static Button2MotionMask: libc::c_long = (1<<9);
+pub static Button3MotionMask: libc::c_long = (1<<10);
+pub static Button4MotionMask: libc::c_long = (1<<11);
+pub static Button5MotionMask: libc::c_long = (1<<12);
+pub static ButtonMotionMask: libc::c_long = (1<<13);
+pub static KeymapStateMask: libc::c_long = (1<<14);
+pub static ExposureMask: libc::c_long = (1<<15);
+pub static VisibilityChangeMask: libc::c_long = (1<<16);
+pub static StructureNotifyMask: libc::c_long = (1<<17);
+pub static ResizeRedirectMask: libc::c_long = (1<<18);
+pub static SubstructureNotifyMask: libc::c_long = (1<<19);
+pub static SubstructureRedirectMask: libc::c_long = (1<<20);
+pub static FocusChangeMask: libc::c_long = (1<<21);
+pub static PropertyChangeMask: libc::c_long = (1<<22);
+pub static ColormapChangeMask: libc::c_long = (1<<23);
+pub static OwnerGrabButtonMask: libc::c_long = (1<<24);
+
pub static GLX_USE_GL: libc::c_int = 1;
pub static GLX_BUFFER_SIZE: libc::c_int = 2;
pub static GLX_LEVEL: libc::c_int = 3;
@@ -160,6 +187,12 @@ pub struct XSetWindowAttributes {
pub cursor: Cursor,
}
+#[repr(C)]
+pub struct XEvent {
+ type_: libc::c_int,
+ pad: [libc::c_long, ..24],
+}
+
#[link(name = "GL")]
#[link(name = "X11")]
extern "C" {
@@ -175,6 +208,7 @@ extern "C" {
pub fn XDefaultScreen(display: *mut Display) -> libc::c_int;
pub fn XFlush(display: *mut Display);
pub fn XMapWindow(display: *mut Display, w: Window);
+ pub fn XNextEvent(display: *mut Display, event_return: *mut XEvent);
pub fn XOpenDisplay(display_name: *const libc::c_char) -> *mut Display;
pub fn XStoreName(display: *mut Display, w: Window, window_name: *const libc::c_char);
diff --git a/src/x11/mod.rs b/src/x11/mod.rs
index 8849441..e6297f1 100644
--- a/src/x11/mod.rs
+++ b/src/x11/mod.rs
@@ -57,7 +57,7 @@ impl Window {
let mut set_win_attr = {
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
swa.colormap = cmap;
- //swa.event_mask = ExposureMask | KeyPressMask;
+ swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask | ffi::KeyPressMask;
swa
};
@@ -65,7 +65,7 @@ impl Window {
let window = unsafe {
let win = ffi::XCreateWindow(display, root, 10, 10, 800, 600,
0, (*visual_infos).depth, ffi::InputOutput, (*visual_infos).visual,
- ffi::CWColormap/* | ffi::CWEventMask*/, &mut set_win_attr);
+ ffi::CWColormap | ffi::CWEventMask, &mut set_win_attr);
win
};
@@ -120,7 +120,12 @@ impl Window {
}
pub fn wait_events(&self) -> Vec<Event> {
- // TODO:
+ use std::mem;
+
+ let mut xev = unsafe { mem::uninitialized() };
+ unsafe { ffi::XNextEvent(self.display, &mut xev) };
+
+
Vec::new()
}