summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--calmwm.c15
-rw-r--r--calmwm.h8
-rw-r--r--group.c27
-rw-r--r--screen.c11
-rw-r--r--xevents.c3
-rw-r--r--xutil.c3
6 files changed, 45 insertions, 22 deletions
diff --git a/calmwm.c b/calmwm.c
index 4bd1567..5824441 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -143,12 +143,12 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	XWindowAttributes	 winattr;
 	XSetWindowAttributes	 rootattr;
 	int			 fake;
-	u_int			 ndesks = CALMWM_NGROUPS, nwins, i;
-
+	u_int			 nwins, i;
 	sc->which = which;
 	sc->rootwin = RootWindow(X_Dpy, sc->which);
-	sc->xmax = DisplayWidth(X_Dpy, sc->which);
-	sc->ymax = DisplayHeight(X_Dpy, sc->which);
+
+	screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which),
+	    DisplayHeight(X_Dpy, sc->which));
 
 	conf_color(&Conf, sc);
 
@@ -161,13 +161,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	/* Initialize menu window. */
 	menu_init(sc);
 
-	/*
-	 * XXX this probably should be somewhere else, but since it's a 
-	 * static value for now it does ok.
-	 */
-	XChangeProperty(X_Dpy, sc->rootwin, _NET_NUMBER_OF_DESKTOPS,
-	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
-
 	xu_setwmname(sc);
 
 	/* Deal with existing clients. */
diff --git a/calmwm.h b/calmwm.h
index 9ca583f..8e4b3ab 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -401,6 +401,7 @@ char			*xstrdup(const char *);
 
 struct screen_ctx	*screen_fromroot(Window);
 void			 screen_updatestackingorder(struct screen_ctx *);
+void			 screen_update_geometry(struct screen_ctx *, int, int);
 void			 screen_init_xinerama(struct screen_ctx *);
 XineramaScreenInfo	*screen_find_xinerama(struct screen_ctx *, int, int);
 
@@ -530,9 +531,12 @@ extern struct conf			 Conf;
 #define	_NET_SUPPORTING_WM_CHECK	 cwm_atoms[8]
 #define	_NET_WM_NAME			 cwm_atoms[9]
 #define	_NET_ACTIVE_WINDOW		 cwm_atoms[10]
-#define _NET_CLIENT_LIST		 cwm_atoms[11]
+#define	_NET_CLIENT_LIST		 cwm_atoms[11]
 #define	_NET_NUMBER_OF_DESKTOPS		 cwm_atoms[12]
-#define CWM_NO_ATOMS			 13
+#define	_NET_CURRENT_DESKTOP		 cwm_atoms[13]
+#define	_NET_DESKTOP_VIEWPORT		 cwm_atoms[14]
+#define	_NET_DESKTOP_GEOMETRY		 cwm_atoms[15]
+#define CWM_NO_ATOMS			 16
 #define CWM_NETWM_START			 7
 
 extern Atom				 cwm_atoms[CWM_NO_ATOMS];
diff --git a/group.c b/group.c
index 6b20027..78c9e51 100644
--- a/group.c
+++ b/group.c
@@ -27,6 +27,7 @@ static void		 group_remove(struct client_ctx *);
 static void		 group_hide(struct screen_ctx *, struct group_ctx *);
 static void		 group_show(struct screen_ctx *, struct group_ctx *);
 static void		 group_fix_hidden_state(struct group_ctx *);
+static void		 group_setactive(struct screen_ctx *, int);
 
 const char *shortcut_to_name[] = {
 	"nogroup", "one", "two", "three", "four", "five", "six",
@@ -118,17 +119,17 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc)
 	xfree(winlist);
 
 	gc->hidden = 0;
-	sc->group_active = gc;
+	group_setactive(sc, gc->shortcut - 1);
 }
 
 void
 group_init(struct screen_ctx *sc)
 {
-	int	 i;
+	int	 	 i;
+	u_int32_t	 viewports[2] = {0, 0}, ndesks = CALMWM_NGROUPS;
 
 	TAILQ_INIT(&sc->groupq);
 	sc->group_hideall = 0;
-	sc->group_active = NULL;
 
 	for (i = 0; i < CALMWM_NGROUPS; i++) {
 		TAILQ_INIT(&sc->groups[i].clients);
@@ -138,7 +139,20 @@ group_init(struct screen_ctx *sc)
 		TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry);
 	}
 
-	sc->group_active = &sc->groups[0];
+	/* we don't support large desktops, so this is always (0, 0) */
+	XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_VIEWPORT,
+	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)viewports, 2);
+	XChangeProperty(X_Dpy, sc->rootwin, _NET_NUMBER_OF_DESKTOPS,
+	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
+	group_setactive(sc, 0);
+}
+
+static void
+group_setactive(struct screen_ctx *sc, int idx)
+{
+	sc->group_active = &sc->groups[idx];
+	XChangeProperty(X_Dpy, sc->rootwin, _NET_CURRENT_DESKTOP,
+	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
 }
 
 void
@@ -210,7 +224,6 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 		err(1, "group_hidetoggle: index out of range (%d)", idx);
 
 	gc = &sc->groups[idx];
-
 	group_fix_hidden_state(gc);
 
 	if (gc->hidden)
@@ -219,7 +232,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 		group_hide(sc, gc);
 		/* XXX wtf? */
 		if (TAILQ_EMPTY(&gc->clients))
-			sc->group_active = gc;
+			group_setactive(sc, idx);
 	}
 }
 
@@ -273,7 +286,7 @@ group_cycle(struct screen_ctx *sc, int reverse)
 	if (showgroup->hidden)
 		group_show(sc, showgroup);
 	else
-		sc->group_active = showgroup;
+		group_setactive(sc, showgroup->shortcut - 1);
 }
 
 /* called when a client is deleted */
diff --git a/screen.c b/screen.c
index 6f73f2f..33d8199 100644
--- a/screen.c
+++ b/screen.c
@@ -98,3 +98,14 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
 	}
 	return (NULL);
 }
+
+void
+screen_update_geometry(struct screen_ctx *sc, int width, int height)
+{
+	int	geom[2];
+
+	sc->xmax = geom[0] = width;
+	sc->ymax = geom[1] = height;
+	XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_GEOMETRY,
+	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2);
+}
diff --git a/xevents.c b/xevents.c
index 39586b1..d52984a 100644
--- a/xevents.c
+++ b/xevents.c
@@ -368,8 +368,7 @@ xev_handle_randr(XEvent *ee)
 	TAILQ_FOREACH(sc, &Screenq, entry) {
 		if (sc->which == (u_int)i) {
 			XRRUpdateConfiguration(ee);
-			sc->xmax = rev->width;
-			sc->ymax = rev->height;
+			screen_update_geometry(sc, rev->width, rev->height);
 			screen_init_xinerama(sc);
 		}
 	}
diff --git a/xutil.c b/xutil.c
index 489b187..727fd37 100644
--- a/xutil.c
+++ b/xutil.c
@@ -184,6 +184,9 @@ char 		*atoms[CWM_NO_ATOMS] = {
 	"_NET_ACTIVE_WINDOW",
 	"_NET_CLIENT_LIST",
 	"_NET_NUMBER_OF_DESKTOPS",
+	"_NET_CURRENT_DESKTOP",
+	"_NET_DESKTOP_VIEWPORT",
+	"_NET_DESKTOP_GEOMETRY",
 };
 
 void