aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2015-12-27 23:17:00 -0300
committerMatias Linares <matiaslina@openmailbox.org>2015-12-27 23:17:00 -0300
commit312a8f2e5832c06fcd228acee4945b3236841ee1 (patch)
tree9603233b2d6a29d444befef45e7d0e98698f7015 /src
parentad181f63bc252303d52dc413433890f14d21b915 (diff)
downloaddotwm-312a8f2e5832c06fcd228acee4945b3236841ee1.tar.gz
Better fullscreen handling.
Diffstat (limited to 'src')
-rw-r--r--src/command.rs2
-rw-r--r--src/desktop.rs2
-rw-r--r--src/safe_x11/window.rs37
3 files changed, 26 insertions, 15 deletions
diff --git a/src/command.rs b/src/command.rs
index 8f7218e..21760a8 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -73,7 +73,7 @@ pub fn fullscreen(wm: &mut DotWM, _: xlib::XEvent, _: &[String]) -> bool {
let fs_atom = wm.netatoms[&NetAtom::NetFullscreen];
if let Some(win) = wm.current_window_mut() {
- win.toggle_fullscreen(wmstate, fs_atom, true);
+ win.fullscreen(wmstate, fs_atom);
};
true
}
diff --git a/src/desktop.rs b/src/desktop.rs
index 7d2a8a5..520c196 100644
--- a/src/desktop.rs
+++ b/src/desktop.rs
@@ -72,6 +72,8 @@ impl Desktop {
}
}
+ /// Changes the focus from the current window to the window on the idx
+ /// postition on the window_list.
pub fn change_focus_of(&mut self, idx: usize) {
let w = &self.window_list[idx];
self.unfocus_current_window();
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs
index 8a3bab4..78b73f7 100644
--- a/src/safe_x11/window.rs
+++ b/src/safe_x11/window.rs
@@ -38,6 +38,7 @@ pub struct XWindow {
/// xlib::Window that wraps this struct.
pub inner: Window,
fullscreen: bool,
+ prev_attribs: XWindowAttributes,
}
fn fixed_with_ratio(x: i32, ratio: f32) -> i32 {
@@ -51,10 +52,12 @@ impl XWindow {
/// `None` if the window is the root window.
pub fn new(d: *mut xlib::Display, w: Window) -> Option<XWindow> {
if w != 0 {
+ let attrs: XWindowAttributes = unsafe { uninitialized() };
Some(XWindow {
display: d,
inner: w,
fullscreen: false,
+ prev_attribs: attrs,
})
} else {
None
@@ -210,30 +213,36 @@ impl XWindow {
}
/// Fullscreen toggle
- pub fn toggle_fullscreen(&mut self, wm_state_atom: Atom,
- fs_atom: Atom, fullscreen: bool) {
+ pub fn fullscreen(&mut self, wm_state_atom: Atom, fs_atom: Atom) {
let screen = unsafe { XDefaultScreen(self.display) };
let dh: u32 = unsafe { XDisplayHeight(self.display, screen) as u32 };
let dw: u32 = unsafe { XDisplayWidth(self.display, screen) as u32 };
- if fullscreen != self.fullscreen {
- self.fullscreen = fullscreen;
- let fs_atom_slice: &[Atom; 1] = &[fs_atom];
- let fs_atom_ptr: *const u8 = unsafe { transmute(fs_atom_slice) };
+ if !self.fullscreen {
+ // First, store the XWindowAttributes to query later.
+ self.prev_attribs = self.attributes();
- unsafe {
- XChangeProperty(self.display, self.inner, wm_state_atom,
- XA_ATOM, 32, PropModeReplace, fs_atom_ptr,
- fullscreen as i32);
- }
- }
-
- if fullscreen {
+ self.fullscreen = true;
self.move_resize(0, 0, dw, dh);
self.set_border_width(0);
} else {
+ self.fullscreen = false;
+ self.move_resize(self.prev_attribs.x,
+ self.prev_attribs.y,
+ self.prev_attribs.width as u32,
+ self.prev_attribs.height as u32);
self.set_border_width(1);
}
+
+ // EWMH for fullscreen (Don't know how to test it.)
+ let fs_atom_slice: &[Atom; 1] = &[fs_atom];
+ let fs_atom_ptr: *const u8 = unsafe { transmute(fs_atom_slice) };
+
+ unsafe {
+ XChangeProperty(self.display, self.inner, wm_state_atom,
+ XA_ATOM, 32, PropModeReplace, fs_atom_ptr,
+ self.fullscreen as i32);
+ }
}
pub fn map(&self) {