sowm: simpler del

This commit is contained in:
Dylan Araps 2019-10-18 12:05:13 +03:00
parent e0bd38091a
commit 522defba1e
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 16 additions and 27 deletions

View File

@ -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>

41
sowm.c
View File

@ -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);