summary refs log tree commit diff
path: root/screen.c
diff options
context:
space:
mode:
authorokan <okan>2015-11-09 20:03:29 +0000
committerokan <okan>2015-11-09 20:03:29 +0000
commitd7bd2998191af2ce1d6c0018e7c3a43a01ed3be5 (patch)
treef19e680cf0d8ca985fe18f66a39e273677676162 /screen.c
parent5fcf2516721dd441b435ba07f73c6315c104f5a3 (diff)
downloadcwm-d7bd2998191af2ce1d6c0018e7c3a43a01ed3be5.tar.gz
cwm-d7bd2998191af2ce1d6c0018e7c3a43a01ed3be5.tar.xz
cwm-d7bd2998191af2ce1d6c0018e7c3a43a01ed3be5.zip
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.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/screen.c b/screen.c
index aad2159..4fc6f4e 100644
--- a/screen.c
+++ b/screen.c
@@ -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);