From 3d44ce225a8bba7bc65c3edba2caca131c95b611 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 18 Dec 2011 14:50:41 +0100 Subject: [PATCH] Select first tag of each screen if !tag prop at start/reload --- src/client.h | 12 ++++++++++++ src/tag.c | 2 +- src/wmfs.c | 23 ++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/client.h b/src/client.h index c8c3cde..8cc3f92 100644 --- a/src/client.h +++ b/src/client.h @@ -132,4 +132,16 @@ clients_arrange_map(void) } } +static inline void +clients_tag_arrange_map(struct tag *t) +{ + struct client *c; + void (*sfunc)(struct client*) + = (t == t->screen->seltag ? client_map : client_unmap); + + SLIST_FOREACH(c, &t->clients, tnext) + sfunc(c); +} + + #endif /* CLIENT_H */ diff --git a/src/tag.c b/src/tag.c index bec82ad..ce2f660 100644 --- a/src/tag.c +++ b/src/tag.c @@ -107,7 +107,7 @@ tag_client(struct tag *t, struct client *c) tag_client(t, cc); } - if(t != W->screen->seltag || c->flags & CLIENT_TABBED) + if(t != c->screen->seltag || c->flags & CLIENT_TABBED) client_unmap(c); } diff --git a/src/wmfs.c b/src/wmfs.c index a7a2ece..0c4d00f 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -186,7 +186,7 @@ wmfs_scan(void) struct geo g; struct client *c, *cc, *fc; struct screen *s; - int i, n, rf, nscreen; + int i, n, rf, nscreen = 0; int tag = -1, screen = -1, flags = -1; unsigned long ir, il; long *ret, *tret; @@ -205,7 +205,6 @@ wmfs_scan(void) (unsigned char**)&tret) == Success && ret) { - pstag = true; nscreen = (int)ir; } @@ -298,20 +297,19 @@ wmfs_scan(void) } } - /* Set back selected tag */ - if(pstag) + if(!nscreen) { - struct tag *t; - + SLIST_FOREACH(s, &W->h.screen, next) + tag_screen(s, TAILQ_FIRST(&s->tags)); + } + else + { + /* Set back selected tag */ for(i = 0; i < nscreen; ++i) { s = screen_gb_id(i); - - if((t = tag_gb_id(s, tret[i])) != s->seltag) - tag_screen(s, t); + tag_screen(s, tag_gb_id(s, tret[i])); } - - XFree(tret); } /* Re-adjust tabbed clients */ @@ -324,6 +322,9 @@ wmfs_scan(void) W->flags &= ~WMFS_SCAN; + if(tret) + XFree(tret); + XFree(w); XSync(W->dpy, false); }