diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-01-27 00:42:54 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-01-27 00:42:54 +0000 |
commit | 12bb7c96c370dcaef400976aabcb8cf3794fdf68 (patch) | |
tree | 66555eb85ae2f54dfcd66dc29da538ef3cdd71be /app | |
parent | 3962a2a3034d3b39442d526c64a8f93b02f25b09 (diff) |
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 'app')
-rw-r--r-- | app/cwm/calmwm.h | 6 | ||||
-rw-r--r-- | app/cwm/group.c | 29 | ||||
-rw-r--r-- | app/cwm/xutil.c | 5 |
3 files changed, 29 insertions, 11 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index a800ca4c6..ec9376885 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -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. * - * $Id: calmwm.h,v 1.80 2009/01/23 19:00:59 okan Exp $ + * $Id: calmwm.h,v 1.81 2009/01/27 00:42:53 oga Exp $ */ #ifndef _CALMWM_H_ @@ -140,6 +140,7 @@ extern const char *shortcut_to_name[]; struct group_ctx { TAILQ_ENTRY(group_ctx) entry; struct client_ctx_q clients; + const char *name; int shortcut; int hidden; int nhidden; @@ -523,7 +524,8 @@ extern struct conf Conf; #define WM_TAKE_FOCUS cwm_atoms[2] #define WM_PROTOCOLS cwm_atoms[3] #define _MOTIF_WM_HINTS cwm_atoms[4] -#define CWM_NO_ATOMS 5 +#define _CWM_GRP cwm_atoms[5] +#define CWM_NO_ATOMS 6 extern Atom cwm_atoms[CWM_NO_ATOMS]; diff --git a/app/cwm/group.c b/app/cwm/group.c index 0929b4966..ffe6b5f6f 100644 --- a/app/cwm/group.c +++ b/app/cwm/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. * - * $Id: group.c,v 1.22 2009/01/16 15:24:14 okan Exp $ + * $Id: group.c,v 1.23 2009/01/27 00:42:53 oga Exp $ */ #include "headers.h" @@ -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; + } } } diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c index b0b11fd59..db9fe8cff 100644 --- a/app/cwm/xutil.c +++ b/app/cwm/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. * - * $Id: xutil.c,v 1.13 2009/01/23 20:07:20 oga Exp $ + * $Id: xutil.c,v 1.14 2009/01/27 00:42:53 oga Exp $ */ #include "headers.h" @@ -175,7 +175,8 @@ char *atoms[CWM_NO_ATOMS] = { "WM_DELETE_WINDOW", "WM_TAKE_FOCUS", "WM_PROTOCOLS", - "_MOTIF_WM_HINTS" + "_MOTIF_WM_HINTS", + "_CWM_GRP", }; void |