From 4cf9a34b65cbb495088d33fd16dd68400ded62c0 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 1 Sep 2016 18:34:04 +0000 Subject: [PATCH 01/10] Remove redundant minimum client size adjustment (minw and minh are always positive since r1.214); from Vadim Vygonets. --- client.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/client.c b/client.c index bb8f8dc..322b889 100644 --- a/client.c +++ b/client.c @@ -898,9 +898,6 @@ client_applysizehints(struct client_ctx *cc) if (cc->hint.maxh) cc->geom.h = MIN(cc->geom.h, cc->hint.maxh); - cc->geom.w = MAX(cc->geom.w, 1); - cc->geom.h = MAX(cc->geom.h, 1); - cc->dim.w = (cc->geom.w - cc->hint.basew) / cc->hint.incw; cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch; } From 44f3fefe1135a5ca9e7f662cf9d7321fee174615 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 1 Sep 2016 18:38:52 +0000 Subject: [PATCH 02/10] Do not draw borders on ignored clients when returning from fullscreen; from Vadim Vygonets. --- client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index 322b889..fb3fe31 100644 --- a/client.c +++ b/client.c @@ -297,7 +297,8 @@ client_toggle_fullscreen(struct client_ctx *cc) return; if (cc->flags & CLIENT_FULLSCREEN) { - cc->bwidth = Conf.bwidth; + if (!(cc->flags & CLIENT_IGNORE)) + cc->bwidth = Conf.bwidth; cc->geom = cc->fullgeom; cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE); goto resize; From 67a9eaa440ddc535fc7707883baca9f263cf4ae8 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 2 Sep 2016 15:08:44 +0000 Subject: [PATCH 03/10] Simplify toggling flags; from Vadim Vygonets. --- client.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/client.c b/client.c index fb3fe31..7a073c8 100644 --- a/client.c +++ b/client.c @@ -256,33 +256,21 @@ client_toggle_freeze(struct client_ctx *cc) if (cc->flags & CLIENT_FULLSCREEN) return; - if (cc->flags & CLIENT_FREEZE) - cc->flags &= ~CLIENT_FREEZE; - else - cc->flags |= CLIENT_FREEZE; - + cc->flags ^= CLIENT_FREEZE; xu_ewmh_set_net_wm_state(cc); } void client_toggle_hidden(struct client_ctx *cc) { - if (cc->flags & CLIENT_HIDDEN) - cc->flags &= ~CLIENT_HIDDEN; - else - cc->flags |= CLIENT_HIDDEN; - + cc->flags ^= CLIENT_HIDDEN; xu_ewmh_set_net_wm_state(cc); } void client_toggle_sticky(struct client_ctx *cc) { - if (cc->flags & CLIENT_STICKY) - cc->flags &= ~CLIENT_STICKY; - else - cc->flags |= CLIENT_STICKY; - + cc->flags ^= CLIENT_STICKY; xu_ewmh_set_net_wm_state(cc); } From c82c3f08356d4debd69f1f15be3fc065a2010b8e Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 2 Sep 2016 16:07:11 +0000 Subject: [PATCH 04/10] Simplify group_holds_only_hidden(); from Vadim Vygonets. --- group.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/group.c b/group.c index c39e0f1..81961e7 100644 --- a/group.c +++ b/group.c @@ -209,19 +209,12 @@ int group_holds_only_hidden(struct group_ctx *gc) { struct client_ctx *cc; - int hidden = 0, same = 0; TAILQ_FOREACH(cc, &gc->clientq, group_entry) { - if (cc->flags & CLIENT_STICKY) - continue; - if (hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0)) - same++; + if (!(cc->flags & (CLIENT_HIDDEN | CLIENT_STICKY))) + return(0); } - - if (same == 0) - hidden = !hidden; - - return(hidden); + return(1); } void From b14a4b222d43a798971e62627b862046b540cda9 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 12 Sep 2016 13:47:00 +0000 Subject: [PATCH 05/10] change 'sticky' to 'stick' to toggle client stickiness (seems the default binding worked for everyone for a long time!); conflict with group sticky found by Ali Farzanrad - thanks! --- conf.c | 4 ++-- cwmrc.5 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf.c b/conf.c index a8acb6b..7d7026d 100644 --- a/conf.c +++ b/conf.c @@ -207,7 +207,7 @@ static const struct { { "CM-g", "grouptoggle" }, { "CM-f", "fullscreen" }, { "CM-m", "maximize" }, - { "CM-s", "sticky" }, + { "CM-s", "stick" }, { "CM-equal", "vmaximize" }, { "CMS-equal", "hmaximize" }, { "CMS-f", "freeze" }, @@ -408,7 +408,7 @@ static const struct { {.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} }, { "grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT, {.i = CWM_KBD}}, - { "sticky", kbfunc_client_toggle_sticky, CWM_CONTEXT_CLIENT, {0} }, + { "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CLIENT, {0} }, { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CLIENT, {0} }, { "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} }, diff --git a/cwmrc.5 b/cwmrc.5 index ee8dd78..19a4152 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -301,7 +301,7 @@ Raise current window. Label current window. .It freeze Freeze current window geometry. -.It sticky +.It stick Stick current window to all groups (same as assigning to nogroup). .It fullscreen Full-screen current window (gap + border removed). From e1234b75b8d9ba3dc414af1fc2e04f159a5d6f7e Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 12 Sep 2016 13:48:41 +0000 Subject: [PATCH 06/10] Switch to just malloc since we need initialize most everything anyway. --- client.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client.c b/client.c index 7a073c8..8556395 100644 --- a/client.c +++ b/client.c @@ -67,12 +67,18 @@ client_init(Window win, struct screen_ctx *sc) mapped = wattr.map_state != IsUnmapped; } - cc = xcalloc(1, sizeof(*cc)); + cc = xmalloc(sizeof(*cc)); XGrabServer(X_Dpy); cc->sc = sc; cc->win = win; + cc->gc = NULL; + cc->flags = 0; + cc->stackingorder = 0; + memset(&cc->hint, 0, sizeof(cc->hint)); + cc->ptr.x = -1; + cc->ptr.y = -1; TAILQ_INIT(&cc->nameq); client_setname(cc); @@ -85,10 +91,6 @@ client_init(Window win, struct screen_ctx *sc) client_getsizehints(cc); client_mwm_hints(cc); - /* Saved pointer position */ - cc->ptr.x = -1; - cc->ptr.y = -1; - cc->geom.x = wattr.x; cc->geom.y = wattr.y; cc->geom.w = wattr.width; From a94254137c6916d65be42fb90a9e60c384b8a088 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 13 Sep 2016 13:42:28 +0000 Subject: [PATCH 07/10] Limit mouse resize to hints within the client; matches kbd resize behaviour. --- mousefunc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mousefunc.c b/mousefunc.c index e2f91d4..36f9460 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -57,7 +57,6 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg) XEvent ev; Time ltime = 0; struct screen_ctx *sc = cc->sc; - int x = cc->geom.x, y = cc->geom.y; if (cc->flags & CLIENT_FREEZE) return; @@ -81,12 +80,8 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg) continue; ltime = ev.xmotion.time; - cc->geom.w = abs(x - ev.xmotion.x_root) - cc->bwidth; - cc->geom.h = abs(y - ev.xmotion.y_root) - cc->bwidth; - cc->geom.x = (x <= ev.xmotion.x_root) ? - x : x - cc->geom.w; - cc->geom.y = (y <= ev.xmotion.y_root) ? - y : y - cc->geom.h; + cc->geom.w = ev.xmotion.x; + cc->geom.h = ev.xmotion.y; client_applysizehints(cc); client_resize(cc, 1); mousefunc_sweep_draw(cc); From 9124a561e317d68454ce22c65da47cff10482ce5 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 13 Sep 2016 17:42:58 +0000 Subject: [PATCH 08/10] init label --- client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client.c b/client.c index 8556395..d9c8241 100644 --- a/client.c +++ b/client.c @@ -73,6 +73,7 @@ client_init(Window win, struct screen_ctx *sc) cc->sc = sc; cc->win = win; + cc->label = NULL; cc->gc = NULL; cc->flags = 0; cc->stackingorder = 0; From b8933ebccaba603c47d15026ed22a2afabbd9d67 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 14 Sep 2016 19:45:33 +0000 Subject: [PATCH 09/10] Fix-up a few simple uses of client_current(): check CLIENT_ACTIVE flag instead of relying on curcc. --- client.c | 12 ++++++------ search.c | 4 ++-- xevents.c | 9 ++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client.c b/client.c index d9c8241..b730c78 100644 --- a/client.c +++ b/client.c @@ -176,12 +176,12 @@ client_delete(struct client_ctx *cc) xu_ewmh_net_client_list(sc); xu_ewmh_net_client_list_stacking(sc); + if (cc->flags & CLIENT_ACTIVE) + client_none(sc); + if (cc->gc != NULL) TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry); - if (cc == client_current()) - client_none(sc); - while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { TAILQ_REMOVE(&cc->nameq, wn, entry); free(wn->name); @@ -510,12 +510,12 @@ client_hide(struct client_ctx *cc) { XUnmapWindow(X_Dpy, cc->win); + if (cc->flags & CLIENT_ACTIVE) + client_none(cc->sc); + cc->flags &= ~CLIENT_ACTIVE; cc->flags |= CLIENT_HIDDEN; client_set_wm_state(cc, IconicState); - - if (cc == client_current()) - client_none(cc->sc); } void diff --git a/search.c b/search.c index aa409e0..f52d87d 100644 --- a/search.c +++ b/search.c @@ -94,7 +94,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) * window. Furthermore, this is denoted by a "!" when * printing the window name in the search menu. */ - if (cc == client_current() && tier < nitems(tierp) - 1) + if ((cc->flags & CLIENT_ACTIVE) && (tier < nitems(tierp) - 1)) tier++; /* Clients that are hidden get ranked one up. */ @@ -147,7 +147,7 @@ search_print_client(struct menu *mi, int list) struct client_ctx *cc = (struct client_ctx *)mi->ctx; char flag = ' '; - if (cc == client_current()) + if (cc->flags & CLIENT_ACTIVE) flag = '!'; else if (cc->flags & CLIENT_HIDDEN) flag = '&'; diff --git a/xevents.c b/xevents.c index a3a12c2..8763c8a 100644 --- a/xevents.c +++ b/xevents.c @@ -250,10 +250,13 @@ xev_handle_buttonpress(XEvent *ee) static void xev_handle_buttonrelease(XEvent *ee) { - struct client_ctx *cc; + XButtonEvent *e = &ee->xbutton; + struct client_ctx *cc; - if ((cc = client_current()) != NULL) - group_toggle_membership_leave(cc); + if ((cc = client_find(e->window)) != NULL) { + if (cc->flags & CLIENT_ACTIVE) + group_toggle_membership_leave(cc); + } } static void From 2bbe111cc0e2ddd8b684e22dab337086c39ac46a Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 14 Sep 2016 21:00:24 +0000 Subject: [PATCH 10/10] Some clients fail to setup hints at all, so initalize for them; fallout from r1.218 switching to malloc - clearly missed this case. found the hard way by brynet@ --- client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client.c b/client.c index b730c78..5c2148b 100644 --- a/client.c +++ b/client.c @@ -78,6 +78,7 @@ client_init(Window win, struct screen_ctx *sc) cc->flags = 0; cc->stackingorder = 0; memset(&cc->hint, 0, sizeof(cc->hint)); + memset(&cc->ch, 0, sizeof(cc->ch)); cc->ptr.x = -1; cc->ptr.y = -1;