From 50dd70afc5f37b724ce0f68dd6755faffbb994df Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 24 Apr 2017 12:18:04 +0000 Subject: For {h,v}tile, instead of keeping the master client's {h,v} geometry, expand it to %50 of the area, then fill in the remaining space with the other clients in the same group; from Gerrit Meyerheim. support from ajacoutot. --- client.c | 2 ++ cwmrc.5 | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index 9917a4e..bf9a823 100644 --- a/client.c +++ b/client.c @@ -982,6 +982,7 @@ client_htile(struct client_ctx *cc) cc->flags &= ~CLIENT_HMAXIMIZED; cc->geom.x = area.x; cc->geom.y = area.y; + cc->geom.h = (area.h - (cc->bwidth * 2)) / 2; cc->geom.w = area.w - (cc->bwidth * 2); client_resize(cc, 1); client_ptrwarp(cc); @@ -1042,6 +1043,7 @@ client_vtile(struct client_ctx *cc) cc->geom.x = area.x; cc->geom.y = area.y; cc->geom.h = area.h - (cc->bwidth * 2); + cc->geom.w = (area.w - (cc->bwidth * 2)) / 2; client_resize(cc, 1); client_ptrwarp(cc); diff --git a/cwmrc.5 b/cwmrc.5 index d46dc7f..389083e 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -324,11 +324,13 @@ Vertically maximize current window (gap + border honored). .It window-hmaximize Horizontally maximize current window (gap + border honored). .It window-htile -Current window is placed at the top of the screen and maximized -horizontally, other windows in its group share remaining screen space. +Current window is placed at the top of the screen, maximized +horizontally and resized to half of the vertical screen space. Other +windows in its group share remaining screen space. .It window-vtile -Current window is placed on the left of the screen and maximized -vertically, other windows in its group share remaining screen space. +Current window is placed on the left of the screen, maximized vertically +and resized to half of the horizontal screen space. Other windows in its +group share remaining screen space. .It window-move Move current window. .It window-resize -- cgit 1.4.1 From 9b5632590822eea5d11d0994fd7a6e1a5feffb7a Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 24 Apr 2017 12:27:32 +0000 Subject: Raise the previously focused window, instead of the previous window in the cycle list; seems to match behaviour of other wm's; from Walter Alejandro Iglesias. --- client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index bf9a823..c5c7959 100644 --- a/client.c +++ b/client.c @@ -645,7 +645,7 @@ match: void client_cycle(struct screen_ctx *sc, int flags) { - struct client_ctx *newcc, *oldcc; + struct client_ctx *newcc, *oldcc, *prevcc; int again = 1; /* For X apps that ignore events. */ @@ -655,6 +655,7 @@ client_cycle(struct screen_ctx *sc, int flags) if (TAILQ_EMPTY(&sc->clientq)) return; + prevcc = TAILQ_FIRST(&sc->clientq); oldcc = client_current(); if (oldcc == NULL) oldcc = (flags & CWM_CYCLE_REVERSE) ? @@ -686,6 +687,7 @@ client_cycle(struct screen_ctx *sc, int flags) /* reset when cycling mod is released. XXX I hate this hack */ sc->cycling = 1; client_ptrsave(oldcc); + client_raise(prevcc); client_raise(newcc); if (!client_inbound(newcc, newcc->ptr.x, newcc->ptr.y)) { newcc->ptr.x = newcc->geom.w / 2; -- cgit 1.4.1 From 15a6fcc851d0e04f1a53beec6b2db81109e9a058 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 24 Apr 2017 13:31:19 +0000 Subject: sort --- client.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client.c b/client.c index c5c7959..c16e10f 100644 --- a/client.c +++ b/client.c @@ -958,7 +958,7 @@ client_htile(struct client_ctx *cc) struct group_ctx *gc = cc->gc; struct screen_ctx *sc = cc->sc; struct geom area; - int i, n, mh, x, h, w; + int i, n, mh, x, w, h; if (!gc) return; @@ -984,8 +984,8 @@ client_htile(struct client_ctx *cc) cc->flags &= ~CLIENT_HMAXIMIZED; cc->geom.x = area.x; cc->geom.y = area.y; - cc->geom.h = (area.h - (cc->bwidth * 2)) / 2; cc->geom.w = area.w - (cc->bwidth * 2); + cc->geom.h = (area.h - (cc->bwidth * 2)) / 2; client_resize(cc, 1); client_ptrwarp(cc); @@ -998,16 +998,16 @@ client_htile(struct client_ctx *cc) ci->flags & CLIENT_IGNORE || (ci == cc)) continue; ci->bwidth = Conf.bwidth; - ci->geom.y = area.y + mh; ci->geom.x = x; - ci->geom.h = h - (ci->bwidth * 2); + ci->geom.y = area.y + mh; ci->geom.w = w - (ci->bwidth * 2); + ci->geom.h = h - (ci->bwidth * 2); if (i + 1 == n) ci->geom.w = area.x + area.w - ci->geom.x - (ci->bwidth * 2); x += w; - client_resize(ci, 1); i++; + client_resize(ci, 1); } } @@ -1018,7 +1018,7 @@ client_vtile(struct client_ctx *cc) struct group_ctx *gc = cc->gc; struct screen_ctx *sc = cc->sc; struct geom area; - int i, n, mw, y, h, w; + int i, n, mw, y, w, h; if (!gc) return; @@ -1044,8 +1044,8 @@ client_vtile(struct client_ctx *cc) cc->flags &= ~CLIENT_VMAXIMIZED; cc->geom.x = area.x; cc->geom.y = area.y; - cc->geom.h = area.h - (cc->bwidth * 2); cc->geom.w = (area.w - (cc->bwidth * 2)) / 2; + cc->geom.h = area.h - (cc->bwidth * 2); client_resize(cc, 1); client_ptrwarp(cc); @@ -1058,16 +1058,16 @@ client_vtile(struct client_ctx *cc) ci->flags & CLIENT_IGNORE || (ci == cc)) continue; ci->bwidth = Conf.bwidth; - ci->geom.y = y; ci->geom.x = area.x + mw; - ci->geom.h = h - (ci->bwidth * 2); + ci->geom.y = y; ci->geom.w = w - (ci->bwidth * 2); + ci->geom.h = h - (ci->bwidth * 2); if (i + 1 == n) ci->geom.h = area.y + area.h - ci->geom.y - (ci->bwidth * 2); y += h; - client_resize(ci, 1); i++; + client_resize(ci, 1); } } -- cgit 1.4.1 From 56b44257a56417f038255c340f89eb3df90f1241 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 24 Apr 2017 13:35:25 +0000 Subject: Move queue init to caller so it's only called once in a few cases. --- search.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/search.c b/search.c index f244e7f..1dbf92b 100644 --- a/search.c +++ b/search.c @@ -152,8 +152,6 @@ search_match_path_type(struct menu_q *menuq, struct menu_q *resultq, glob_t g; int i; - TAILQ_INIT(resultq); - (void)strlcpy(pattern, search, sizeof(pattern)); (void)strlcat(pattern, "*", sizeof(pattern)); @@ -170,6 +168,8 @@ search_match_path_type(struct menu_q *menuq, struct menu_q *resultq, void search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search) { + TAILQ_INIT(resultq); + return(search_match_path_type(menuq, resultq, search, PATH_ANY)); } -- cgit 1.4.1 From ffcfff3dea48485f806670b1d34b7a6db1363c8d Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 24 Apr 2017 15:06:11 +0000 Subject: search_match_path() isn't supposed to return anything. --- search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.c b/search.c index 1dbf92b..07e0e15 100644 --- a/search.c +++ b/search.c @@ -170,7 +170,7 @@ search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search) { TAILQ_INIT(resultq); - return(search_match_path_type(menuq, resultq, search, PATH_ANY)); + search_match_path_type(menuq, resultq, search, PATH_ANY); } void -- cgit 1.4.1 From 717e6c8167978bef3ffaba49322724e72cb78ba3 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 25 Apr 2017 12:08:05 +0000 Subject: Remove 'noresult' (and simplify) as it does nothing and makes the logic around it needless. History doesn't show what this might have been used for in future iterations. --- menu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/menu.c b/menu.c index ea5b2dd..b2658d7 100644 --- a/menu.c +++ b/menu.c @@ -52,7 +52,6 @@ struct menu_ctx { int list; int listing; int changed; - int noresult; int prev; int entry; int num; @@ -313,15 +312,10 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq, (void)strlcat(mc->searchstr, chr, sizeof(mc->searchstr)); } - mc->noresult = 0; - if (mc->changed && mc->searchstr[0] != '\0') { - (*mc->match)(menuq, resultq, mc->searchstr); - /* If menuq is empty, never show we've failed */ - mc->noresult = TAILQ_EMPTY(resultq) && !TAILQ_EMPTY(menuq); - } else if (mc->changed) - TAILQ_INIT(resultq); - - if (!mc->list && mc->listing && !mc->changed) { + if (mc->changed) { + if (mc->searchstr[0] != '\0') + (*mc->match)(menuq, resultq, mc->searchstr); + } else if (!mc->list && mc->listing) { TAILQ_INIT(resultq); mc->listing = 0; } -- cgit 1.4.1 From 15b9a8fe27a72e58f1fb488ebf14c3fcae4b98a9 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 25 Apr 2017 13:40:33 +0000 Subject: The r1.36 menuq_add() conversion did this one wrong; fix by reverting to the original code which adds to resultentry list, as opposed to the wrong one in menuq_add(). Fixes crash noticed by at least Rickard Gustafsson. --- search.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/search.c b/search.c index 07e0e15..2f8897d 100644 --- a/search.c +++ b/search.c @@ -148,9 +148,10 @@ static void search_match_path_type(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag) { - char pattern[PATH_MAX]; - glob_t g; - int i; + struct menu *mi; + char pattern[PATH_MAX]; + glob_t g; + int i; (void)strlcpy(pattern, search, sizeof(pattern)); (void)strlcat(pattern, "*", sizeof(pattern)); @@ -160,7 +161,9 @@ search_match_path_type(struct menu_q *menuq, struct menu_q *resultq, for (i = 0; i < g.gl_pathc; i++) { if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK)) continue; - menuq_add(resultq, NULL, "%s", g.gl_pathv[i]); + mi = xcalloc(1, sizeof(*mi)); + (void)strlcpy(mi->text, g.gl_pathv[i], sizeof(mi->text)); + TAILQ_INSERT_TAIL(resultq, mi, resultentry); } globfree(&g); } -- cgit 1.4.1