sowm

An itsy bitsy floating window manager (220~ sloc!).
git clone git://mfeller.io/sowm.git
Log | Files | Refs | README | LICENSE

commit 60d88980fbe029d81dbb0e469f5bddf1f433b8a8
parent 4af0d5414721c3e14b4431d37d069c5d21851ede
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Thu, 17 Oct 2019 09:16:22 +0300

sowm: subscribe to less window events!

Diffstat:
Msowm.c | 27+++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/sowm.c b/sowm.c @@ -34,7 +34,6 @@ struct desktop{client *list;}; static void button_press(XEvent *e); static void button_release(); static void configure_request(XEvent *e); -static void key_grab(); static void key_press(XEvent *e); static void map_request(XEvent *e); static void notify_destroy(XEvent *e); @@ -158,7 +157,7 @@ void notify_destroy(XEvent *e) { void notify_enter(XEvent *e) { while(XCheckTypedEvent(d, EnterNotify, e)); - if (e->xcrossing.window != root) win_focus(e->xcrossing.window) + win_focus(e->xcrossing.window) } /* @@ -194,17 +193,6 @@ void notify_motion(XEvent *e) { } /* - This function initializes all key bindings defined in 'config.h'. - Simple stuff, nothing fancy or different from other window - managers happens here. -*/ -void key_grab() { - for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i) - XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod, - root, True, GrabModeAsync, GrabModeAsync); -} - -/* This function fires on a key press and checks to see if there is a matching and defined key binding. If there is a match the function bound to the key is executed. @@ -507,8 +495,7 @@ void configure_request(XEvent *e) { void map_request(XEvent *e) { Window w = e->xmaprequest.window; - XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask| - EnterWindowMask|FocusChangeMask); + XSelectInput(d, w, StructureNotifyMask|EnterWindowMask|LeaveWindowMask); win_center((Arg){.i = w}); XMapWindow(d, w); @@ -552,13 +539,13 @@ int main(void) { sw = XDisplayWidth(d, s); sh = XDisplayHeight(d, s); - key_grab(); - - XSelectInput(d, root, SubstructureNotifyMask| - SubstructureRedirectMask|EnterWindowMask|LeaveWindowMask); - + XSelectInput(d, root, SubstructureNotifyMask|SubstructureRedirectMask); XDefineCursor(d, root, XCreateFontCursor(d, 68)); + for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i) + XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod, + root, True, GrabModeAsync, GrabModeAsync); + for (int i=1; i<4; i+=2) XGrabButton(d, i, MOD, root, True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask,