From a23dd7987b6bbd7c32ac8e4b9d4395f9f1538101 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 9 Dec 2011 12:06:32 +0100 Subject: [PATCH] Work on reload/tag arranging --- src/client.h | 14 ++++++++++++++ src/ewmh.c | 20 +++++++++++--------- src/tag.c | 17 ++--------------- src/wmfs.c | 8 ++++++-- src/wmfs.h | 2 ++ 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/client.h b/src/client.h index 2fcd30a..c8c3cde 100644 --- a/src/client.h +++ b/src/client.h @@ -118,4 +118,18 @@ client_unmap(struct client *c) } } +static inline void +clients_arrange_map(void) +{ + struct client *c; + + SLIST_FOREACH(c, &W->h.client, next) + { + if(c->tag == c->screen->seltag && !(c->flags & CLIENT_TABBED)) + client_map(c); + else + client_unmap(c); + } +} + #endif /* CLIENT_H */ diff --git a/src/ewmh.c b/src/ewmh.c index 65238bb..0a221fa 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -5,6 +5,7 @@ #include "ewmh.h" #include "util.h" +#include "screen.h" void ewmh_init(void) @@ -103,21 +104,22 @@ void ewmh_update_wmfs_props(void) { struct screen *s; - int n = 0; - unsigned char *cts = NULL; + int i, ns = 0; + long *cts = NULL; SLIST_FOREACH(s, &W->h.screen, next) - ++n; + ++ns; - cts = xcalloc(n, sizeof(char)); + cts = xcalloc(ns, sizeof(long)); - n = 0; - - SLIST_FOREACH(s, &W->h.screen, next) - cts[n++] = s->seltag->id; + for(i = 0; i < ns; ++i) + { + s = screen_gb_id(i); + cts[i] = s->seltag->id; + } XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_current_tag], XA_CARDINAL, 32, - PropModeReplace, (unsigned char*)cts, n); + PropModeReplace, (unsigned char*)cts, ns); if(W->client) XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_focus], XA_WINDOW, 32, diff --git a/src/tag.c b/src/tag.c index 75a23f7..7bf7ef9 100644 --- a/src/tag.c +++ b/src/tag.c @@ -46,23 +46,10 @@ tag_screen(struct screen *s, struct tag *t) t->prev = s->seltag; s->seltag = t; - /* Unmap previous tag's frame */ - if(t->prev != t) - SLIST_FOREACH(c, &t->prev->clients, tnext) - client_unmap(c); - - /* - * Map selected tag's frame, only if there is - * clients in t - */ - if(!SLIST_EMPTY(&t->clients)) - { - SLIST_FOREACH(c, &t->clients, tnext) - if(!(c->flags & CLIENT_TABBED)) - client_map(c); + clients_arrange_map(); + if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) client_focus( client_tab_next(t->sel)); - } infobar_elem_screen_update(s, ElemTag); diff --git a/src/wmfs.c b/src/wmfs.c index 0040356..74669ef 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -197,6 +197,8 @@ wmfs_scan(void) SLIST_INIT(&W->h.client); + W->flags |= WMFS_SCAN; + /* Get previous selected tag to apply it at the end */ if(XGetWindowProperty(W->dpy, W->root, W->net_atom[wmfs_current_tag], 0, 32, False, XA_CARDINAL, &rt, &rf, &ir, &il, @@ -307,15 +309,17 @@ wmfs_scan(void) /* Set back selected tag */ if(pstag) { - for(i = 0; i < (int)nscreen; ++i) + for(i = 0; i < nscreen; ++i) { s = screen_gb_id(i); - tag_screen(screen_gb_id(i), tag_gb_id(s, tret[i])); + tag_screen(s, tag_gb_id(s, tret[i])); } XFree(tret); } + W->flags &= ~WMFS_SCAN; + XFree(w); XSync(W->dpy, false); } diff --git a/src/wmfs.h b/src/wmfs.h index f36ce6f..4875b59 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -250,6 +250,8 @@ struct wmfs int xscreen, xdepth; int xmaxw, xmaxh; Flags numlockmask; +#define WMFS_SCAN 0x01 + Flags flags; GC gc, rgc; Atom *net_atom; char **argv;