From 560acb43fca290db3009a0b992c7c7c4a09d4c52 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 29 Nov 2012 04:25:49 +0000 Subject: [PATCH] specific last match for autogroup; few iterations with Kent Spillner. --- cwmrc.5 | 1 + group.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cwmrc.5 b/cwmrc.5 index 39ab221..4e17dbd 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -50,6 +50,7 @@ or if their name and class properties match and .Ar windowclass , respectively. +The more specific last match wins. .Ar group is a number between 0 and 9. If diff --git a/group.c b/group.c index fd507be..dd96575 100644 --- a/group.c +++ b/group.c @@ -412,7 +412,7 @@ group_autogroup(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; struct autogroupwin *aw; struct group_ctx *gc; - int no = -1; + int no = -1, both_match = 0; long *grpno; if (cc->app_class == NULL || cc->app_name == NULL) @@ -429,11 +429,13 @@ group_autogroup(struct client_ctx *cc) XFree(grpno); } 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)) { - no = aw->num; - break; + if (strcmp(aw->class, cc->app_class) == 0) { + if ((aw->name != NULL) && + (strcmp(aw->name, cc->app_name) == 0)) { + no = aw->num; + both_match = 1; + } else if (aw->name == NULL && !both_match) + no = aw->num; } } }