cvsimport

* refs/heads/master:
  Add 'group-close-[n]' action to close all windows within specified group.
  simplify screen 'area' usage for initial client placement
  restore order from before r1.248 (vtile/vtile containment changes).
  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.
  Limit vtile/htile actions to clients fully within the screen of master client.
  fix missing includes
This commit is contained in:
Leah Neukirchen 2019-02-25 19:45:12 +01:00
commit f4286ad453
9 changed files with 90 additions and 41 deletions

View File

@ -422,7 +422,7 @@ void client_applysizehints(struct client_ctx *);
void client_config(struct client_ctx *); void client_config(struct client_ctx *);
struct client_ctx *client_current(void); struct client_ctx *client_current(void);
void client_cycle(struct screen_ctx *, int); 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 *); void client_draw_border(struct client_ctx *);
struct client_ctx *client_find(Window); struct client_ctx *client_find(Window);
long client_get_wm_state(struct client_ctx *); 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_ptrwarp(struct client_ctx *);
void client_raise(struct client_ctx *); void client_raise(struct client_ctx *);
void client_resize(struct client_ctx *, int); 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_set_wm_state(struct client_ctx *, long);
void client_setactive(struct client_ctx *); void client_setactive(struct client_ctx *);
void client_setname(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_init(struct screen_ctx *, int);
void group_movetogroup(struct client_ctx *, int); void group_movetogroup(struct client_ctx *, int);
void group_only(struct screen_ctx *, int); void group_only(struct screen_ctx *, int);
void group_close(struct screen_ctx *, int);
int group_restore(struct client_ctx *); int group_restore(struct client_ctx *);
void group_show(struct group_ctx *); void group_show(struct group_ctx *);
void group_toggle_membership(struct client_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_snap(void *, struct cargs *);
void kbfunc_client_move(void *, struct cargs *); void kbfunc_client_move(void *, struct cargs *);
void kbfunc_client_resize(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_lower(void *, struct cargs *);
void kbfunc_client_raise(void *, struct cargs *); void kbfunc_client_raise(void *, struct cargs *);
void kbfunc_client_hide(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_client_movetogroup(void *, struct cargs *);
void kbfunc_group_toggle(void *, struct cargs *); void kbfunc_group_toggle(void *, struct cargs *);
void kbfunc_group_only(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_cycle(void *, struct cargs *);
void kbfunc_group_alltoggle(void *, struct cargs *); void kbfunc_group_alltoggle(void *, struct cargs *);
void kbfunc_menu_client(void *, struct cargs *); void kbfunc_menu_client(void *, struct cargs *);

View File

@ -170,7 +170,7 @@ client_find(Window win)
} }
void void
client_delete(struct client_ctx *cc) client_remove(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct winname *wn; struct winname *wn;
@ -636,7 +636,7 @@ client_msg(struct client_ctx *cc, Atom proto, Time ts)
} }
void void
client_send_delete(struct client_ctx *cc) client_close(struct client_ctx *cc)
{ {
if (cc->flags & CLIENT_WM_DELETE_WINDOW) if (cc->flags & CLIENT_WM_DELETE_WINDOW)
client_msg(cc, cwmh[WM_DELETE_WINDOW], CurrentTime); client_msg(cc, cwmh[WM_DELETE_WINDOW], CurrentTime);
@ -754,7 +754,6 @@ static void
client_placecalc(struct client_ctx *cc) client_placecalc(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
int xslack, yslack;
if (cc->hint.flags & (USPosition | PPosition)) { if (cc->hint.flags & (USPosition | PPosition)) {
if (cc->geom.x >= sc->view.w) if (cc->geom.x >= sc->view.w)
@ -773,32 +772,28 @@ client_placecalc(struct client_ctx *cc)
} }
} else { } else {
struct geom area; struct geom area;
int xmouse, ymouse; int xmouse, ymouse, xslack, yslack;
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
area = screen_area(sc, xmouse, ymouse, CWM_GAP); 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); xmouse = MAX(MAX(xmouse, area.x) - cc->geom.w / 2, area.x);
ymouse = MAX(ymouse, area.y); ymouse = MAX(MAX(ymouse, area.y) - cc->geom.h / 2, area.y);
xslack = area.w - cc->geom.w - cc->bwidth * 2; xslack = area.x + area.w - cc->geom.w - cc->bwidth * 2;
yslack = area.h - cc->geom.h - cc->bwidth * 2; yslack = area.y + area.h - cc->geom.h - cc->bwidth * 2;
if (xslack >= area.x) { if (xslack >= area.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), area.x); cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
} else { } else {
cc->geom.x = area.x; cc->geom.x = area.x;
cc->geom.w = area.w; cc->geom.w = area.x + area.w;
} }
if (yslack >= area.y) { if (yslack >= area.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), area.y); cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
} else { } else {
cc->geom.y = area.y; 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; return;
i = n = 0; 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) { TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN || 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; continue;
n++; n++;
} }
if (n == 0) if (n == 0)
return; 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 || if (cc->flags & CLIENT_VMAXIMIZED ||
cc->geom.h + (cc->bwidth * 2) >= area.h) cc->geom.h + (cc->bwidth * 2) >= area.h)
return; return;
@ -1017,7 +1016,11 @@ client_htile(struct client_ctx *cc)
h = area.h - mh; h = area.h - mh;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) { TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN || 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; continue;
ci->bwidth = Conf.bwidth; ci->bwidth = Conf.bwidth;
ci->geom.x = x; ci->geom.x = x;
@ -1046,19 +1049,23 @@ client_vtile(struct client_ctx *cc)
return; return;
i = n = 0; 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) { TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN || 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; continue;
n++; n++;
} }
if (n == 0) if (n == 0)
return; 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 || if (cc->flags & CLIENT_HMAXIMIZED ||
cc->geom.w + (cc->bwidth * 2) >= area.w) cc->geom.w + (cc->bwidth * 2) >= area.w)
return; return;
@ -1077,7 +1084,11 @@ client_vtile(struct client_ctx *cc)
w = area.w - mw; w = area.w - mw;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) { TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN || 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; continue;
ci->bwidth = Conf.bwidth; ci->bwidth = Conf.bwidth;
ci->geom.x = area.x + mw; ci->geom.x = area.x + mw;

15
conf.c
View File

@ -20,7 +20,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "queue.h" #include "queue.h"
#include <sys/stat.h>
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
@ -68,7 +67,8 @@ static const struct {
{ FUNC_CC(window-lower, client_lower, 0) }, { FUNC_CC(window-lower, client_lower, 0) },
{ FUNC_CC(window-raise, client_raise, 0) }, { FUNC_CC(window-raise, client_raise, 0) },
{ FUNC_CC(window-hide, client_hide, 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-htile, client_htile, 0) },
{ FUNC_CC(window-vtile, client_vtile, 0) }, { FUNC_CC(window-vtile, client_vtile, 0) },
{ FUNC_CC(window-stick, client_toggle_sticky, 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-7, group_only, 7) },
{ FUNC_SC(group-only-8, group_only, 8) }, { FUNC_SC(group-only-8, group_only, 8) },
{ FUNC_SC(group-only-9, group_only, 9) }, { 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-up, ptrmove, (CWM_UP)) },
{ FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) }, { FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) },
@ -195,7 +204,7 @@ static const struct {
{ "M-Tab", "window-cycle" }, { "M-Tab", "window-cycle" },
{ "MS-Tab", "window-rcycle" }, { "MS-Tab", "window-rcycle" },
{ "CM-n", "window-menu-label" }, { "CM-n", "window-menu-label" },
{ "CM-x", "window-delete" }, { "CM-x", "window-close" },
{ "CM-a", "group-toggle-all" }, { "CM-a", "group-toggle-all" },
{ "CM-0", "group-toggle-all" }, { "CM-0", "group-toggle-all" },
{ "CM-1", "group-toggle-1" }, { "CM-1", "group-toggle-1" },

2
cwm.1
View File

@ -100,7 +100,7 @@ Cycle through currently visible windows.
.It Ic MS-Tab .It Ic MS-Tab
Reverse cycle through currently visible windows. Reverse cycle through currently visible windows.
.It Ic CM-x .It Ic CM-x
Delete current window. Close current window.
.It Ic CM-[n] .It Ic CM-[n]
Toggle visibility of group n, where n is 1-9. Toggle visibility of group n, where n is 1-9.
.It Ic CM-a .It Ic CM-a

View File

@ -288,6 +288,8 @@ menu.
Toggle visibility of group n, where n is 1-9. Toggle visibility of group n, where n is 1-9.
.It group-only-[n] .It group-only-[n]
Show only group n, where n is 1-9, hiding other groups. 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 .It group-toggle-all
Toggle visibility of all groups. Toggle visibility of all groups.
.It window-group .It window-group
@ -306,8 +308,8 @@ Reverse cycle through windows.
Forward cycle through windows in current group. Forward cycle through windows in current group.
.It window-rcycle-ingroup .It window-rcycle-ingroup
Reverse cycle through windows in current group. Reverse cycle through windows in current group.
.It window-delete .It window-close
Delete current window. Close current window.
.It window-hide .It window-hide
Hide current window. Hide current window.
.It window-lower .It window-lower

17
group.c
View File

@ -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 void
group_cycle(struct screen_ctx *sc, int flags) group_cycle(struct screen_ctx *sc, int flags)
{ {

View File

@ -23,6 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#include "queue.h" #include "queue.h"
#include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <err.h> #include <err.h>
@ -326,9 +327,9 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs)
} }
void 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 void
@ -442,6 +443,12 @@ kbfunc_group_only(void *ctx, struct cargs *cargs)
group_only(ctx, cargs->flag); group_only(ctx, cargs->flag);
} }
void
kbfunc_group_close(void *ctx, struct cargs *cargs)
{
group_close(ctx, cargs->flag);
}
void void
kbfunc_group_cycle(void *ctx, struct cargs *cargs) kbfunc_group_cycle(void *ctx, struct cargs *cargs)
{ {

1
util.c
View File

@ -24,6 +24,7 @@
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -102,7 +102,7 @@ xev_handle_unmapnotify(XEvent *ee)
client_set_wm_state(cc, WithdrawnState); client_set_wm_state(cc, WithdrawnState);
} else { } else {
if (!(cc->flags & CLIENT_HIDDEN)) 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); LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL) if ((cc = client_find(e->window)) != NULL)
client_delete(cc); client_remove(cc);
} }
static void static void
@ -389,7 +389,7 @@ xev_handle_clientmessage(XEvent *ee)
} }
} else if (e->message_type == ewmh[_NET_CLOSE_WINDOW]) { } else if (e->message_type == ewmh[_NET_CLOSE_WINDOW]) {
if ((cc = client_find(e->window)) != NULL) { if ((cc = client_find(e->window)) != NULL) {
client_send_delete(cc); client_close(cc);
} }
} else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) { } else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) {
if ((cc = client_find(e->window)) != NULL) { if ((cc = client_find(e->window)) != NULL) {