sowm

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

commit efc1327d0efad3747971a246e08b762b5413dc0d
parent 18b908fe342f41aaf63fcacf103fc1c0c6e257d3
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Fri, 11 Oct 2019 19:51:06 +0300

catwm: fix send to workspace

Diffstat:
Mcatwm.c | 68+++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 35 insertions(+), 33 deletions(-)

diff --git a/catwm.c b/catwm.c @@ -85,7 +85,7 @@ static XButtonEvent start; static XWindowAttributes attr; static client *current; static client *head; -static desktop desktops[6]; +static desktop desktops[10]; static void (*events[LASTEvent])(XEvent *e) = { [KeyPress] = keypress, @@ -154,8 +154,9 @@ void client_to_desktop(const Arg arg) { // Remove client from current desktop select_desktop(tmp2); - remove_window(current->win); - + XUnmapWindow(dis,tmp->win); + remove_window(tmp->win); + save_desktop(tmp2); update_current(); } @@ -195,7 +196,6 @@ void update_current() { for(c=head;c;c=c->next) if (current == c) { - XSetWindowBorderWidth(dis, c->win, 1); XSetInputFocus(dis, c->win, RevertToParent, CurrentTime); XRaiseWindow(dis, c->win); } @@ -303,37 +303,39 @@ void remove_window(Window w) { client *c; for(c=head;c;c=c->next) { - if(c->win != w) + if(c->win == w) { + if (c->prev == NULL && c->next == NULL) { + free(head); + + head = NULL; + current = NULL; + + save_desktop(curr_desk); + return; + } + + if (c->prev == NULL) { + head = c->next; + c->next->prev = NULL; + current = c->next; + } + + else if (c->next == NULL) { + c->prev->next = NULL; + current = c->prev; + } + + else { + c->prev->next = c->next; + c->next->prev = c->prev; + current = c->prev; + } + + free(c); + save_desktop(curr_desk); + update_current(); return; - - if (c->prev == NULL && c->next == NULL) { - free(head); - - head = NULL; - current = NULL; - - return; - } - - if (c->prev == NULL) { - head = c->next; - c->next->prev = NULL; - current = c->next; } - - else if (c->next == NULL) { - c->prev->next = NULL; - current = c->prev; - } - - else { - c->prev->next = c->next; - c->next->prev = c->prev; - current = c->prev; - } - - free(c); - return; } }