diff --git a/calmwm.h b/calmwm.h index 8e44228..01b560a 100644 --- a/calmwm.h +++ b/calmwm.h @@ -422,7 +422,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 *); @@ -440,7 +440,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 *); @@ -472,6 +472,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 *); @@ -511,7 +512,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 *); @@ -529,6 +530,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/client.c b/client.c index 8794f28..d7d34c4 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); @@ -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; } } } @@ -986,19 +981,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 +1016,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; @@ -1046,19 +1049,23 @@ client_vtile(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_HMAXIMIZED || cc->geom.w + (cc->bwidth * 2) >= area.w) return; @@ -1077,7 +1084,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; diff --git a/conf.c b/conf.c index d6d88d2..22d4fc5 100644 --- a/conf.c +++ b/conf.c @@ -20,7 +20,6 @@ #include #include "queue.h" -#include #include #include @@ -68,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) }, @@ -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)) }, @@ -195,7 +204,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..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 @@ -306,8 +308,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/group.c b/group.c index 124f778..3088ae7 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 b6fb13e..3da28c3 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -23,6 +23,7 @@ #include #include "queue.h" +#include #include #include @@ -326,9 +327,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 @@ -442,6 +443,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) { diff --git a/util.c b/util.c index 9119cc2..0fa8e9d 100644 --- a/util.c +++ b/util.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/xevents.c b/xevents.c index e5c76fe..8b29315 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) {