From 6ccf70f82d9136844ae8f2bb68b43aa31fd09d25 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 22 Aug 2014 19:04:00 +0000 Subject: Fix nogroup regression, where nogroup became an actual group - the symantics between cwm groups and ewmh got in the way. Ensure a client that wants to be in nogroup stays in nogroup (thus stays in view), even when (re)reading NET_WM_DESKTOP. Paritially reverts patchset 644 (2014-02-07 13:09 PST) which deals with a NULL cc->group. All to be revisited when NET_WM_STATE_STICKY hits cwm. Reported by many; testing and ok phessler. --- group.c | 25 ++++++++++++------------- mousefunc.c | 5 +++-- search.c | 4 ++-- xutil.c | 7 +++++-- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/group.c b/group.c index efab527..36a2bb4 100644 --- a/group.c +++ b/group.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: group.c,v 1.92 2014/08/20 15:15:29 okan Exp $ + * $OpenBSD: group.c,v 1.93 2014/08/22 19:04:00 okan Exp $ */ #include @@ -48,17 +48,14 @@ const char *num_to_name[] = { static void group_assign(struct group_ctx *gc, struct client_ctx *cc) { - if (gc == NULL) - gc = TAILQ_FIRST(&cc->sc->groupq); - if (cc->group == gc) - return; - if (cc->group != NULL) TAILQ_REMOVE(&cc->group->clients, cc, group_entry); - TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry); cc->group = gc; + if (cc->group != NULL) + TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry); + xu_ewmh_net_wm_desktop(cc); } @@ -354,7 +351,7 @@ group_autogroup(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; struct autogroupwin *aw; struct group_ctx *gc; - int num = -1, both_match = 0; + int num = -2, both_match = 0; long *grpnum; if (cc->ch.res_class == NULL || cc->ch.res_name == NULL) @@ -362,12 +359,9 @@ group_autogroup(struct client_ctx *cc) if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP], XA_CARDINAL, 1, (unsigned char **)&grpnum) > 0) { - if (*grpnum == -1) - num = 0; - else if (*grpnum > CALMWM_NGROUPS || *grpnum < 0) + num = *grpnum; + if (num > CALMWM_NGROUPS || num < -1) num = CALMWM_NGROUPS - 1; - else - num = *grpnum; XFree(grpnum); } else { TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { @@ -382,6 +376,11 @@ group_autogroup(struct client_ctx *cc) } } + if ((num == -1) || (num == 0)) { + group_assign(NULL, cc); + return; + } + TAILQ_FOREACH(gc, &sc->groupq, entry) { if (gc->num == num) { group_assign(gc, cc); diff --git a/mousefunc.c b/mousefunc.c index c954991..323ae29 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: mousefunc.c,v 1.72 2014/08/20 15:15:29 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.73 2014/08/22 19:04:00 okan Exp $ */ #include @@ -202,7 +202,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg) if (wname == NULL) continue; - menuq_add(&menuq, cc, "(%d) %s", cc->group->num, wname); + menuq_add(&menuq, cc, "(%d) %s", + cc->group ? cc->group->num : 0, wname); } if (TAILQ_EMPTY(&menuq)) diff --git a/search.c b/search.c index 0b3b95d..3ee8e9d 100644 --- a/search.c +++ b/search.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: search.c,v 1.38 2014/08/20 15:15:29 okan Exp $ + * $OpenBSD: search.c,v 1.39 2014/08/22 19:04:00 okan Exp $ */ #include @@ -143,7 +143,7 @@ search_print_client(struct menu *mi, int list) cc->matchname = cc->name; (void)snprintf(mi->print, sizeof(mi->print), "(%d) %c%s", - cc->group->num, flag, cc->matchname); + cc->group ? cc->group->num : 0, flag, cc->matchname); if (!list && cc->matchname != cc->name && strlen(mi->print) < sizeof(mi->print) - 1) { diff --git a/xutil.c b/xutil.c index 64fccb0..368dc40 100644 --- a/xutil.c +++ b/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xutil.c,v 1.86 2014/08/20 15:15:29 okan Exp $ + * $OpenBSD: xutil.c,v 1.87 2014/08/22 19:04:00 okan Exp $ */ #include @@ -291,7 +291,10 @@ xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n) void xu_ewmh_net_wm_desktop(struct client_ctx *cc) { - long num = cc->group->num; + long num = 0xffffffff; + + if (cc->group) + num = cc->group->num; XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&num, 1); -- cgit v1.2.3-2-gb3c3