From c307e37dcb8f280e0c3c51248e71e4292e62631d Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 13 Feb 2019 15:43:24 +0000 Subject: [PATCH 1/6] fix missing includes --- conf.c | 1 - kbfunc.c | 1 + util.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index b18dc4a..f15598d 100644 --- a/conf.c +++ b/conf.c @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/kbfunc.c b/kbfunc.c index 4fc0b4d..2574954 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/util.c b/util.c index 575d6b2..09135a4 100644 --- a/util.c +++ b/util.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include From 044ef5a8cd71dc8935ba40015d3583d231d0bf27 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 22 Feb 2019 14:39:18 +0000 Subject: [PATCH 2/6] Limit vtile/htile actions to clients fully within the screen of master client. from Charles A Daniels. --- client.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/client.c b/client.c index ff20290..2819bf2 100644 --- a/client.c +++ b/client.c @@ -986,19 +986,23 @@ client_htile(struct client_ctx *cc) return; i = n = 0; + area = screen_area(sc, + cc->geom.x + cc->geom.w / 2, + cc->geom.y + cc->geom.h / 2, CWM_GAP); + TAILQ_FOREACH(ci, &gc->clientq, group_entry) { if (ci->flags & CLIENT_HIDDEN || - ci->flags & CLIENT_IGNORE || (ci == cc)) + ci->flags & CLIENT_IGNORE || (ci == cc) || + ci->geom.x < area.x || + ci->geom.x > (area.x + area.w) || + ci->geom.y < area.y || + ci->geom.y > (area.y + area.h)) continue; n++; } if (n == 0) return; - area = screen_area(sc, - cc->geom.x + cc->geom.w / 2, - cc->geom.y + cc->geom.h / 2, CWM_GAP); - if (cc->flags & CLIENT_VMAXIMIZED || cc->geom.h + (cc->bwidth * 2) >= area.h) return; @@ -1017,7 +1021,11 @@ client_htile(struct client_ctx *cc) h = area.h - mh; TAILQ_FOREACH(ci, &gc->clientq, group_entry) { if (ci->flags & CLIENT_HIDDEN || - ci->flags & CLIENT_IGNORE || (ci == cc)) + ci->flags & CLIENT_IGNORE || (ci == cc) || + ci->geom.x < area.x || + ci->geom.x > (area.x + area.w) || + ci->geom.y < area.y || + ci->geom.y > (area.y + area.h)) continue; ci->bwidth = Conf.bwidth; ci->geom.x = x; @@ -1044,21 +1052,26 @@ client_vtile(struct client_ctx *cc) if (!gc) return; + + area = screen_area(sc, + cc->geom.x + cc->geom.w / 2, + cc->geom.y + cc->geom.h / 2, CWM_GAP); + i = n = 0; TAILQ_FOREACH(ci, &gc->clientq, group_entry) { if (ci->flags & CLIENT_HIDDEN || - ci->flags & CLIENT_IGNORE || (ci == cc)) + ci->flags & CLIENT_IGNORE || (ci == cc) || + ci->geom.x < area.x || + ci->geom.x > (area.x + area.w) || + ci->geom.y < area.y || + ci->geom.y > (area.y + area.h)) continue; n++; } if (n == 0) return; - area = screen_area(sc, - cc->geom.x + cc->geom.w / 2, - cc->geom.y + cc->geom.h / 2, CWM_GAP); - if (cc->flags & CLIENT_HMAXIMIZED || cc->geom.w + (cc->bwidth * 2) >= area.w) return; @@ -1077,7 +1090,11 @@ client_vtile(struct client_ctx *cc) w = area.w - mw; TAILQ_FOREACH(ci, &gc->clientq, group_entry) { if (ci->flags & CLIENT_HIDDEN || - ci->flags & CLIENT_IGNORE || (ci == cc)) + ci->flags & CLIENT_IGNORE || (ci == cc) || + ci->geom.x < area.x || + ci->geom.x > (area.x + area.w) || + ci->geom.y < area.y || + ci->geom.y > (area.y + area.h)) continue; ci->bwidth = Conf.bwidth; ci->geom.x = area.x + mw; From 535cf541c8fb229d3223dbed5da3b6400a12abe6 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 22 Feb 2019 19:40:32 +0000 Subject: [PATCH 3/6] Rename internal functions to delinate between client remove, delete and xproto delete; 'window-close' is now the proper action, but 'window-delete' as an alias will remain until more interesting changes require breaking configs. --- calmwm.h | 6 +++--- client.c | 4 ++-- conf.c | 5 +++-- cwm.1 | 2 +- cwmrc.5 | 4 ++-- kbfunc.c | 4 ++-- xevents.c | 6 +++--- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/calmwm.h b/calmwm.h index f007a04..44d7f62 100644 --- a/calmwm.h +++ b/calmwm.h @@ -401,7 +401,7 @@ void client_applysizehints(struct client_ctx *); void client_config(struct client_ctx *); struct client_ctx *client_current(void); void client_cycle(struct screen_ctx *, int); -void client_delete(struct client_ctx *); +void client_remove(struct client_ctx *); void client_draw_border(struct client_ctx *); struct client_ctx *client_find(Window); long client_get_wm_state(struct client_ctx *); @@ -419,7 +419,7 @@ void client_ptrsave(struct client_ctx *); void client_ptrwarp(struct client_ctx *); void client_raise(struct client_ctx *); void client_resize(struct client_ctx *, int); -void client_send_delete(struct client_ctx *); +void client_close(struct client_ctx *); void client_set_wm_state(struct client_ctx *, long); void client_setactive(struct client_ctx *); void client_setname(struct client_ctx *); @@ -490,7 +490,7 @@ void kbfunc_ptrmove(void *, struct cargs *); void kbfunc_client_snap(void *, struct cargs *); void kbfunc_client_move(void *, struct cargs *); void kbfunc_client_resize(void *, struct cargs *); -void kbfunc_client_delete(void *, struct cargs *); +void kbfunc_client_close(void *, struct cargs *); void kbfunc_client_lower(void *, struct cargs *); void kbfunc_client_raise(void *, struct cargs *); void kbfunc_client_hide(void *, struct cargs *); diff --git a/client.c b/client.c index 2819bf2..5303832 100644 --- a/client.c +++ b/client.c @@ -170,7 +170,7 @@ client_find(Window win) } void -client_delete(struct client_ctx *cc) +client_remove(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; struct winname *wn; @@ -636,7 +636,7 @@ client_msg(struct client_ctx *cc, Atom proto, Time ts) } void -client_send_delete(struct client_ctx *cc) +client_close(struct client_ctx *cc) { if (cc->flags & CLIENT_WM_DELETE_WINDOW) client_msg(cc, cwmh[WM_DELETE_WINDOW], CurrentTime); diff --git a/conf.c b/conf.c index f15598d..5d75bac 100644 --- a/conf.c +++ b/conf.c @@ -67,7 +67,8 @@ static const struct { { FUNC_CC(window-lower, client_lower, 0) }, { FUNC_CC(window-raise, client_raise, 0) }, { FUNC_CC(window-hide, client_hide, 0) }, - { FUNC_CC(window-delete, client_delete, 0) }, + { FUNC_CC(window-close, client_close, 0) }, + { FUNC_CC(window-delete, client_close, 0) }, { FUNC_CC(window-htile, client_htile, 0) }, { FUNC_CC(window-vtile, client_vtile, 0) }, { FUNC_CC(window-stick, client_toggle_sticky, 0) }, @@ -194,7 +195,7 @@ static const struct { { "M-Tab", "window-cycle" }, { "MS-Tab", "window-rcycle" }, { "CM-n", "window-menu-label" }, - { "CM-x", "window-delete" }, + { "CM-x", "window-close" }, { "CM-a", "group-toggle-all" }, { "CM-0", "group-toggle-all" }, { "CM-1", "group-toggle-1" }, diff --git a/cwm.1 b/cwm.1 index bf6c573..a603100 100644 --- a/cwm.1 +++ b/cwm.1 @@ -100,7 +100,7 @@ Cycle through currently visible windows. .It Ic MS-Tab Reverse cycle through currently visible windows. .It Ic CM-x -Delete current window. +Close current window. .It Ic CM-[n] Toggle visibility of group n, where n is 1-9. .It Ic CM-a diff --git a/cwmrc.5 b/cwmrc.5 index 2e16850..609202e 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -306,8 +306,8 @@ Reverse cycle through windows. Forward cycle through windows in current group. .It window-rcycle-ingroup Reverse cycle through windows in current group. -.It window-delete -Delete current window. +.It window-close +Close current window. .It window-hide Hide current window. .It window-lower diff --git a/kbfunc.c b/kbfunc.c index 2574954..55d206d 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -324,9 +324,9 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs) } void -kbfunc_client_delete(void *ctx, struct cargs *cargs) +kbfunc_client_close(void *ctx, struct cargs *cargs) { - client_send_delete(ctx); + client_close(ctx); } void diff --git a/xevents.c b/xevents.c index e192400..8fd65ff 100644 --- a/xevents.c +++ b/xevents.c @@ -102,7 +102,7 @@ xev_handle_unmapnotify(XEvent *ee) client_set_wm_state(cc, WithdrawnState); } else { if (!(cc->flags & CLIENT_HIDDEN)) - client_delete(cc); + client_remove(cc); } } } @@ -116,7 +116,7 @@ xev_handle_destroynotify(XEvent *ee) LOG_DEBUG3("window: 0x%lx", e->window); if ((cc = client_find(e->window)) != NULL) - client_delete(cc); + client_remove(cc); } static void @@ -389,7 +389,7 @@ xev_handle_clientmessage(XEvent *ee) } } else if (e->message_type == ewmh[_NET_CLOSE_WINDOW]) { if ((cc = client_find(e->window)) != NULL) { - client_send_delete(cc); + client_close(cc); } } else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) { if ((cc = client_find(e->window)) != NULL) { From 953cf1ce89525d9c64bb4b484195def605632422 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 22 Feb 2019 20:52:13 +0000 Subject: [PATCH 4/6] restore order from before r1.248 (vtile/vtile containment changes). --- client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.c b/client.c index 5303832..b5b79cb 100644 --- a/client.c +++ b/client.c @@ -1052,13 +1052,12 @@ client_vtile(struct client_ctx *cc) if (!gc) return; + i = n = 0; area = screen_area(sc, cc->geom.x + cc->geom.w / 2, cc->geom.y + cc->geom.h / 2, CWM_GAP); - i = n = 0; - TAILQ_FOREACH(ci, &gc->clientq, group_entry) { if (ci->flags & CLIENT_HIDDEN || ci->flags & CLIENT_IGNORE || (ci == cc) || From 43cd19378ed244f9bd9f86e51bca0f3905055bdf Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 23 Feb 2019 19:17:17 +0000 Subject: [PATCH 5/6] simplify screen 'area' usage for initial client placement --- client.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/client.c b/client.c index b5b79cb..46c70c1 100644 --- a/client.c +++ b/client.c @@ -754,7 +754,6 @@ static void client_placecalc(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - int xslack, yslack; if (cc->hint.flags & (USPosition | PPosition)) { if (cc->geom.x >= sc->view.w) @@ -772,33 +771,29 @@ client_placecalc(struct client_ctx *cc) cc->geom.y += cc->obwidth * 2; } } else { - struct geom area; - int xmouse, ymouse; + struct geom area; + int xmouse, ymouse, xslack, yslack; xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); area = screen_area(sc, xmouse, ymouse, CWM_GAP); - area.w += area.x; - area.h += area.y; - xmouse = MAX(xmouse, area.x) - cc->geom.w / 2; - ymouse = MAX(ymouse, area.y) - cc->geom.h / 2; - xmouse = MAX(xmouse, area.x); - ymouse = MAX(ymouse, area.y); + xmouse = MAX(MAX(xmouse, area.x) - cc->geom.w / 2, area.x); + ymouse = MAX(MAX(ymouse, area.y) - cc->geom.h / 2, area.y); - xslack = area.w - cc->geom.w - cc->bwidth * 2; - yslack = area.h - cc->geom.h - cc->bwidth * 2; + xslack = area.x + area.w - cc->geom.w - cc->bwidth * 2; + yslack = area.y + area.h - cc->geom.h - cc->bwidth * 2; if (xslack >= area.x) { cc->geom.x = MAX(MIN(xmouse, xslack), area.x); } else { cc->geom.x = area.x; - cc->geom.w = area.w; + cc->geom.w = area.x + area.w; } if (yslack >= area.y) { cc->geom.y = MAX(MIN(ymouse, yslack), area.y); } else { cc->geom.y = area.y; - cc->geom.h = area.h; + cc->geom.h = area.y + area.h; } } } From a5ba9aa9da9567244d1c3d1d8ccacfdb51b044de Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 25 Feb 2019 16:40:49 +0000 Subject: [PATCH 6/6] Add 'group-close-[n]' action to close all windows within specified group. heavily based on a diff from Nam Nguyen. --- calmwm.h | 2 ++ conf.c | 9 +++++++++ cwmrc.5 | 2 ++ group.c | 17 +++++++++++++++++ kbfunc.c | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/calmwm.h b/calmwm.h index 44d7f62..15dd247 100644 --- a/calmwm.h +++ b/calmwm.h @@ -451,6 +451,7 @@ int group_holds_only_sticky(struct group_ctx *); void group_init(struct screen_ctx *, int); void group_movetogroup(struct client_ctx *, int); void group_only(struct screen_ctx *, int); +void group_close(struct screen_ctx *, int); int group_restore(struct client_ctx *); void group_show(struct group_ctx *); void group_toggle_membership(struct client_ctx *); @@ -508,6 +509,7 @@ void kbfunc_client_toggle_group(void *, struct cargs *); void kbfunc_client_movetogroup(void *, struct cargs *); void kbfunc_group_toggle(void *, struct cargs *); void kbfunc_group_only(void *, struct cargs *); +void kbfunc_group_close(void *, struct cargs *); void kbfunc_group_cycle(void *, struct cargs *); void kbfunc_group_alltoggle(void *, struct cargs *); void kbfunc_menu_client(void *, struct cargs *); diff --git a/conf.c b/conf.c index 5d75bac..e54f96a 100644 --- a/conf.c +++ b/conf.c @@ -143,6 +143,15 @@ static const struct { { FUNC_SC(group-only-7, group_only, 7) }, { FUNC_SC(group-only-8, group_only, 8) }, { FUNC_SC(group-only-9, group_only, 9) }, + { FUNC_SC(group-close-1, group_close, 1) }, + { FUNC_SC(group-close-2, group_close, 2) }, + { FUNC_SC(group-close-3, group_close, 3) }, + { FUNC_SC(group-close-4, group_close, 4) }, + { FUNC_SC(group-close-5, group_close, 5) }, + { FUNC_SC(group-close-6, group_close, 6) }, + { FUNC_SC(group-close-7, group_close, 7) }, + { FUNC_SC(group-close-8, group_close, 8) }, + { FUNC_SC(group-close-9, group_close, 9) }, { FUNC_SC(pointer-move-up, ptrmove, (CWM_UP)) }, { FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) }, diff --git a/cwmrc.5 b/cwmrc.5 index 609202e..7434d66 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -288,6 +288,8 @@ menu. Toggle visibility of group n, where n is 1-9. .It group-only-[n] Show only group n, where n is 1-9, hiding other groups. +.It group-close-[n] +Close all windows in group n, where n is 1-9. .It group-toggle-all Toggle visibility of all groups. .It window-group diff --git a/group.c b/group.c index 4c25bcc..30fe718 100644 --- a/group.c +++ b/group.c @@ -249,6 +249,23 @@ group_only(struct screen_ctx *sc, int idx) } } +void +group_close(struct screen_ctx *sc, int idx) +{ + struct group_ctx *gc; + struct client_ctx *cc; + + if (idx < 0 || idx >= Conf.ngroups) + return; + + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (gc->num == idx) { + TAILQ_FOREACH(cc, &gc->clientq, group_entry) + client_close(cc); + } + } +} + void group_cycle(struct screen_ctx *sc, int flags) { diff --git a/kbfunc.c b/kbfunc.c index 55d206d..35b9b22 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -440,6 +440,12 @@ kbfunc_group_only(void *ctx, struct cargs *cargs) group_only(ctx, cargs->flag); } +void +kbfunc_group_close(void *ctx, struct cargs *cargs) +{ + group_close(ctx, cargs->flag); +} + void kbfunc_group_cycle(void *ctx, struct cargs *cargs) {