sowm

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

commit 4b91bb3ba68909b3786bd5531dbc965b14e2f7ea
parent 31589b5e94b0f1a397c4131d8f1ff1186595a60d
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Sun, 13 Oct 2019 18:17:39 +0300

docs: update

Diffstat:
Msowm.c | 32+++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/sowm.c b/sowm.c @@ -9,7 +9,8 @@ #include <signal.h> #include <unistd.h> -#define WIN (c=list;c;c=c->next) +#define WIN (c=list;c;c=c->next) +#define FOC(W) XSetInputFocus(dis, W, RevertToParent, CurrentTime); typedef union { const char** com; @@ -89,12 +90,11 @@ static void (*events[LASTEvent])(XEvent *e) = { void notify_destroy(XEvent *e) { win_del(e->xdestroywindow.window); - if (list) XSetInputFocus(dis, list->win, RevertToParent, CurrentTime); + if (list) FOC(list->win); } void notify_enter(XEvent *e) { - if (e->xcrossing.window != root) - XSetInputFocus(dis, e->xcrossing.window, RevertToParent, CurrentTime); + if (e->xcrossing.window != root) FOC(e->xcrossing.window) } void notify_motion(XEvent *e) { @@ -225,16 +225,14 @@ void win_center(Window w) { void win_fs(Window w) { client *c; - for WIN if (c->win == w) break; - - if (!c) return; - - if ((c->f = c->f == 0 ? 1 : 0)) { - XGetWindowAttributes(dis, w, &c->a); - XMoveResizeWindow(dis, w, 0, 0, sw, sh); + for WIN if (c->win == w) { + if ((c->f = c->f == 0 ? 1 : 0)) { + XGetWindowAttributes(dis, w, &c->a); + XMoveResizeWindow(dis, w, 0, 0, sw, sh); - } else - XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height); + } else + XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height); + } } void win_to_ws(const Arg arg) { @@ -252,7 +250,7 @@ void win_to_ws(const Arg arg) { XUnmapWindow(dis, cur); ws_save(tmp); - if (list) XSetInputFocus(dis, list->win, RevertToParent, CurrentTime); + if (list) FOC(list->win); } void win_next() { @@ -266,7 +264,7 @@ void win_next() { c = c->next ? c->next : list; - XSetInputFocus(dis, c->win, RevertToParent, CurrentTime); + FOC(c->win); XRaiseWindow(dis, c->win); } } @@ -296,7 +294,7 @@ void ws_go(const Arg arg) { ws_sel(arg.i); - if (list) XSetInputFocus(dis, list->win, RevertToParent, CurrentTime); + if (list) FOC(list->win); } void ws_save(int i) { @@ -327,7 +325,7 @@ void map_request(XEvent *e) { EnterWindowMask|FocusChangeMask); win_center(ev->window); XMapWindow(dis, ev->window); - XSetInputFocus(dis, ev->window, RevertToParent, CurrentTime); + FOC(ev->window); win_add(ev->window); }