From d8a33d9894f15aafb9eb14e0def1de450ec96716 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 9 Dec 2011 12:32:55 +0100 Subject: [PATCH] Fix tag mapping at reload and possible segf with tabmaster client in tag_client --- src/tag.c | 2 +- src/wmfs.c | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/tag.c b/src/tag.c index a1cb2b5..75a23f7 100644 --- a/src/tag.c +++ b/src/tag.c @@ -113,7 +113,7 @@ tag_client(struct tag *t, struct client *c) else if(!(c->flags & CLIENT_TABBED)) layout_split_integrate(c, t->sel); - if(c->flags & CLIENT_TABMASTER) + if(c->flags & CLIENT_TABMASTER && c->prevtag) { struct client *cc; diff --git a/src/wmfs.c b/src/wmfs.c index b1e6646..0040356 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -185,31 +185,26 @@ wmfs_scan(void) { struct geo g; struct client *c, *cc, *fc; - int i, n, rf; + struct screen *s; + int i, n, rf, nscreen; int tag = -1, screen = -1, flags = -1; unsigned long ir, il; - long *ret; + long *ret, *tret; + bool pstag = false; XWindowAttributes wa; Window usl, usl2, *w = NULL, tm, focus; Atom rt; SLIST_INIT(&W->h.client); - /* Set back selected tag */ + /* 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, - (unsigned char**)&ret) + (unsigned char**)&tret) == Success && ret) { - struct screen *s; - - for(i = 0; i < (int)ir; ++i) - { - s = screen_gb_id(i); - tag_screen(s, tag_gb_id(s, ret[i])); - } - - XFree(ret); + pstag = true; + nscreen = (int)ir; } /* Previous focused client before reload */ @@ -309,7 +304,20 @@ wmfs_scan(void) if((fc = client_gb_win(focus)) && fc != W->client) client_focus(fc); + /* Set back selected tag */ + if(pstag) + { + for(i = 0; i < (int)nscreen; ++i) + { + s = screen_gb_id(i); + tag_screen(screen_gb_id(i), tag_gb_id(s, tret[i])); + } + + XFree(tret); + } + XFree(w); + XSync(W->dpy, false); } static void