Extend region to include both view and work areas; switch to

region_find() which no longer needs to recalculate gap each time
a client (or menu) is created or altered. If no RandR, fall back
to display dimensions while building regions instead of during
execution.
This commit is contained in:
okan 2015-11-09 20:03:29 +00:00
parent 370b4f5d5a
commit ffc7945b8d
6 changed files with 90 additions and 83 deletions

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: calmwm.h,v 1.305 2015/09/16 17:58:25 okan Exp $ * $OpenBSD: calmwm.h,v 1.306 2015/11/09 20:03:29 okan Exp $
*/ */
#ifndef _CALMWM_H_ #ifndef _CALMWM_H_
@ -80,9 +80,6 @@
#define CWM_TILE_HORIZ 0x0001 #define CWM_TILE_HORIZ 0x0001
#define CWM_TILE_VERT 0x0002 #define CWM_TILE_VERT 0x0002
#define CWM_GAP 0x0001
#define CWM_NOGAP 0x0002
#define CWM_WIN 0x0001 #define CWM_WIN 0x0001
#define CWM_CMD 0x0002 #define CWM_CMD 0x0002
@ -224,7 +221,8 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
struct region_ctx { struct region_ctx {
TAILQ_ENTRY(region_ctx) entry; TAILQ_ENTRY(region_ctx) entry;
int num; int num;
struct geom area; struct geom view; /* viewable area */
struct geom work; /* workable area, gap-applied */
}; };
TAILQ_HEAD(region_ctx_q, region_ctx); TAILQ_HEAD(region_ctx_q, region_ctx);
@ -459,7 +457,7 @@ void search_print_group(struct menu *, int);
struct geom screen_apply_gap(struct screen_ctx *, struct geom); struct geom screen_apply_gap(struct screen_ctx *, struct geom);
struct screen_ctx *screen_find(Window); struct screen_ctx *screen_find(Window);
struct geom screen_area(struct screen_ctx *, int, int, int); struct region_ctx *region_find(struct screen_ctx *, int, int);
void screen_init(int); void screen_init(int);
void screen_update_geometry(struct screen_ctx *); void screen_update_geometry(struct screen_ctx *);
void screen_updatestackingorder(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *);

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: client.c,v 1.210 2015/09/23 14:09:40 okan Exp $ * $OpenBSD: client.c,v 1.211 2015/11/09 20:03:29 okan Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -290,7 +290,7 @@ void
client_toggle_fullscreen(struct client_ctx *cc) client_toggle_fullscreen(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
if ((cc->flags & CLIENT_FREEZE) && if ((cc->flags & CLIENT_FREEZE) &&
!(cc->flags & CLIENT_FULLSCREEN)) !(cc->flags & CLIENT_FULLSCREEN))
@ -305,12 +305,12 @@ client_toggle_fullscreen(struct client_ctx *cc)
cc->fullgeom = cc->geom; cc->fullgeom = cc->geom;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_NOGAP); cc->geom.y + cc->geom.h / 2);
cc->bwidth = 0; cc->bwidth = 0;
cc->geom = area; cc->geom = rc->view;
cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE); cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);
resize: resize:
@ -322,7 +322,7 @@ void
client_toggle_maximize(struct client_ctx *cc) client_toggle_maximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -348,14 +348,14 @@ client_toggle_maximize(struct client_ctx *cc)
* that's probably more fair than if just the origin of * that's probably more fair than if just the origin of
* a window is poking over a boundary * a window is poking over a boundary
*/ */
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
cc->geom.x = area.x; cc->geom.x = rc->work.x;
cc->geom.y = area.y; cc->geom.y = rc->work.y;
cc->geom.w = area.w - (cc->bwidth * 2); cc->geom.w = rc->work.w - (cc->bwidth * 2);
cc->geom.h = area.h - (cc->bwidth * 2); cc->geom.h = rc->work.h - (cc->bwidth * 2);
cc->flags |= CLIENT_MAXIMIZED; cc->flags |= CLIENT_MAXIMIZED;
resize: resize:
@ -367,7 +367,7 @@ void
client_toggle_vmaximize(struct client_ctx *cc) client_toggle_vmaximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -382,12 +382,12 @@ client_toggle_vmaximize(struct client_ctx *cc)
cc->savegeom.y = cc->geom.y; cc->savegeom.y = cc->geom.y;
cc->savegeom.h = cc->geom.h; cc->savegeom.h = cc->geom.h;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
cc->geom.y = area.y; cc->geom.y = rc->work.y;
cc->geom.h = area.h - (cc->bwidth * 2); cc->geom.h = rc->work.h - (cc->bwidth * 2);
cc->flags |= CLIENT_VMAXIMIZED; cc->flags |= CLIENT_VMAXIMIZED;
resize: resize:
@ -399,7 +399,7 @@ void
client_toggle_hmaximize(struct client_ctx *cc) client_toggle_hmaximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -414,12 +414,12 @@ client_toggle_hmaximize(struct client_ctx *cc)
cc->savegeom.x = cc->geom.x; cc->savegeom.x = cc->geom.x;
cc->savegeom.w = cc->geom.w; cc->savegeom.w = cc->geom.w;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
cc->geom.x = area.x; cc->geom.x = rc->work.x;
cc->geom.w = area.w - (cc->bwidth * 2); cc->geom.w = rc->work.w - (cc->bwidth * 2);
cc->flags |= CLIENT_HMAXIMIZED; cc->flags |= CLIENT_HMAXIMIZED;
resize: resize:
@ -749,6 +749,7 @@ 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;
struct region_ctx *rc;
int xslack, yslack; int xslack, yslack;
if (cc->hint.flags & (USPosition | PPosition)) { if (cc->hint.flags & (USPosition | PPosition)) {
@ -768,7 +769,8 @@ client_placecalc(struct client_ctx *cc)
int xmouse, ymouse; int xmouse, ymouse;
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
area = screen_area(sc, xmouse, ymouse, CWM_GAP); rc = region_find(sc, xmouse, ymouse);
area = rc->work;
area.w += area.x; area.w += area.x;
area.h += area.y; area.h += area.y;
xmouse = MAX(xmouse, area.x) - cc->geom.w / 2; xmouse = MAX(xmouse, area.x) - cc->geom.w / 2;
@ -973,7 +975,7 @@ client_htile(struct client_ctx *cc)
struct client_ctx *ci; struct client_ctx *ci;
struct group_ctx *gc = cc->gc; struct group_ctx *gc = cc->gc;
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
int i, n, mh, x, h, w; int i, n, mh, x, h, w;
if (!gc) if (!gc)
@ -989,36 +991,36 @@ client_htile(struct client_ctx *cc)
if (n == 0) if (n == 0)
return; return;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
if (cc->flags & CLIENT_VMAXIMIZED || if (cc->flags & CLIENT_VMAXIMIZED ||
cc->geom.h + (cc->bwidth * 2) >= area.h) cc->geom.h + (cc->bwidth * 2) >= rc->work.h)
return; return;
cc->flags &= ~CLIENT_HMAXIMIZED; cc->flags &= ~CLIENT_HMAXIMIZED;
cc->geom.x = area.x; cc->geom.x = rc->work.x;
cc->geom.y = area.y; cc->geom.y = rc->work.y;
cc->geom.w = area.w - (cc->bwidth * 2); cc->geom.w = rc->work.w - (cc->bwidth * 2);
client_resize(cc, 1); client_resize(cc, 1);
client_ptrwarp(cc); client_ptrwarp(cc);
mh = cc->geom.h + (cc->bwidth * 2); mh = cc->geom.h + (cc->bwidth * 2);
x = area.x; x = rc->work.x;
w = area.w / n; w = rc->work.w / n;
h = area.h - mh; h = rc->work.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))
continue; continue;
ci->bwidth = Conf.bwidth; ci->bwidth = Conf.bwidth;
ci->geom.y = area.y + mh; ci->geom.y = rc->work.y + mh;
ci->geom.x = x; ci->geom.x = x;
ci->geom.h = h - (ci->bwidth * 2); ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2); ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n) if (i + 1 == n)
ci->geom.w = area.x + area.w - ci->geom.w = rc->work.x + rc->work.w -
ci->geom.x - (ci->bwidth * 2); ci->geom.x - (ci->bwidth * 2);
x += w; x += w;
client_resize(ci, 1); client_resize(ci, 1);
@ -1032,7 +1034,7 @@ client_vtile(struct client_ctx *cc)
struct client_ctx *ci; struct client_ctx *ci;
struct group_ctx *gc = cc->gc; struct group_ctx *gc = cc->gc;
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
int i, n, mw, y, h, w; int i, n, mw, y, h, w;
if (!gc) if (!gc)
@ -1048,36 +1050,36 @@ client_vtile(struct client_ctx *cc)
if (n == 0) if (n == 0)
return; return;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
if (cc->flags & CLIENT_HMAXIMIZED || if (cc->flags & CLIENT_HMAXIMIZED ||
cc->geom.w + (cc->bwidth * 2) >= area.w) cc->geom.w + (cc->bwidth * 2) >= rc->work.w)
return; return;
cc->flags &= ~CLIENT_VMAXIMIZED; cc->flags &= ~CLIENT_VMAXIMIZED;
cc->geom.x = area.x; cc->geom.x = rc->work.x;
cc->geom.y = area.y; cc->geom.y = rc->work.y;
cc->geom.h = area.h - (cc->bwidth * 2); cc->geom.h = rc->work.h - (cc->bwidth * 2);
client_resize(cc, 1); client_resize(cc, 1);
client_ptrwarp(cc); client_ptrwarp(cc);
mw = cc->geom.w + (cc->bwidth * 2); mw = cc->geom.w + (cc->bwidth * 2);
y = area.y; y = rc->work.y;
h = area.h / n; h = rc->work.h / n;
w = area.w - mw; w = rc->work.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))
continue; continue;
ci->bwidth = Conf.bwidth; ci->bwidth = Conf.bwidth;
ci->geom.y = y; ci->geom.y = y;
ci->geom.x = area.x + mw; ci->geom.x = rc->work.x + mw;
ci->geom.h = h - (ci->bwidth * 2); ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2); ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n) if (i + 1 == n)
ci->geom.h = area.y + area.h - ci->geom.h = rc->work.y + rc->work.h -
ci->geom.y - (ci->bwidth * 2); ci->geom.y - (ci->bwidth * 2);
y += h; y += h;
client_resize(ci, 1); client_resize(ci, 1);

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: kbfunc.c,v 1.118 2015/09/16 17:58:25 okan Exp $ * $OpenBSD: kbfunc.c,v 1.119 2015/11/09 20:03:29 okan Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -57,7 +57,7 @@ void
kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg) kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct geom area; struct region_ctx *rc;
int x, y, flags, amt; int x, y, flags, amt;
unsigned int mx, my; 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) if (cc->geom.y > sc->view.h - 1)
cc->geom.y = sc->view.h - 1; cc->geom.y = sc->view.h - 1;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.x + cc->geom.w + (cc->bwidth * 2), cc->geom.x + cc->geom.w + (cc->bwidth * 2),
area.x, area.x + area.w, sc->snapdist); rc->work.x, rc->work.x + rc->work.w, sc->snapdist);
cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.y + cc->geom.h + (cc->bwidth * 2), cc->geom.y + cc->geom.h + (cc->bwidth * 2),
area.y, area.y + area.h, sc->snapdist); rc->work.y, rc->work.y + rc->work.h, sc->snapdist);
client_move(cc); client_move(cc);
xu_ptr_getpos(cc->win, &x, &y); xu_ptr_getpos(cc->win, &x, &y);

View File

@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: menu.c,v 1.87 2015/07/12 14:21:09 okan Exp $ * $OpenBSD: menu.c,v 1.88 2015/11/09 20:03:29 okan Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -331,6 +331,7 @@ static void
menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
{ {
struct screen_ctx *sc = mc->sc; struct screen_ctx *sc = mc->sc;
struct region_ctx *rc;
struct menu *mi; struct menu *mi;
struct geom area; struct geom area;
int n, xsave, ysave; int n, xsave, ysave;
@ -371,7 +372,8 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
mc->num++; mc->num++;
} }
area = screen_area(sc, mc->geom.x, mc->geom.y, CWM_GAP); rc = region_find(sc, mc->geom.x, mc->geom.y);
area = rc->work;
area.w += area.x - Conf.bwidth * 2; area.w += area.x - Conf.bwidth * 2;
area.h += area.y - Conf.bwidth * 2; area.h += area.y - Conf.bwidth * 2;

View File

@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: mousefunc.c,v 1.98 2015/08/21 16:14:39 okan Exp $ * $OpenBSD: mousefunc.c,v 1.99 2015/11/09 20:03:30 okan Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -123,7 +123,7 @@ mousefunc_client_move(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;
struct geom area; struct region_ctx *rc;
int px, py; int px, py;
client_raise(cc); 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.x = ev.xmotion.x_root - px - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
area = screen_area(sc, rc = region_find(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP); cc->geom.y + cc->geom.h / 2);
cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.x + cc->geom.w + (cc->bwidth * 2), cc->geom.x + cc->geom.w + (cc->bwidth * 2),
area.x, area.x + area.w, sc->snapdist); rc->work.x, rc->work.x + rc->work.w, sc->snapdist);
cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.y + cc->geom.h + (cc->bwidth * 2), cc->geom.y + cc->geom.h + (cc->bwidth * 2),
area.y, area.y + area.h, sc->snapdist); rc->work.y, rc->work.y + rc->work.h, sc->snapdist);
client_move(cc); client_move(cc);
break; break;

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: screen.c,v 1.77 2015/08/21 16:52:37 okan Exp $ * $OpenBSD: screen.c,v 1.78 2015/11/09 20:03:30 okan Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -124,35 +124,29 @@ screen_updatestackingorder(struct screen_ctx *sc)
} }
} }
struct geom struct region_ctx *
screen_area(struct screen_ctx *sc, int x, int y, int flags) region_find(struct screen_ctx *sc, int x, int y)
{ {
struct region_ctx *rc; struct region_ctx *rc;
struct geom area = sc->work;
TAILQ_FOREACH(rc, &sc->regionq, entry) { TAILQ_FOREACH(rc, &sc->regionq, entry) {
if ((x >= rc->area.x) && (x < (rc->area.x + rc->area.w)) && if ((x >= rc->view.x) && (x < (rc->view.x + rc->view.w)) &&
(y >= rc->area.y) && (y < (rc->area.y + rc->area.h))) { (y >= rc->view.y) && (y < (rc->view.y + rc->view.h))) {
area = rc->area;
break; break;
} }
} }
if (flags & CWM_GAP) return(rc);
area = screen_apply_gap(sc, area);
return(area);
} }
void void
screen_update_geometry(struct screen_ctx *sc) screen_update_geometry(struct screen_ctx *sc)
{ {
struct region_ctx *rc; struct region_ctx *rc;
int i;
sc->view.x = 0; sc->view.x = 0;
sc->view.y = 0; sc->view.y = 0;
sc->view.w = DisplayWidth(X_Dpy, sc->which); sc->view.w = DisplayWidth(X_Dpy, sc->which);
sc->view.h = DisplayHeight(X_Dpy, sc->which); sc->view.h = DisplayHeight(X_Dpy, sc->which);
sc->work = screen_apply_gap(sc, sc->view); sc->work = screen_apply_gap(sc, sc->view);
while ((rc = TAILQ_FIRST(&sc->regionq)) != NULL) { while ((rc = TAILQ_FIRST(&sc->regionq)) != NULL) {
@ -163,6 +157,7 @@ screen_update_geometry(struct screen_ctx *sc)
if (HasRandr) { if (HasRandr) {
XRRScreenResources *sr; XRRScreenResources *sr;
XRRCrtcInfo *ci; XRRCrtcInfo *ci;
int i;
sr = XRRGetScreenResources(X_Dpy, sc->rootwin); sr = XRRGetScreenResources(X_Dpy, sc->rootwin);
for (i = 0, ci = NULL; i < sr->ncrtc; i++) { for (i = 0, ci = NULL; i < sr->ncrtc; i++) {
@ -176,15 +171,25 @@ screen_update_geometry(struct screen_ctx *sc)
rc = xmalloc(sizeof(*rc)); rc = xmalloc(sizeof(*rc));
rc->num = i; rc->num = i;
rc->area.x = ci->x; rc->view.x = ci->x;
rc->area.y = ci->y; rc->view.y = ci->y;
rc->area.w = ci->width; rc->view.w = ci->width;
rc->area.h = ci->height; rc->view.h = ci->height;
rc->work = screen_apply_gap(sc, rc->view);
TAILQ_INSERT_TAIL(&sc->regionq, rc, entry); TAILQ_INSERT_TAIL(&sc->regionq, rc, entry);
XRRFreeCrtcInfo(ci); XRRFreeCrtcInfo(ci);
} }
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
} else {
rc = xmalloc(sizeof(*rc));
rc->num = 0;
rc->view.x = 0;
rc->view.y = 0;
rc->view.w = DisplayWidth(X_Dpy, sc->which);
rc->view.h = DisplayHeight(X_Dpy, sc->which);
rc->work = screen_apply_gap(sc, rc->view);
TAILQ_INSERT_TAIL(&sc->regionq, rc, entry);
} }
xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_desktop_geometry(sc);