Mechanical change from xinerama to region backed areas.

This commit is contained in:
okan 2015-06-26 17:17:46 +00:00
parent 90288e2fc3
commit 66bc416217
6 changed files with 86 additions and 90 deletions

View File

@ -452,8 +452,7 @@ void search_print_client(struct menu *, int);
struct geom screen_apply_gap(struct screen_ctx *, struct geom);
struct screen_ctx *screen_find(Window);
struct geom screen_find_xinerama(struct screen_ctx *,
int, int, int);
struct geom screen_area(struct screen_ctx *, int, int, int);
void screen_init(int);
void screen_update_geometry(struct screen_ctx *);
void screen_updatestackingorder(struct screen_ctx *);

114
client.c
View File

@ -265,7 +265,7 @@ void
client_toggle_fullscreen(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
if ((cc->flags & CLIENT_FREEZE) &&
!(cc->flags & CLIENT_FULLSCREEN))
@ -280,12 +280,12 @@ client_toggle_fullscreen(struct client_ctx *cc)
cc->fullgeom = cc->geom;
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_NOGAP);
cc->bwidth = 0;
cc->geom = xine;
cc->geom = area;
cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);
resize:
@ -297,7 +297,7 @@ void
client_toggle_maximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
@ -323,14 +323,14 @@ client_toggle_maximize(struct client_ctx *cc)
* that's probably more fair than if just the origin of
* a window is poking over a boundary
*/
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.w = area.w - (cc->bwidth * 2);
cc->geom.h = area.h - (cc->bwidth * 2);
cc->flags |= CLIENT_MAXIMIZED;
resize:
@ -342,7 +342,7 @@ void
client_toggle_vmaximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
@ -357,12 +357,12 @@ client_toggle_vmaximize(struct client_ctx *cc)
cc->savegeom.y = cc->geom.y;
cc->savegeom.h = cc->geom.h;
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
cc->geom.y = xine.y;
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.y = area.y;
cc->geom.h = area.h - (cc->bwidth * 2);
cc->flags |= CLIENT_VMAXIMIZED;
resize:
@ -374,7 +374,7 @@ void
client_toggle_hmaximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
@ -389,12 +389,12 @@ client_toggle_hmaximize(struct client_ctx *cc)
cc->savegeom.x = cc->geom.x;
cc->savegeom.w = cc->geom.w;
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
cc->geom.x = xine.x;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.w = area.w - (cc->bwidth * 2);
cc->flags |= CLIENT_HMAXIMIZED;
resize:
@ -740,33 +740,33 @@ client_placecalc(struct client_ctx *cc)
cc->geom.x = MIN(cc->geom.x, xslack);
cc->geom.y = MIN(cc->geom.y, yslack);
} else {
struct geom xine;
struct geom area;
int xmouse, ymouse;
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
xine = screen_find_xinerama(sc, xmouse, ymouse, CWM_GAP);
xine.w += xine.x;
xine.h += xine.y;
xmouse = MAX(xmouse, xine.x) - cc->geom.w / 2;
ymouse = MAX(ymouse, xine.y) - cc->geom.h / 2;
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, xine.x);
ymouse = MAX(ymouse, xine.y);
xmouse = MAX(xmouse, area.x);
ymouse = MAX(ymouse, area.y);
xslack = xine.w - cc->geom.w - cc->bwidth * 2;
yslack = xine.h - cc->geom.h - cc->bwidth * 2;
xslack = area.w - cc->geom.w - cc->bwidth * 2;
yslack = area.h - cc->geom.h - cc->bwidth * 2;
if (xslack >= xine.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), xine.x);
if (xslack >= area.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
} else {
cc->geom.x = xine.x;
cc->geom.w = xine.w;
cc->geom.x = area.x;
cc->geom.w = area.w;
}
if (yslack >= xine.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), xine.y);
if (yslack >= area.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
} else {
cc->geom.y = xine.y;
cc->geom.h = xine.h;
cc->geom.y = area.y;
cc->geom.h = area.h;
}
}
}
@ -949,7 +949,7 @@ client_htile(struct client_ctx *cc)
struct client_ctx *ci;
struct group_ctx *gc = cc->group;
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int i, n, mh, x, h, w;
if (!gc)
@ -965,36 +965,36 @@ client_htile(struct client_ctx *cc)
if (n == 0)
return;
xine = screen_find_xinerama(sc,
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) >= xine.h)
cc->geom.h + (cc->bwidth * 2) >= area.h)
return;
cc->flags &= ~CLIENT_HMAXIMIZED;
cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.w = area.w - (cc->bwidth * 2);
client_resize(cc, 1);
client_ptrwarp(cc);
mh = cc->geom.h + (cc->bwidth * 2);
x = xine.x;
w = xine.w / n;
h = xine.h - mh;
x = area.x;
w = area.w / n;
h = area.h - mh;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc))
continue;
ci->bwidth = Conf.bwidth;
ci->geom.y = xine.y + mh;
ci->geom.y = area.y + mh;
ci->geom.x = x;
ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n)
ci->geom.w = xine.x + xine.w -
ci->geom.w = area.x + area.w -
ci->geom.x - (ci->bwidth * 2);
x += w;
client_resize(ci, 1);
@ -1008,7 +1008,7 @@ client_vtile(struct client_ctx *cc)
struct client_ctx *ci;
struct group_ctx *gc = cc->group;
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int i, n, mw, y, h, w;
if (!gc)
@ -1024,36 +1024,36 @@ client_vtile(struct client_ctx *cc)
if (n == 0)
return;
xine = screen_find_xinerama(sc,
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) >= xine.w)
cc->geom.w + (cc->bwidth * 2) >= area.w)
return;
cc->flags &= ~CLIENT_VMAXIMIZED;
cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.h = area.h - (cc->bwidth * 2);
client_resize(cc, 1);
client_ptrwarp(cc);
mw = cc->geom.w + (cc->bwidth * 2);
y = xine.y;
h = xine.h / n;
w = xine.w - mw;
y = area.y;
h = area.h / n;
w = area.w - mw;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc))
continue;
ci->bwidth = Conf.bwidth;
ci->geom.y = y;
ci->geom.x = xine.x + mw;
ci->geom.x = area.x + mw;
ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n)
ci->geom.h = xine.y + xine.h -
ci->geom.h = area.y + area.h -
ci->geom.y - (ci->bwidth * 2);
y += h;
client_resize(ci, 1);

View File

@ -57,7 +57,7 @@ void
kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int x, y, flags, amt;
unsigned int mx, my;
@ -101,15 +101,15 @@ kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
if (cc->geom.y > sc->view.h - 1)
cc->geom.y = sc->view.h - 1;
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.x + cc->geom.w + (cc->bwidth * 2),
xine.x, xine.x + xine.w, sc->snapdist);
area.x, area.x + area.w, sc->snapdist);
cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.y + cc->geom.h + (cc->bwidth * 2),
xine.y, xine.y + xine.h, sc->snapdist);
area.y, area.y + area.h, sc->snapdist);
client_move(cc);
xu_ptr_getpos(cc->win, &x, &y);

30
menu.c
View File

@ -331,7 +331,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
{
struct screen_ctx *sc = mc->sc;
struct menu *mi;
struct geom xine;
struct geom area;
int n, xsave, ysave;
if (mc->list) {
@ -374,25 +374,25 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
mc->num++;
}
xine = screen_find_xinerama(sc, mc->geom.x, mc->geom.y, CWM_GAP);
xine.w += xine.x - Conf.bwidth * 2;
xine.h += xine.y - Conf.bwidth * 2;
area = screen_area(sc, mc->geom.x, mc->geom.y, CWM_GAP);
area.w += area.x - Conf.bwidth * 2;
area.h += area.y - Conf.bwidth * 2;
xsave = mc->geom.x;
ysave = mc->geom.y;
/* Never hide the top, or left side, of the menu. */
if (mc->geom.x + mc->geom.w >= xine.w)
mc->geom.x = xine.w - mc->geom.w;
if (mc->geom.x < xine.x) {
mc->geom.x = xine.x;
mc->geom.w = MIN(mc->geom.w, (xine.w - xine.x));
if (mc->geom.x + mc->geom.w >= area.w)
mc->geom.x = area.w - mc->geom.w;
if (mc->geom.x < area.x) {
mc->geom.x = area.x;
mc->geom.w = MIN(mc->geom.w, (area.w - area.x));
}
if (mc->geom.y + mc->geom.h >= xine.h)
mc->geom.y = xine.h - mc->geom.h;
if (mc->geom.y < xine.y) {
mc->geom.y = xine.y;
mc->geom.h = MIN(mc->geom.h, (xine.h - xine.y));
if (mc->geom.y + mc->geom.h >= area.h)
mc->geom.y = area.h - mc->geom.h;
if (mc->geom.y < area.y) {
mc->geom.y = area.y;
mc->geom.h = MIN(mc->geom.h, (area.h - area.y));
}
if (mc->geom.x != xsave || mc->geom.y != ysave)
@ -415,7 +415,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
int y = n * (sc->xftfont->height + 1) + sc->xftfont->ascent + 1;
/* Stop drawing when menu doesn't fit inside the screen. */
if (mc->geom.y + y > xine.h)
if (mc->geom.y + y > area.h)
break;
xu_xft_draw(sc, text, CWM_COLOR_MENU_FONT, 0, y);

View File

@ -123,7 +123,7 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
XEvent ev;
Time ltime = 0;
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int px, py;
client_raise(cc);
@ -149,15 +149,15 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.x + cc->geom.w + (cc->bwidth * 2),
xine.x, xine.x + xine.w, sc->snapdist);
area.x, area.x + area.w, sc->snapdist);
cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.y + cc->geom.h + (cc->bwidth * 2),
xine.y, xine.y + xine.h, sc->snapdist);
area.y, area.y + area.h, sc->snapdist);
client_move(cc);
break;

View File

@ -124,25 +124,22 @@ screen_updatestackingorder(struct screen_ctx *sc)
}
}
/*
* Find which xinerama screen the coordinates (x,y) is on.
*/
struct geom
screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags)
screen_area(struct screen_ctx *sc, int x, int y, int flags)
{
struct region_ctx *region;
struct geom geom = sc->work;
struct geom area = sc->work;
TAILQ_FOREACH(region, &sc->regionq, entry) {
if (x >= region->area.x && x < region->area.x+region->area.w &&
y >= region->area.y && y < region->area.y+region->area.h) {
geom = region->area;
area = region->area;
break;
}
}
if (flags & CWM_GAP)
geom = screen_apply_gap(sc, geom);
return(geom);
area = screen_apply_gap(sc, area);
return(area);
}
void