sowm

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

commit 522defba1ee671c15c5767166b8152539e883714
parent e0bd38091a5b224a1f19a85bd499dcfeed7d3ac9
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Fri, 18 Oct 2019 12:05:13 +0300

sowm: simpler del

Diffstat:
MREADME.md | 2++
Msowm.c | 41++++++++++++++---------------------------
2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md @@ -1,3 +1,5 @@ +Note: Stick to tagged releases as master isn't currently in a stable state*!* + # sowm <a href="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg" width="43%" align="right"></a> diff --git a/sowm.c b/sowm.c @@ -37,7 +37,7 @@ static void notify_motion(XEvent *e); static void run(const Arg arg); static void win_add(Window w); static void win_center(const Arg arg); -static void win_del(Window w); +static void win_del(client *c); static void win_fs(); static void win_kill(); static void win_next(); @@ -81,7 +81,7 @@ void win_focus(Window w) { } void notify_destroy(XEvent *e) { - win_del(e->xdestroywindow.window); + for win if (c->w == e->xdestroywindow.window) win_del(c); if (list) win_focus(list->w); } @@ -152,31 +152,18 @@ void win_add(Window w) { ws_save(ws); } -void win_del(Window w) { - for win if (c->w == w) { - if (!c->prev && !c->next) { - free(list); - list = 0; - ws_save(ws); - return; - } - - if (!c->prev) { - list = c->next; - c->next->prev = 0; - - } else if (!c->next) { - c->prev->next = 0; - - } else { - c->prev->next = c->next; - c->next->prev = c->prev; - } - - free(c); - ws_save(ws); - return; +void win_del(client *c) { + if (c == list) { + list = list->next ? list->next : 0; + goto del; } + + if (c->prev) c->prev->next = c->next; + if (c->next) c->next->prev = c->prev; + +del: + free(c); + ws_save(ws); } void win_kill() { @@ -214,7 +201,7 @@ void win_to_ws(const Arg arg) { ws_save(arg.i); ws_sel(tmp); - win_del(cur->w); + win_del(cur); XUnmapWindow(d, cur->w); ws_save(tmp);