about summary refs log tree commit diff
path: root/screen.c
diff options
context:
space:
mode:
authorokan <okan>2013-01-06 01:01:26 +0000
committerokan <okan>2013-01-06 01:01:26 +0000
commit104c7d5de3a92da8b0c3514ef0692ff1e5d0ef82 (patch)
tree4e3ce464112ff297402c202eee26cc2fdaa87dfa /screen.c
parentf77166194f4586cb19abcb7951ca05e356ac74e1 (diff)
parentc426254da5ff69102284524ddc560cfb00c73204 (diff)
downloadcwm-104c7d5de3a92da8b0c3514ef0692ff1e5d0ef82.tar.gz
cwm-104c7d5de3a92da8b0c3514ef0692ff1e5d0ef82.tar.xz
cwm-104c7d5de3a92da8b0c3514ef0692ff1e5d0ef82.zip
cvsimport
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/screen.c b/screen.c
index 92ff9a4..5f7af56 100644
--- a/screen.c
+++ b/screen.c
@@ -30,8 +30,6 @@
 
 #include "calmwm.h"
 
-static void	 screen_init_xinerama(struct screen_ctx *);
-
 void
 screen_init(struct screen_ctx *sc, u_int which)
 {
@@ -125,48 +123,40 @@ screen_updatestackingorder(struct screen_ctx *sc)
 }
 
 /*
- * If we're using RandR then we'll redo this whenever the screen
- * changes since a CTRC may have been added or removed
- */
-void
-screen_init_xinerama(struct screen_ctx *sc)
-{
-	XineramaScreenInfo	*info = NULL;
-	int			 no = 0;
-
-	if (XineramaIsActive(X_Dpy))
-		info = XineramaQueryScreens(X_Dpy, &no);
-
-	if (sc->xinerama != NULL)
-		XFree(sc->xinerama);
-	sc->xinerama = info;
-	sc->xinerama_no = no;
-}
-
-/*
  * Find which xinerama screen the coordinates (x,y) is on.
  */
-XineramaScreenInfo *
+struct geom
 screen_find_xinerama(struct screen_ctx *sc, int x, int y)
 {
 	XineramaScreenInfo	*info;
+	struct geom		 geom;
 	int			 i;
 
+	geom = sc->view;
+
 	if (sc->xinerama == NULL)
-		return (NULL);
+		return (geom);
 
 	for (i = 0; i < sc->xinerama_no; i++) {
 		info = &sc->xinerama[i];
 		if (x >= info->x_org && x < info->x_org + info->width &&
-		    y >= info->y_org && y < info->y_org + info->height)
-			return (info);
+		    y >= info->y_org && y < info->y_org + info->height) {
+			geom.x = info->x_org;
+			geom.y = info->y_org;
+			geom.w = info->width;
+			geom.h = info->height;
+			break;
+		}
 	}
-	return (NULL);
+	return (geom);
 }
 
 void
 screen_update_geometry(struct screen_ctx *sc)
 {
+	XineramaScreenInfo	*info = NULL;
+	int			 info_no = 0;
+
 	sc->view.x = 0;
 	sc->view.y = 0;
 	sc->view.w = DisplayWidth(X_Dpy, sc->which);
@@ -177,7 +167,13 @@ 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);
 
-	screen_init_xinerama(sc);
+	/* RandR event may have a CTRC added or removed. */
+	if (XineramaIsActive(X_Dpy))
+		info = XineramaQueryScreens(X_Dpy, &info_no);
+	if (sc->xinerama != NULL)
+		XFree(sc->xinerama);
+	sc->xinerama = info;
+	sc->xinerama_no = info_no;
 
 	xu_ewmh_net_desktop_geometry(sc);
 	xu_ewmh_net_workarea(sc);