aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authorIvo Wetzel <ivo.wetzel@googlemail.com>2016-03-25 02:54:40 +0100
committerIvo Wetzel <ivo.wetzel@googlemail.com>2016-03-25 02:54:40 +0100
commit7a5e47c446801c40e9048668feb54f3d76dc2442 (patch)
tree83549f606174c40effa4656508920220efd10b45 /src/api/x11
parent7473d99c2f4038a36cb7848e0c08f89b47b219b3 (diff)
parent8ae2df68e19ca71453af5e11de9ca807ef7adcb4 (diff)
downloadglutin-7a5e47c446801c40e9048668feb54f3d76dc2442.tar.gz
glutin-7a5e47c446801c40e9048668feb54f3d76dc2442.zip
Merge branch 'master' into x11_window_size_constraints
Diffstat (limited to 'src/api/x11')
-rw-r--r--src/api/x11/events.rs2
-rw-r--r--src/api/x11/window.rs53
2 files changed, 42 insertions, 13 deletions
diff --git a/src/api/x11/events.rs b/src/api/x11/events.rs
index 408a3ec..1c6668c 100644
--- a/src/api/x11/events.rs
+++ b/src/api/x11/events.rs
@@ -997,6 +997,8 @@ pub fn keycode_to_element(scancode: libc::c_uint) -> Option<VirtualKeyCode> {
//ffi::XK_hebrew_taw => events::VirtualKeyCode::Hebrew_taw,
//ffi::XK_hebrew_taf => events::VirtualKeyCode::Hebrew_taf,
//ffi::XK_Hebrew_switch => events::VirtualKeyCode::Hebrew_switch,
+ ffi::XF86XK_Back => VirtualKeyCode::NavigateBackward,
+ ffi::XF86XK_Forward => VirtualKeyCode::NavigateForward,
_ => return None
})
}
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index 86d6c92..aeb7efe 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -867,29 +867,61 @@ impl Window {
self.x.display.check_errors().expect("Failed to call XcursorLibraryLoadCursor");
(self.x.display.xlib.XDefineCursor)(self.x.display.display, self.x.window, xcursor);
(self.x.display.xlib.XFlush)(self.x.display.display);
+ (self.x.display.xlib.XFreeCursor)(self.x.display.display, xcursor);
self.x.display.check_errors().expect("Failed to call XDefineCursor");
}
}
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
- use CursorState::{ Grab, Normal };
+ use CursorState::{ Grab, Normal, Hide };
let mut cursor_state = self.cursor_state.lock().unwrap();
-
match (state, *cursor_state) {
- (Normal, Grab) => {
+ (Normal, Normal) | (Hide, Hide) | (Grab, Grab) => return Ok(()),
+ _ => {},
+ }
+
+ match *cursor_state {
+ Grab => {
unsafe {
(self.x.display.xlib.XUngrabPointer)(self.x.display.display, ffi::CurrentTime);
self.x.display.check_errors().expect("Failed to call XUngrabPointer");
- *cursor_state = Normal;
- Ok(())
}
},
-
- (Grab, Normal) => {
+ Normal => {},
+ Hide => {
unsafe {
- *cursor_state = Grab;
+ let xcursor = (self.x.display.xlib.XCreateFontCursor)(self.x.display.display, 68/*XC_left_ptr*/);
+ self.x.display.check_errors().expect("Failed to call XCreateFontCursor");
+ (self.x.display.xlib.XDefineCursor)(self.x.display.display, self.x.window, xcursor);
+ self.x.display.check_errors().expect("Failed to call XDefineCursor");
+ (self.x.display.xlib.XFlush)(self.x.display.display);
+ (self.x.display.xlib.XFreeCursor)(self.x.display.display, xcursor);
+ }
+ },
+ }
+ *cursor_state = state;
+ match state {
+ Normal => Ok(()),
+ Hide => {
+ let data = &[0, 0, 0, 0, 0, 0, 0, 0];
+ unsafe {
+ let mut black = ffi::XColor {
+ red: 0, green: 0, blue: 0,
+ pad: 0, pixel: 0, flags: 0,
+ };
+ let bitmap = (self.x.display.xlib.XCreateBitmapFromData)(self.x.display.display, self.x.window, data.as_ptr(), 8, 8);
+ let cursor = (self.x.display.xlib.XCreatePixmapCursor)(self.x.display.display, bitmap, bitmap, &mut black, &mut black, 0, 0);
+ (self.x.display.xlib.XDefineCursor)(self.x.display.display, self.x.window, cursor);
+ self.x.display.check_errors().expect("Failed to call XDefineCursor");
+ (self.x.display.xlib.XFreeCursor)(self.x.display.display, cursor);
+ (self.x.display.xlib.XFreePixmap)(self.x.display.display, bitmap);
+ }
+ Ok(())
+ },
+ Grab => {
+ unsafe {
match (self.x.display.xlib.XGrabPointer)(
self.x.display.display, self.x.window, ffi::False,
(ffi::ButtonPressMask | ffi::ButtonReleaseMask | ffi::EnterWindowMask |
@@ -908,11 +940,6 @@ impl Window {
}
}
},
-
- // Nothing needs to change
- (Grab, Grab) | (Normal, Normal) => Ok(()),
-
- _ => unimplemented!(),
}
}