cvsimport

This commit is contained in:
okan
2013-12-02 20:01:19 +00:00
10 changed files with 99 additions and 159 deletions

150
client.c
View File

@@ -180,53 +180,35 @@ client_delete(struct client_ctx *cc)
}
void
client_leave(struct client_ctx *cc)
client_setactive(struct client_ctx *cc)
{
if (cc == NULL)
cc = client_current();
if (cc == NULL)
return;
}
struct screen_ctx *sc = cc->sc;
struct client_ctx *oldcc;
void
client_setactive(struct client_ctx *cc, int fg)
{
struct screen_ctx *sc;
XInstallColormap(X_Dpy, cc->colormap);
if (cc == NULL)
cc = client_current();
if (cc == NULL)
return;
if ((cc->flags & CLIENT_INPUT) ||
((cc->flags & CLIENT_WM_TAKE_FOCUS) == 0)) {
XSetInputFocus(X_Dpy, cc->win,
RevertToPointerRoot, CurrentTime);
}
if (cc->flags & CLIENT_WM_TAKE_FOCUS)
client_msg(cc, cwmh[WM_TAKE_FOCUS]);
sc = cc->sc;
if (fg) {
XInstallColormap(X_Dpy, cc->colormap);
if ((cc->flags & CLIENT_INPUT) ||
((cc->flags & CLIENT_WM_TAKE_FOCUS) == 0)) {
XSetInputFocus(X_Dpy, cc->win,
RevertToPointerRoot, CurrentTime);
}
if (cc->flags & CLIENT_WM_TAKE_FOCUS)
client_msg(cc, cwmh[WM_TAKE_FOCUS]);
conf_grab_mouse(cc->win);
/*
* If we're in the middle of alt-tabbing, don't change
* the order please.
*/
if (!sc->cycling)
client_mtf(cc);
} else
client_leave(cc);
if (fg && cc != client_current()) {
client_setactive(NULL, 0);
_curcc = cc;
xu_ewmh_net_active_window(sc, cc->win);
if ((oldcc = client_current())) {
oldcc->active = 0;
client_draw_border(oldcc);
}
cc->active = fg;
/* If we're in the middle of cycing, don't change the order. */
if (!sc->cycling)
client_mtf(cc);
_curcc = cc;
cc->active = 1;
client_draw_border(cc);
conf_grab_mouse(cc->win);
xu_ewmh_net_active_window(sc, cc->win);
}
/*
@@ -640,12 +622,14 @@ client_cycle(struct screen_ctx *sc, int flags)
}
void
client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc)
client_cycle_leave(struct screen_ctx *sc)
{
struct client_ctx *cc;
sc->cycling = 0;
client_mtf(NULL);
if (cc) {
if ((cc = client_current())) {
client_mtf(cc);
group_sticky_toggle_exit(cc);
XUngrabKeyboard(X_Dpy, CurrentTime);
}
@@ -724,14 +708,8 @@ client_placecalc(struct client_ctx *cc)
static void
client_mtf(struct client_ctx *cc)
{
struct screen_ctx *sc;
struct screen_ctx *sc = cc->sc;
if (cc == NULL)
cc = client_current();
if (cc == NULL)
return;
sc = cc->sc;
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
TAILQ_INSERT_HEAD(&sc->mruq, cc, mru_entry);
}
@@ -740,52 +718,46 @@ void
client_getsizehints(struct client_ctx *cc)
{
long tmp;
XSizeHints *size;
XSizeHints size;
if ((size = XAllocSizeHints()) == NULL)
warnx("XAllocSizeHints failure");
if (!XGetWMNormalHints(X_Dpy, cc->win, &size, &tmp))
size.flags = 0;
if (!XGetWMNormalHints(X_Dpy, cc->win, size, &tmp))
size->flags = 0;
cc->hint.flags = size.flags;
cc->hint.flags = size->flags;
if (size->flags & PBaseSize) {
cc->hint.basew = size->base_width;
cc->hint.baseh = size->base_height;
} else if (size->flags & PMinSize) {
cc->hint.basew = size->min_width;
cc->hint.baseh = size->min_height;
if (size.flags & PBaseSize) {
cc->hint.basew = size.base_width;
cc->hint.baseh = size.base_height;
} else if (size.flags & PMinSize) {
cc->hint.basew = size.min_width;
cc->hint.baseh = size.min_height;
}
if (size->flags & PMinSize) {
cc->hint.minw = size->min_width;
cc->hint.minh = size->min_height;
} else if (size->flags & PBaseSize) {
cc->hint.minw = size->base_width;
cc->hint.minh = size->base_height;
if (size.flags & PMinSize) {
cc->hint.minw = size.min_width;
cc->hint.minh = size.min_height;
} else if (size.flags & PBaseSize) {
cc->hint.minw = size.base_width;
cc->hint.minh = size.base_height;
}
if (size->flags & PMaxSize) {
cc->hint.maxw = size->max_width;
cc->hint.maxh = size->max_height;
if (size.flags & PMaxSize) {
cc->hint.maxw = size.max_width;
cc->hint.maxh = size.max_height;
}
if (size->flags & PResizeInc) {
cc->hint.incw = size->width_inc;
cc->hint.inch = size->height_inc;
if (size.flags & PResizeInc) {
cc->hint.incw = size.width_inc;
cc->hint.inch = size.height_inc;
}
cc->hint.incw = MAX(1, cc->hint.incw);
cc->hint.inch = MAX(1, cc->hint.inch);
if (size->flags & PAspect) {
if (size->min_aspect.x > 0)
cc->hint.mina = (float)size->min_aspect.y /
size->min_aspect.x;
if (size->max_aspect.y > 0)
cc->hint.maxa = (float)size->max_aspect.x /
size->max_aspect.y;
if (size.flags & PAspect) {
if (size.min_aspect.x > 0)
cc->hint.mina = (float)size.min_aspect.y /
size.min_aspect.x;
if (size.max_aspect.y > 0)
cc->hint.maxa = (float)size.max_aspect.x /
size.max_aspect.y;
}
if (size)
XFree(size);
}
void
@@ -803,12 +775,10 @@ client_applysizehints(struct client_ctx *cc)
}
/* adjust for aspect limits */
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
if (cc->hint.maxa <
(float)cc->geom.w / cc->geom.h)
if (cc->hint.mina && cc->hint.maxa) {
if (cc->hint.maxa < (float)cc->geom.w / cc->geom.h)
cc->geom.w = cc->geom.h * cc->hint.maxa;
else if (cc->hint.mina <
(float)cc->geom.h / cc->geom.w)
else if (cc->hint.mina < (float)cc->geom.h / cc->geom.w)
cc->geom.h = cc->geom.w * cc->hint.mina;
}