From 560acb43fca290db3009a0b992c7c7c4a09d4c52 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 29 Nov 2012 04:25:49 +0000 Subject: specific last match for autogroup; few iterations with Kent Spillner. --- group.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'group.c') 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; } } } -- cgit 1.4.1 From 3a3e0383b2b605ede516f4f58eef778bea7815e4 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 17 Dec 2012 14:32:39 +0000 Subject: create and use menuq_clear() helper; from Tiago Cunha --- calmwm.h | 1 + group.c | 5 +---- kbfunc.c | 20 ++++---------------- menu.c | 16 ++++++++++++---- mousefunc.c | 13 +++---------- 5 files changed, 21 insertions(+), 34 deletions(-) (limited to 'group.c') diff --git a/calmwm.h b/calmwm.h index 096a5c4..35bf6c2 100644 --- a/calmwm.h +++ b/calmwm.h @@ -431,6 +431,7 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *, void (*)(struct menu_q *, struct menu_q *, char *), void (*)(struct menu *, int)); void menu_init(struct screen_ctx *); +void menuq_clear(struct menu_q *); int parse_config(const char *, struct conf *); diff --git a/group.c b/group.c index dd96575..1b89825 100644 --- a/group.c +++ b/group.c @@ -385,10 +385,7 @@ group_menu(XButtonEvent *e) (gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc); cleanup: - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } void diff --git a/kbfunc.c b/kbfunc.c index e8ab152..023069d 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -168,10 +168,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg) client_ptrwarp(cc); } - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } void @@ -195,10 +192,7 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg) search_match_text, NULL)) != NULL) u_spawn(((struct cmd *)mi->ctx)->image); - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } void @@ -320,10 +314,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg) out: if (mi != NULL && mi->dummy) free(mi); - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } void @@ -390,10 +381,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg) out: if (mi != NULL && mi->dummy) free(mi); - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } void diff --git a/menu.c b/menu.c index dd6de18..3889d96 100644 --- a/menu.c +++ b/menu.c @@ -215,10 +215,7 @@ menu_complete_path(struct menu_ctx *mc) strlcpy(path, mi->text, sizeof(mi->text)); } - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); if (path[0] != '\0') snprintf(mr->text, sizeof(mr->text), "%s \"%s\"", @@ -632,3 +629,14 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr) return (0); } + +void +menuq_clear(struct menu_q *mq) +{ + struct menu *mi; + + while ((mi = TAILQ_FIRST(mq)) != NULL) { + TAILQ_REMOVE(mq, mi, entry); + free(mi); + } +} diff --git a/mousefunc.c b/mousefunc.c index a342b8e..eb5171a 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -250,12 +250,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) if (old_cc != NULL) client_ptrsave(old_cc); client_ptrwarp(cc); - } else { - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } - } + } else + menuq_clear(&menuq); } void @@ -280,8 +276,5 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg) if (mi != NULL) u_spawn(((struct cmd *)mi->ctx)->image); else - while ((mi = TAILQ_FIRST(&menuq)) != NULL) { - TAILQ_REMOVE(&menuq, mi, entry); - free(mi); - } + menuq_clear(&menuq); } -- cgit 1.4.1 From 82e8ec4245f44bd10c0fc5ed27640dafbb7beb44 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 17 Dec 2012 17:48:57 +0000 Subject: replace client highlight with a client flag --- calmwm.h | 6 +++--- client.c | 7 +++---- group.c | 10 ++++------ 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'group.c') diff --git a/calmwm.h b/calmwm.h index bfef2bd..601ca8f 100644 --- a/calmwm.h +++ b/calmwm.h @@ -159,16 +159,16 @@ struct client_ctx { #define CLIENT_VMAXIMIZED 0x0004 #define CLIENT_HMAXIMIZED 0x0008 #define CLIENT_FREEZE 0x0010 +#define CLIENT_GROUP 0x0020 +#define CLIENT_UNGROUP 0x0040 +#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) #define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) int flags; int state; int active; int stackingorder; -#define CLIENT_HIGHLIGHT_GROUP 0x0001 -#define CLIENT_HIGHLIGHT_UNGROUP 0x0002 - int highlight; struct winname_q nameq; #define CLIENT_MAXNAMEQLEN 5 int nameqlen; diff --git a/client.c b/client.c index 3dd6c70..cae9ba4 100644 --- a/client.c +++ b/client.c @@ -490,7 +490,6 @@ client_unhide(struct client_ctx *cc) { XMapRaised(X_Dpy, cc->win); - cc->highlight = 0; cc->flags &= ~CLIENT_HIDDEN; xu_setstate(cc, NormalState); client_draw_border(cc); @@ -503,11 +502,11 @@ client_draw_border(struct client_ctx *cc) unsigned long pixel; if (cc->active) - switch (cc->highlight) { - case CLIENT_HIGHLIGHT_GROUP: + switch (cc->flags & CLIENT_HIGHLIGHT) { + case CLIENT_GROUP: pixel = sc->color[CWM_COLOR_BORDER_GROUP].pixel; break; - case CLIENT_HIGHLIGHT_UNGROUP: + case CLIENT_UNGROUP: pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel; break; default: diff --git a/group.c b/group.c index 1b89825..847cddd 100644 --- a/group.c +++ b/group.c @@ -218,16 +218,14 @@ void group_sticky_toggle_enter(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - struct group_ctx *gc; - - gc = sc->group_active; + struct group_ctx *gc = sc->group_active; if (gc == cc->group) { group_remove(cc); - cc->highlight = CLIENT_HIGHLIGHT_UNGROUP; + cc->flags |= CLIENT_UNGROUP; } else { group_add(gc, cc); - cc->highlight = CLIENT_HIGHLIGHT_GROUP; + cc->flags |= CLIENT_GROUP; } client_draw_border(cc); @@ -236,7 +234,7 @@ group_sticky_toggle_enter(struct client_ctx *cc) void group_sticky_toggle_exit(struct client_ctx *cc) { - cc->highlight = 0; + cc->flags &= ~CLIENT_HIGHLIGHT; client_draw_border(cc); } -- cgit 1.4.1