aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2015-11-09 01:33:33 -0300
committerMatias Linares <matiaslina@openmailbox.org>2015-11-09 01:33:33 -0300
commit05bfd598a060beafe1a20ff759e499987f1ce87b (patch)
treedba0e6ddc3c8d110ece5bbdd4b3f7f12063eb0a5 /src/main.rs
parenta92f31598c7f5c5be971d643435193c52080b4dc (diff)
downloaddotwm-05bfd598a060beafe1a20ff759e499987f1ce87b.tar.gz
Focus handling.
For now this have some bugs. Some complex programs (i.e. thunar, firefox) will spawn a lot of XCreateEvents and the last window it's not focused correctly. Also the enter notify should work on an input instead hovering the window
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index c89544d..feda9e0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,6 +47,8 @@ fn main() {
dotwm.add_binding(keysym::XK_Return, xlib::Mod4Mask, exec,
&["xterm"]);
+ dotwm.add_binding(keysym::XK_p, xlib::Mod4Mask, exec,
+ &["dmenu_run"]);
dotwm.add_binding(keysym::XK_h, xlib::Mod4Mask, move_win, &["-10", "0"]);
dotwm.add_binding(keysym::XK_j, xlib::Mod4Mask, move_win, &["0", "10"]);
dotwm.add_binding(keysym::XK_k, xlib::Mod4Mask, move_win, &["0", "-10"]);
@@ -57,6 +59,7 @@ fn main() {
// Main loop
loop {
let event = next_event(dotwm.display);
+ println!("Event {:?}", event);
match event {
Event::Key(mut e, true) => {
let keysym = unsafe { xlib::XLookupKeysym(&mut e, 0) as u32 };
@@ -69,7 +72,15 @@ fn main() {
let create_event = xlib::XCreateWindowEvent::from(e);
dotwm.add_window(create_event.window);
}
- _ => println!("Catched event! {:?}", event),
+ Event::Destroy(e) => {
+ dotwm.remove_window(e.window);
+ },
+ Event::Enter(e) => {
+ if let Some(idx) = dotwm.find_window(e.window) {
+ dotwm.change_focus_of(idx);
+ }
+ },
+ _ => (),
}
}
}