From 067d8c9f41a0c6d9cd87c31432b56057e0da2c5d Mon Sep 17 00:00:00 2001 From: oga Date: Thu, 10 Dec 2009 23:14:58 +0000 Subject: Implement _NET_CURRENT_DESKTOP, _NET_DESKTOP_VIEWPORT and _NET_DESKTOP_GEOMETRY. ok okan@ --- calmwm.c | 17 +++++------------ calmwm.h | 10 +++++++--- group.c | 29 +++++++++++++++++++++-------- screen.c | 13 ++++++++++++- xevents.c | 5 ++--- xutil.c | 5 ++++- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/calmwm.c b/calmwm.c index 63486df..234b284 100644 --- a/calmwm.c +++ b/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/calmwm.h b/calmwm.h index 14fb7e7..e191c3b 100644 --- a/calmwm.h +++ b/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/group.c b/group.c index c1bda73..df5600a 100644 --- a/group.c +++ b/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/screen.c b/screen.c index f53a31b..4e078e7 100644 --- a/screen.c +++ b/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/xevents.c b/xevents.c index b914484..69bbec4 100644 --- a/xevents.c +++ b/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/xutil.c b/xutil.c index 6b3d95b..be39289 100644 --- a/xutil.c +++ b/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 -- cgit v1.2.3-2-gb3c3