From 05bfd598a060beafe1a20ff759e499987f1ce87b Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Mon, 9 Nov 2015 01:33:33 -0300 Subject: 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 --- src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main.rs') 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); + } + }, + _ => (), } } } -- cgit v1.2.3-54-g00ecf