diff options
author | oga <oga> | 2009-01-27 00:42:53 +0000 |
---|---|---|
committer | oga <oga> | 2009-01-27 00:42:53 +0000 |
commit | c750462d13e2ee289d715bca58a85123d6f055f5 (patch) | |
tree | 60c63c71c63e16449e11d1cb17801699aba32fb4 /group.c | |
parent | 9203c7e8cacbc14878f49b5199650566b33b6e95 (diff) | |
download | cwm-c750462d13e2ee289d715bca58a85123d6f055f5.tar.gz cwm-c750462d13e2ee289d715bca58a85123d6f055f5.tar.xz cwm-c750462d13e2ee289d715bca58a85123d6f055f5.zip |
One of the most annoying things to do was restart cwm and lose all of
your group state. Fix this up by using an X Atom (_CWM_GRP) to store the name of the group that we're using (the name, not the number is because at one point we may make the group numbers dynamic). I've been talking about this since c2k8. so CM-w means you keep all of your windows grouped properly. ok okan@, todd@
Diffstat (limited to 'group.c')
-rw-r--r-- | group.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/group.c b/group.c index e1dd03e..29647ac 100644 --- a/group.c +++ b/group.c @@ -52,6 +52,9 @@ _group_add(struct group_ctx *gc, struct client_ctx *cc) if (cc->group != NULL) TAILQ_REMOVE(&cc->group->clients, cc, group_entry); + XChangeProperty(X_Dpy, cc->win, _CWM_GRP, XA_STRING, + 8, PropModeReplace, gc->name, strlen(gc->name)); + TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry); cc->group = gc; } @@ -62,6 +65,10 @@ _group_remove(struct client_ctx *cc) if (cc == NULL || cc->group == NULL) errx(1, "_group_remove: a ctx is NULL"); + XChangeProperty(X_Dpy, cc->win, _CWM_GRP, XA_STRING, 8, + PropModeReplace, shortcut_to_name[0], + strlen(shortcut_to_name[0])); + TAILQ_REMOVE(&cc->group->clients, cc, group_entry); cc->group = NULL; } @@ -132,6 +139,7 @@ group_init(void) TAILQ_INIT(&Groups[i].clients); Groups[i].hidden = 0; Groups[i].shortcut = i + 1; + Groups[i].name = shortcut_to_name[Groups[i].shortcut]; TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry); } @@ -325,16 +333,23 @@ group_autogroup(struct client_ctx *cc) { struct autogroupwin *aw; struct group_ctx *gc; + unsigned char *grpstr = NULL; char group[CALMWM_MAXNAMELEN]; if (cc->app_class == NULL || cc->app_name == NULL) return; - - TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { - if (strcmp(aw->class, cc->app_class) == 0 && - (aw->name == NULL || strcmp(aw->name, cc->app_name) == 0)) { - strlcpy(group, aw->group, sizeof(group)); - break; + if (xu_getprop(cc, _CWM_GRP, XA_STRING, + (CALMWM_MAXNAMELEN - 1)/sizeof(long), &grpstr) > 0) { + strlcpy(group, grpstr, sizeof(group)); + XFree(grpstr); + } else { + TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { + if (strcmp(aw->class, cc->app_class) == 0 && + (aw->name == NULL || + strcmp(aw->name, cc->app_name) == 0)) { + strlcpy(group, aw->group, sizeof(group)); + break; + } } } |