summary refs log tree commit diff
path: root/screen.c
diff options
context:
space:
mode:
authorokan <okan>2015-06-26 15:21:58 +0000
committerokan <okan>2015-06-26 15:21:58 +0000
commit8aa40078d19b99124efb149bfc43fed47937fc15 (patch)
tree2462871d2e3342d8d03c4b88c068d1f81050b241 /screen.c
parentee400b08a8d7f1a0ef9ba1403285b1e32a08e39f (diff)
downloadcwm-8aa40078d19b99124efb149bfc43fed47937fc15.tar.gz
cwm-8aa40078d19b99124efb149bfc43fed47937fc15.tar.xz
cwm-8aa40078d19b99124efb149bfc43fed47937fc15.zip
Replace screen region info gathering with XRandR equivalent of Xinerama
queries (currently act on XRandR events anyway). Fall-back mode without
XRandR is still what X provides. This removes -lXinerama.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/screen.c b/screen.c
index bb7bd9c..19d92a4 100644
--- a/screen.c
+++ b/screen.c
@@ -152,9 +152,8 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags)
 void
 screen_update_geometry(struct screen_ctx *sc)
 {
-	XineramaScreenInfo	*info = NULL;
 	struct region_ctx	*region;
-	int			 info_num = 0, i;
+	int			 i;
 
 	sc->view.x = 0;
 	sc->view.y = 0;
@@ -166,25 +165,37 @@ screen_update_geometry(struct screen_ctx *sc)
 	sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right);
 	sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom);
 
-	/* RandR event may have a CTRC added or removed. */
-	if (XineramaIsActive(X_Dpy))
-		info = XineramaQueryScreens(X_Dpy, &info_num);
-
 	while ((region = TAILQ_FIRST(&sc->regionq)) != NULL) {
 		TAILQ_REMOVE(&sc->regionq, region, entry);
 		free(region);
 	}
-	for (i = 0; i < info_num; i++) {
-		region = xmalloc(sizeof(*region));
-		region->num = i;
-		region->area.x = info[i].x_org;
-		region->area.y = info[i].y_org;
-		region->area.w = info[i].width;
-		region->area.h = info[i].height;
-		TAILQ_INSERT_TAIL(&sc->regionq, region, entry);
+
+	if (HasRandr) {
+		XRRScreenResources *sr;
+		XRRCrtcInfo *ci;
+
+		sr = XRRGetScreenResources(X_Dpy, sc->rootwin);
+		for (i = 0, ci = NULL; i < sr->ncrtc; i++) {
+			ci = XRRGetCrtcInfo(X_Dpy, sr, sr->crtcs[i]);
+			if (ci == NULL)
+				continue;
+			if (ci->noutput == 0) {
+				XRRFreeCrtcInfo(ci);
+				continue;
+			}
+
+			region = xmalloc(sizeof(*region));
+			region->num = i;
+			region->area.x = ci->x;
+			region->area.y = ci->y;
+			region->area.w = ci->width;
+			region->area.h = ci->height;
+			TAILQ_INSERT_TAIL(&sc->regionq, region, entry);
+
+			XRRFreeCrtcInfo(ci);
+		}
+		XRRFreeScreenResources(sr);
 	}
-	if (info)
-		XFree(info);
 
 	xu_ewmh_net_desktop_geometry(sc);
 	xu_ewmh_net_workarea(sc);