summary refs log tree commit diff
path: root/calmwm.c
diff options
context:
space:
mode:
authoroga <oga>2008-09-29 23:16:46 +0000
committeroga <oga>2008-09-29 23:16:46 +0000
commita0739c6cd4df1890751e2527c899756d7a49b6c5 (patch)
treed0c2dd86406ecbf00616857c3b351da224e31345 /calmwm.c
parente2610449d11d3b5100aad319e8fa70c370b734bf (diff)
downloadcwm-a0739c6cd4df1890751e2527c899756d7a49b6c5.tar.gz
cwm-a0739c6cd4df1890751e2527c899756d7a49b6c5.tar.xz
cwm-a0739c6cd4df1890751e2527c899756d7a49b6c5.zip
Xinerama and XRandR dual head support for cwm(1). Now we detect the xrandr
reconfiguration events and change our sizes depending on that. We also detect
the xinerama screens for maximize, vertmaximize and initial window placement.

This could be improved by automatically resizing maximized windows when
the screen resolution changes and by moving windows that would be hidden
into visible space. Said changes will come shortly.

Tested by many. matthieu@ didn't oppose.
Diffstat (limited to 'calmwm.c')
-rw-r--r--calmwm.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/calmwm.c b/calmwm.c
index c64035d..446ed17 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -36,6 +36,7 @@ u_int				 Nscreens;
 struct client_ctx_q		 Clientq;
 
 int				 Doshape, Shape_ev;
+int				 HasXinerama, HasRandr, Randr_ev;
 int				 Starting;
 struct conf			 Conf;
 
@@ -121,6 +122,8 @@ dpy_init(const char *dpyname)
 
 	Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
 
+	HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
+
 	TAILQ_INIT(&Screenq);
 }
 
@@ -133,7 +136,7 @@ x_setup(void)
 
 	Nscreens = ScreenCount(X_Dpy);
 	for (i = 0; i < (int)Nscreens; i++) {
-		XMALLOC(sc, struct screen_ctx);
+		XCALLOC(sc, struct screen_ctx);
 		x_setupscreen(sc, i);
 		TAILQ_INSERT_TAIL(&Screenq, sc, entry);
 	}
@@ -161,6 +164,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	Window			*wins, w0, w1;
 	XWindowAttributes	 winattr;
 	XSetWindowAttributes	 rootattr;
+	int			 fake;
 	u_int			 nwins, i;
 
 	Curscreen = sc;
@@ -246,6 +250,18 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	XChangeWindowAttributes(X_Dpy, sc->rootwin,
 	    CWEventMask, &rootattr);
 
+	if (XineramaQueryExtension(X_Dpy, &fake, &fake) == 1 &&
+	    ((HasXinerama = XineramaIsActive(X_Dpy)) == 1))
+		HasXinerama = 1;
+	if (HasRandr)
+		XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
+	/*
+	 * initial setup of xinerama screens, if we're using RandR then we'll
+	 * redo this whenever the screen changes since a CTRC may have been
+	 * added or removed
+	 */
+	screen_init_xinerama(sc);
+
 	XSync(X_Dpy, False);
 
 	return;