From cce06135af44660039026ea785a5ffdbfc277ea9 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 9 Nov 2015 20:03:29 +0000 Subject: 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. --- screen.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index 4adc63f..eb52404 100644 --- a/screen.c +++ b/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * 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 @@ -124,35 +124,29 @@ screen_updatestackingorder(struct screen_ctx *sc) } } -struct geom -screen_area(struct screen_ctx *sc, int x, int y, int flags) +struct region_ctx * +region_find(struct screen_ctx *sc, int x, int y) { struct region_ctx *rc; - struct geom area = sc->work; TAILQ_FOREACH(rc, &sc->regionq, entry) { - if ((x >= rc->area.x) && (x < (rc->area.x + rc->area.w)) && - (y >= rc->area.y) && (y < (rc->area.y + rc->area.h))) { - area = rc->area; + if ((x >= rc->view.x) && (x < (rc->view.x + rc->view.w)) && + (y >= rc->view.y) && (y < (rc->view.y + rc->view.h))) { break; } } - if (flags & CWM_GAP) - area = screen_apply_gap(sc, area); - return(area); + return(rc); } void screen_update_geometry(struct screen_ctx *sc) { struct region_ctx *rc; - int i; sc->view.x = 0; sc->view.y = 0; sc->view.w = DisplayWidth(X_Dpy, sc->which); sc->view.h = DisplayHeight(X_Dpy, sc->which); - sc->work = screen_apply_gap(sc, sc->view); while ((rc = TAILQ_FIRST(&sc->regionq)) != NULL) { @@ -163,6 +157,7 @@ screen_update_geometry(struct screen_ctx *sc) if (HasRandr) { XRRScreenResources *sr; XRRCrtcInfo *ci; + int i; sr = XRRGetScreenResources(X_Dpy, sc->rootwin); 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->num = i; - rc->area.x = ci->x; - rc->area.y = ci->y; - rc->area.w = ci->width; - rc->area.h = ci->height; + rc->view.x = ci->x; + rc->view.y = ci->y; + rc->view.w = ci->width; + rc->view.h = ci->height; + rc->work = screen_apply_gap(sc, rc->view); TAILQ_INSERT_TAIL(&sc->regionq, rc, entry); XRRFreeCrtcInfo(ci); } 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); -- cgit v1.2.3-2-gb3c3