aboutsummaryrefslogtreecommitdiff
path: root/src/safe_x11
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2015-12-07 16:19:36 -0300
committerMatias Linares <matiaslina@openmailbox.org>2015-12-07 16:19:36 -0300
commit69f8194da778a692b6b0c14f43d9611c2072e8ba (patch)
tree8d9f252bf7a6db515a05800a73b35b21d1692cfb /src/safe_x11
parent12faa87415d91820503b6b1c98ebabbddc50d665 (diff)
downloaddotwm-69f8194da778a692b6b0c14f43d9611c2072e8ba.tar.gz
Implement desktops.
It's somewhat buggy. But works :). There're 2 desktops only for now, maybe later I will implement something more dynamic
Diffstat (limited to 'src/safe_x11')
-rw-r--r--src/safe_x11/mod.rs7
-rw-r--r--src/safe_x11/window.rs20
2 files changed, 22 insertions, 5 deletions
diff --git a/src/safe_x11/mod.rs b/src/safe_x11/mod.rs
index 2e368aa..9e5859a 100644
--- a/src/safe_x11/mod.rs
+++ b/src/safe_x11/mod.rs
@@ -78,10 +78,8 @@ impl<'a> fmt::Display for XSafeError<'a> {
///
pub fn open_display(display: &str) -> Result<*mut Display, XSafeError> {
let d = if display == "" {
- println!("Opening default display");
unsafe { xlib::XOpenDisplay(0x0 as *const i8) }
} else {
- println!("Opening {}", display);
let cstr = try!(CString::new(display));
unsafe { xlib::XOpenDisplay(cstr.as_ptr()) }
};
@@ -121,6 +119,10 @@ pub fn screen_size(display: *mut Display) -> (u32, u32) {
(dw, dh)
}
+pub fn root_window(display: *mut Display) -> Window {
+ unsafe { xlib::XDefaultRootWindow(display) }
+}
+
/// Grab pointer buttons.
///
/// # Example
@@ -159,7 +161,6 @@ 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;
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs
index 34cce64..8a3bab4 100644
--- a/src/safe_x11/window.rs
+++ b/src/safe_x11/window.rs
@@ -20,6 +20,9 @@ use x11::xlib::{
ClientMessage,ClientMessageData, NoEventMask,
XChangeProperty,
+ XChangeWindowAttributes, XSetWindowAttributes,
+
+ XMapWindow, XUnmapWindow,
};
use std::ptr;
@@ -218,7 +221,6 @@ impl XWindow {
let fs_atom_slice: &[Atom; 1] = &[fs_atom];
let fs_atom_ptr: *const u8 = unsafe { transmute(fs_atom_slice) };
- println!("Changing property!");
unsafe {
XChangeProperty(self.display, self.inner, wm_state_atom,
XA_ATOM, 32, PropModeReplace, fs_atom_ptr,
@@ -227,11 +229,25 @@ impl XWindow {
}
if fullscreen {
- println!("resizing!");
self.move_resize(0, 0, dw, dh);
self.set_border_width(0);
} else {
self.set_border_width(1);
}
}
+
+ pub fn map(&self) {
+ unsafe { XMapWindow(self.display, self.inner); }
+ }
+
+ pub fn unmap(&self) {
+ unsafe { XUnmapWindow(self.display, self.inner); }
+ }
+}
+
+pub fn change_window_attributes(display: *mut xlib::Display, win: Window, mask: u64,
+ window_attribs: *mut XSetWindowAttributes) {
+ unsafe {
+ XChangeWindowAttributes(display, win, mask, window_attribs);
+ }
}