sowm

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

commit fa96cc7b185711079954448d265490e42cd9ccdb
parent f36c78d9bb7ff1586df3eec7427113b507031a07
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Wed, 16 Oct 2019 14:15:34 +0300

sowm: reduce scope of client

Diffstat:
Msowm.c | 41++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/sowm.c b/sowm.c @@ -49,6 +49,8 @@ static void win_kill(); static void win_next(); static void win_to_ws(const Arg arg); static void ws_go(const Arg arg); +static void ws_save(int i); +static void ws_sel(int i); static client *list = {0}; static desktop ws_list[10]; @@ -77,17 +79,11 @@ static void (*events[LASTEvent])(XEvent *e) = { #include "config.h" // Iterate over the current desktop's window list. -#define win (c=list;c;c=c->next) +#define win (client *c=list;c;c=c->next) // Focus the given window. #define win_focus(W) XSetInputFocus(d, W, RevertToParent, CurrentTime); -// Save the current desktop's window list. -#define ws_save(i) ws_list[i].list = list; - -// Select the current desktop's window list. -#define ws_sel(i) list = ws_list[i].list, ws = i; - /* 'sowm' doesn't keep track of the currently focused window and instead grabs the window under the cursor when needed. @@ -237,8 +233,6 @@ void button_press(XEvent *e) { no longer at 0,0+[screen_width]X[screen_height]. */ void button_release() { - client *c; - for win if (c->w == mouse.subwindow) c->f = 0; mouse.subwindow = None; @@ -282,8 +276,6 @@ void win_add(Window w) { is updated. */ void win_del(Window w) { - client *c; - for win if (c->w == w) { if (!c->prev && !c->next) { free(list); @@ -355,8 +347,6 @@ void win_center(const Arg arg) { the window is un-fullscreened. */ void win_fs() { - client *c; - win_current(); for win if (c->w == cur) { @@ -411,15 +401,12 @@ void win_to_ws(const Arg arg) { */ void win_next() { win_current(); - client *c; - - if (list) { - for win if (c->w == cur) break; - + for win if (c->w == cur) { c = c->next ? c->next : list; win_focus(c->w); XRaiseWindow(d, c->w); + return; } } @@ -434,7 +421,6 @@ void win_next() { destination desktop's window list. */ void ws_go(const Arg arg) { - client *c; int tmp = ws; if (arg.i == ws) return; @@ -454,6 +440,23 @@ void ws_go(const Arg arg) { } /* + This function saves the current desktop's window list. + Simple, nothing to see here. +*/ +void ws_save(int i) { + ws_list[i].list = list; +} + +/* + This function restores a saved desktop's window list. + Simple, nothing to see here. +*/ +void ws_sel(int i) { + list = ws_list[i].list; + ws = i; +} + +/* This function allows a window to request a size, position and other attributes.