implement support for _NET_WM_DESKTOP properties on windows.

it works kinda like _CWM_GRP, which we added to aid restarts a while
ago, but it's standardised and clients are specifically allowed to set
it to request a desktop.

for noe we leave _CWM_GRP support in, but its days are now numbered.

while i'm here fixup an int/long mixup with an earlier diff.

ok okan@
This commit is contained in:
oga 2009-12-11 17:55:42 +00:00
parent 7d0bb562dc
commit cb76db27c6
3 changed files with 31 additions and 10 deletions

View File

@ -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.107 2009/12/11 17:51:42 oga Exp $
* $Id: calmwm.h,v 1.108 2009/12/11 17:55:42 oga Exp $
*/
#ifndef _CALMWM_H_
@ -541,7 +541,8 @@ extern struct conf Conf;
#define _NET_VIRTUAL_ROOTS cwm_atoms[16]
#define _NET_SHOWING_DESKTOP cwm_atoms[17]
#define _NET_DESKTOP_NAMES cwm_atoms[18]
#define CWM_NO_ATOMS 19
#define _NET_WM_DESKTOP cwm_atoms[19]
#define CWM_NO_ATOMS 20
#define CWM_NETWM_START 7
extern Atom cwm_atoms[CWM_NO_ATOMS];

View File

@ -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.37 2009/12/11 17:51:42 oga Exp $
* $Id: group.c,v 1.38 2009/12/11 17:55:42 oga Exp $
*/
#include "headers.h"
@ -27,7 +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);
static void group_setactive(struct screen_ctx *, long);
static void group_set_names(struct screen_ctx *);
const char *shortcut_to_name[] = {
@ -38,9 +38,12 @@ const char *shortcut_to_name[] = {
static void
group_add(struct group_ctx *gc, struct client_ctx *cc)
{
long no;
if (cc == NULL || gc == NULL)
errx(1, "group_add: a ctx is NULL");
no = gc->shortcut - 1;
if (cc->group == gc)
return;
@ -50,6 +53,8 @@ group_add(struct group_ctx *gc, struct client_ctx *cc)
XChangeProperty(X_Dpy, cc->win, _CWM_GRP, XA_STRING,
8, PropModeReplace, shortcut_to_name[gc->shortcut],
strlen(shortcut_to_name[gc->shortcut]));
XChangeProperty(X_Dpy, cc->win, _NET_WM_DESKTOP, XA_CARDINAL,
32, PropModeReplace, (unsigned char *)&no, 1);
TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry);
cc->group = gc;
@ -58,12 +63,16 @@ group_add(struct group_ctx *gc, struct client_ctx *cc)
static void
group_remove(struct client_ctx *cc)
{
long no = 0xffffffff;
if (cc == NULL || cc->group == NULL)
errx(1, "group_remove: a ctx is NULL");
XChangeProperty(X_Dpy, cc->win, _CWM_GRP, XA_STRING, 8,
PropModeReplace, shortcut_to_name[0],
strlen(shortcut_to_name[0]));
XChangeProperty(X_Dpy, cc->win, _NET_WM_DESKTOP, XA_CARDINAL,
32, PropModeReplace, (unsigned char *)&no, 1);
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
cc->group = NULL;
@ -128,8 +137,8 @@ void
group_init(struct screen_ctx *sc)
{
int i;
u_int32_t viewports[2] = {0, 0};
u_int32_t ndesks = CALMWM_NGROUPS, zero = 0;
long viewports[2] = {0, 0};
long ndesks = CALMWM_NGROUPS, zero = 0;
TAILQ_INIT(&sc->groupq);
sc->group_hideall = 0;
@ -188,7 +197,7 @@ group_make_autogroup(struct conf *conf, char *class, int no)
}
static void
group_setactive(struct screen_ctx *sc, int idx)
group_setactive(struct screen_ctx *sc, long idx)
{
sc->group_active = &sc->groups[idx];
XChangeProperty(X_Dpy, sc->rootwin, _NET_CURRENT_DESKTOP,
@ -410,11 +419,21 @@ group_autogroup(struct client_ctx *cc)
struct autogroupwin *aw;
struct group_ctx *gc;
int no = -1, i;
long *grpno;
unsigned char *grpstr = NULL;
if (cc->app_class == NULL || cc->app_name == NULL)
return;
if (xu_getprop(cc, _CWM_GRP, XA_STRING,
if (xu_getprop(cc, _NET_WM_DESKTOP, XA_CARDINAL,
1, (unsigned char **)&grpno) > 0) {
if (*grpno == 0xffffffff)
no = 0;
else if (*grpno > CALMWM_NGROUPS || *grpno < 0)
no = CALMWM_NGROUPS - 1;
else
no = *grpno + 1;
XFree(grpno);
} else if (xu_getprop(cc, _CWM_GRP, XA_STRING,
(CALMWM_MAXNAMELEN - 1)/sizeof(long), &grpstr) > 0) {
for (i = 0; i < sizeof(shortcut_to_name) /
sizeof(shortcut_to_name[0]); i++) {

View File

@ -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.24 2009/12/11 17:51:42 oga Exp $
* $Id: xutil.c,v 1.25 2009/12/11 17:55:42 oga Exp $
*/
#include "headers.h"
@ -190,6 +190,7 @@ char *atoms[CWM_NO_ATOMS] = {
"_NET_VIRTUAL_ROOTS",
"_NET_SHOWING_DESKTOP",
"_NET_DESKTOP_NAMES",
"_NET_WM_DESKTOP",
};
void