diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-12-10 23:14:59 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-12-10 23:14:59 +0000 |
commit | 45f3b165f99b841b5d3507544b7fb577e1fbf59c (patch) | |
tree | 1bc3d4af902f903408d785d4a4000fed32fa7f3a | |
parent | 64c662255856aa17131b9636da872a43cbfa3f19 (diff) |
Implement _NET_CURRENT_DESKTOP, _NET_DESKTOP_VIEWPORT and
_NET_DESKTOP_GEOMETRY.
ok okan@
-rw-r--r-- | app/cwm/calmwm.c | 17 | ||||
-rw-r--r-- | app/cwm/calmwm.h | 10 | ||||
-rw-r--r-- | app/cwm/group.c | 29 | ||||
-rw-r--r-- | app/cwm/screen.c | 13 | ||||
-rw-r--r-- | app/cwm/xevents.c | 5 | ||||
-rw-r--r-- | app/cwm/xutil.c | 5 |
6 files changed, 51 insertions, 28 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c index 63486df94..234b28461 100644 --- a/app/cwm/calmwm.c +++ b/app/cwm/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.c,v 1.47 2009/12/10 17:16:51 oga Exp $ + * $Id: calmwm.c,v 1.48 2009/12/10 23:14:58 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/calmwm.h b/app/cwm/calmwm.h index 14fb7e7b6..e191c3b48 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.104 2009/12/10 17:16:51 oga Exp $ + * $Id: calmwm.h,v 1.105 2009/12/10 23:14:58 oga Exp $ */ #ifndef _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/app/cwm/group.c b/app/cwm/group.c index c1bda73e0..df5600a58 100644 --- a/app/cwm/group.c +++ b/app/cwm/group.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: group.c,v 1.34 2009/12/10 17:16:51 oga Exp $ + * $Id: group.c,v 1.35 2009/12/10 23:14:58 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/screen.c b/app/cwm/screen.c index f53a31b17..4e078e7ee 100644 --- a/app/cwm/screen.c +++ b/app/cwm/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: screen.c,v 1.20 2009/12/10 17:16:51 oga Exp $ + * $Id: screen.c,v 1.21 2009/12/10 23:14:58 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/xevents.c b/app/cwm/xevents.c index b914484be..69bbec434 100644 --- a/app/cwm/xevents.c +++ b/app/cwm/xevents.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.45 2009/12/10 17:16:51 oga Exp $ + * $Id: xevents.c,v 1.46 2009/12/10 23:14:58 oga Exp $ */ /* @@ -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/app/cwm/xutil.c b/app/cwm/xutil.c index 6b3d95b31..be39289ce 100644 --- a/app/cwm/xutil.c +++ b/app/cwm/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xutil.c,v 1.21 2009/12/07 23:19:51 oga Exp $ + * $Id: xutil.c,v 1.22 2009/12/10 23:14:58 oga Exp $ */ #include "headers.h" @@ -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 |