aboutsummaryrefslogtreecommitdiff
path: root/src/safe_x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/safe_x11')
-rw-r--r--src/safe_x11/mod.rs11
-rw-r--r--src/safe_x11/window.rs20
2 files changed, 30 insertions, 1 deletions
diff --git a/src/safe_x11/mod.rs b/src/safe_x11/mod.rs
index 9cd14fd..2e368aa 100644
--- a/src/safe_x11/mod.rs
+++ b/src/safe_x11/mod.rs
@@ -149,7 +149,7 @@ pub fn grab_button(display: *mut Display, button: u32, modifiers: u32,
cursor: Cursor) {
unsafe {
let default_win = xlib::XDefaultRootWindow(display);
- xlib::XGrabButton(display, button, modifiers , default_win,
+ xlib::XGrabButton(display, button, modifiers, default_win,
owner_events as i32, event_mask as u32, pointer_mode,
keyboard_mode, confine_to, cursor);
}
@@ -159,6 +159,7 @@ pub fn grab_button(display: *mut Display, button: u32, modifiers: u32,
///
pub fn grab_key(display: *mut Display, key: u32, modifiers: u32, owner_events: bool,
pointer_mode: i32, keyboard_mode: i32) {
+ println!("Modifiers {:x}", modifiers);
unsafe {
let default_win = xlib::XDefaultRootWindow(display);
let keycode: i32 = xlib::XKeysymToKeycode(display, key as u64) as i32;
@@ -166,6 +167,14 @@ pub fn grab_key(display: *mut Display, key: u32, modifiers: u32, owner_events: b
owner_events as i32, pointer_mode, keyboard_mode);
}
}
+/// Unregister a combination of keys that will send a `XEvent`
+pub fn ungrab_key(display: *mut Display, key: u32, modifiers: u32) {
+ unsafe {
+ let default_win = xlib::XDefaultRootWindow(display);
+ let keycode: i32 = xlib::XKeysymToKeycode(display, key as u64) as i32;
+ xlib::XUngrabKey(display, keycode, modifiers, default_win);
+ }
+}
// Window code.
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs
index 6c8e48b..34cce64 100644
--- a/src/safe_x11/window.rs
+++ b/src/safe_x11/window.rs
@@ -166,6 +166,26 @@ impl XWindow {
}
}
+ /// Resizes the window an absolute amount within the height and width.
+ pub fn resize_abs(&self, w: i32, h: i32) {
+ let attrs = self.attributes();
+ unsafe {
+ let ww: u32 = max(1, (attrs.width + w) as u32);
+ let wh: u32 = max(1, (attrs.height + h) as u32);
+ xlib::XResizeWindow(self.display, self.inner,
+ ww, wh);
+ }
+ }
+
+ pub fn resize_to(&self, w: i32, h: i32) {
+ unsafe {
+ let ww: u32 = max(1, w as u32);
+ let wh: u32 = max(1, h as u32);
+ xlib::XResizeWindow(self.display, self.inner,
+ ww, wh);
+ }
+ }
+
/// Raise the focus of the window and set a border.
pub fn focus(&self) {
let attrs = self.attributes();