cvsimport

* refs/heads/master:
  Some clients fail to setup hints at all, so initalize for them; fallout from r1.218 switching to malloc - clearly missed this case.
  Fix-up a few simple uses of client_current(): check CLIENT_ACTIVE flag instead of relying on curcc.
  init label
  Limit mouse resize to hints within the client; matches kbd resize behaviour.
  Switch to just malloc since we need initialize most everything anyway.
  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!
  Simplify group_holds_only_hidden(); from Vadim Vygonets.
  Simplify toggling flags; from Vadim Vygonets.
  Do not draw borders on ignored clients when returning from fullscreen; from Vadim Vygonets.
  Remove redundant minimum client size adjustment (minw and minh are always positive since r1.214); from Vadim Vygonets.
This commit is contained in:
okan 2016-09-14 21:00:24 +00:00
commit 8d44e4b3e8
7 changed files with 36 additions and 55 deletions

View File

@ -67,12 +67,20 @@ client_init(Window win, struct screen_ctx *sc)
mapped = wattr.map_state != IsUnmapped; mapped = wattr.map_state != IsUnmapped;
} }
cc = xcalloc(1, sizeof(*cc)); cc = xmalloc(sizeof(*cc));
XGrabServer(X_Dpy); XGrabServer(X_Dpy);
cc->sc = sc; cc->sc = sc;
cc->win = win; cc->win = win;
cc->label = NULL;
cc->gc = NULL;
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;
TAILQ_INIT(&cc->nameq); TAILQ_INIT(&cc->nameq);
client_setname(cc); client_setname(cc);
@ -85,10 +93,6 @@ client_init(Window win, struct screen_ctx *sc)
client_getsizehints(cc); client_getsizehints(cc);
client_mwm_hints(cc); client_mwm_hints(cc);
/* Saved pointer position */
cc->ptr.x = -1;
cc->ptr.y = -1;
cc->geom.x = wattr.x; cc->geom.x = wattr.x;
cc->geom.y = wattr.y; cc->geom.y = wattr.y;
cc->geom.w = wattr.width; cc->geom.w = wattr.width;
@ -173,12 +177,12 @@ client_delete(struct client_ctx *cc)
xu_ewmh_net_client_list(sc); xu_ewmh_net_client_list(sc);
xu_ewmh_net_client_list_stacking(sc); xu_ewmh_net_client_list_stacking(sc);
if (cc->flags & CLIENT_ACTIVE)
client_none(sc);
if (cc->gc != NULL) if (cc->gc != NULL)
TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry); TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry);
if (cc == client_current())
client_none(sc);
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
TAILQ_REMOVE(&cc->nameq, wn, entry); TAILQ_REMOVE(&cc->nameq, wn, entry);
free(wn->name); free(wn->name);
@ -256,33 +260,21 @@ client_toggle_freeze(struct client_ctx *cc)
if (cc->flags & CLIENT_FULLSCREEN) if (cc->flags & CLIENT_FULLSCREEN)
return; return;
if (cc->flags & CLIENT_FREEZE) cc->flags ^= CLIENT_FREEZE;
cc->flags &= ~CLIENT_FREEZE;
else
cc->flags |= CLIENT_FREEZE;
xu_ewmh_set_net_wm_state(cc); xu_ewmh_set_net_wm_state(cc);
} }
void void
client_toggle_hidden(struct client_ctx *cc) client_toggle_hidden(struct client_ctx *cc)
{ {
if (cc->flags & CLIENT_HIDDEN) cc->flags ^= CLIENT_HIDDEN;
cc->flags &= ~CLIENT_HIDDEN;
else
cc->flags |= CLIENT_HIDDEN;
xu_ewmh_set_net_wm_state(cc); xu_ewmh_set_net_wm_state(cc);
} }
void void
client_toggle_sticky(struct client_ctx *cc) client_toggle_sticky(struct client_ctx *cc)
{ {
if (cc->flags & CLIENT_STICKY) cc->flags ^= CLIENT_STICKY;
cc->flags &= ~CLIENT_STICKY;
else
cc->flags |= CLIENT_STICKY;
xu_ewmh_set_net_wm_state(cc); xu_ewmh_set_net_wm_state(cc);
} }
@ -297,6 +289,7 @@ client_toggle_fullscreen(struct client_ctx *cc)
return; return;
if (cc->flags & CLIENT_FULLSCREEN) { if (cc->flags & CLIENT_FULLSCREEN) {
if (!(cc->flags & CLIENT_IGNORE))
cc->bwidth = Conf.bwidth; cc->bwidth = Conf.bwidth;
cc->geom = cc->fullgeom; cc->geom = cc->fullgeom;
cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE); cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE);
@ -518,12 +511,12 @@ client_hide(struct client_ctx *cc)
{ {
XUnmapWindow(X_Dpy, cc->win); XUnmapWindow(X_Dpy, cc->win);
if (cc->flags & CLIENT_ACTIVE)
client_none(cc->sc);
cc->flags &= ~CLIENT_ACTIVE; cc->flags &= ~CLIENT_ACTIVE;
cc->flags |= CLIENT_HIDDEN; cc->flags |= CLIENT_HIDDEN;
client_set_wm_state(cc, IconicState); client_set_wm_state(cc, IconicState);
if (cc == client_current())
client_none(cc->sc);
} }
void void
@ -898,9 +891,6 @@ client_applysizehints(struct client_ctx *cc)
if (cc->hint.maxh) if (cc->hint.maxh)
cc->geom.h = MIN(cc->geom.h, 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.w = (cc->geom.w - cc->hint.basew) / cc->hint.incw;
cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch; cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch;
} }

4
conf.c
View File

@ -207,7 +207,7 @@ static const struct {
{ "CM-g", "grouptoggle" }, { "CM-g", "grouptoggle" },
{ "CM-f", "fullscreen" }, { "CM-f", "fullscreen" },
{ "CM-m", "maximize" }, { "CM-m", "maximize" },
{ "CM-s", "sticky" }, { "CM-s", "stick" },
{ "CM-equal", "vmaximize" }, { "CM-equal", "vmaximize" },
{ "CMS-equal", "hmaximize" }, { "CMS-equal", "hmaximize" },
{ "CMS-f", "freeze" }, { "CMS-f", "freeze" },
@ -408,7 +408,7 @@ static const struct {
{.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} }, {.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} },
{ "grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT, { "grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT,
{.i = CWM_KBD}}, {.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, { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CLIENT,
{0} }, {0} },
{ "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} }, { "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} },

View File

@ -301,7 +301,7 @@ Raise current window.
Label current window. Label current window.
.It freeze .It freeze
Freeze current window geometry. Freeze current window geometry.
.It sticky .It stick
Stick current window to all groups (same as assigning to nogroup). Stick current window to all groups (same as assigning to nogroup).
.It fullscreen .It fullscreen
Full-screen current window (gap + border removed). Full-screen current window (gap + border removed).

13
group.c
View File

@ -209,19 +209,12 @@ int
group_holds_only_hidden(struct group_ctx *gc) group_holds_only_hidden(struct group_ctx *gc)
{ {
struct client_ctx *cc; struct client_ctx *cc;
int hidden = 0, same = 0;
TAILQ_FOREACH(cc, &gc->clientq, group_entry) { TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
if (cc->flags & CLIENT_STICKY) if (!(cc->flags & (CLIENT_HIDDEN | CLIENT_STICKY)))
continue; return(0);
if (hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0))
same++;
} }
return(1);
if (same == 0)
hidden = !hidden;
return(hidden);
} }
void void

View File

@ -57,7 +57,6 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg)
XEvent ev; XEvent ev;
Time ltime = 0; Time ltime = 0;
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
int x = cc->geom.x, y = cc->geom.y;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -81,12 +80,8 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg)
continue; continue;
ltime = ev.xmotion.time; ltime = ev.xmotion.time;
cc->geom.w = abs(x - ev.xmotion.x_root) - cc->bwidth; cc->geom.w = ev.xmotion.x;
cc->geom.h = abs(y - ev.xmotion.y_root) - cc->bwidth; cc->geom.h = ev.xmotion.y;
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;
client_applysizehints(cc); client_applysizehints(cc);
client_resize(cc, 1); client_resize(cc, 1);
mousefunc_sweep_draw(cc); mousefunc_sweep_draw(cc);

View File

@ -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 * window. Furthermore, this is denoted by a "!" when
* printing the window name in the search menu. * 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++; tier++;
/* Clients that are hidden get ranked one up. */ /* 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; struct client_ctx *cc = (struct client_ctx *)mi->ctx;
char flag = ' '; char flag = ' ';
if (cc == client_current()) if (cc->flags & CLIENT_ACTIVE)
flag = '!'; flag = '!';
else if (cc->flags & CLIENT_HIDDEN) else if (cc->flags & CLIENT_HIDDEN)
flag = '&'; flag = '&';

View File

@ -250,11 +250,14 @@ xev_handle_buttonpress(XEvent *ee)
static void static void
xev_handle_buttonrelease(XEvent *ee) xev_handle_buttonrelease(XEvent *ee)
{ {
XButtonEvent *e = &ee->xbutton;
struct client_ctx *cc; struct client_ctx *cc;
if ((cc = client_current()) != NULL) if ((cc = client_find(e->window)) != NULL) {
if (cc->flags & CLIENT_ACTIVE)
group_toggle_membership_leave(cc); group_toggle_membership_leave(cc);
} }
}
static void static void
xev_handle_keypress(XEvent *ee) xev_handle_keypress(XEvent *ee)