mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Implement _NET_CURRENT_DESKTOP, _NET_DESKTOP_VIEWPORT and
_NET_DESKTOP_GEOMETRY. ok okan@
This commit is contained in:
parent
134e777cf0
commit
a7c3a7cac3
15
calmwm.c
15
calmwm.c
@ -143,12 +143,12 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
XWindowAttributes winattr;
|
XWindowAttributes winattr;
|
||||||
XSetWindowAttributes rootattr;
|
XSetWindowAttributes rootattr;
|
||||||
int fake;
|
int fake;
|
||||||
u_int ndesks = CALMWM_NGROUPS, nwins, i;
|
u_int nwins, i;
|
||||||
|
|
||||||
sc->which = which;
|
sc->which = which;
|
||||||
sc->rootwin = RootWindow(X_Dpy, sc->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);
|
conf_color(&Conf, sc);
|
||||||
|
|
||||||
@ -161,13 +161,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
/* Initialize menu window. */
|
/* Initialize menu window. */
|
||||||
menu_init(sc);
|
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);
|
xu_setwmname(sc);
|
||||||
|
|
||||||
/* Deal with existing clients. */
|
/* Deal with existing clients. */
|
||||||
|
6
calmwm.h
6
calmwm.h
@ -401,6 +401,7 @@ char *xstrdup(const char *);
|
|||||||
|
|
||||||
struct screen_ctx *screen_fromroot(Window);
|
struct screen_ctx *screen_fromroot(Window);
|
||||||
void screen_updatestackingorder(struct screen_ctx *);
|
void screen_updatestackingorder(struct screen_ctx *);
|
||||||
|
void screen_update_geometry(struct screen_ctx *, int, int);
|
||||||
void screen_init_xinerama(struct screen_ctx *);
|
void screen_init_xinerama(struct screen_ctx *);
|
||||||
XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int);
|
XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int);
|
||||||
|
|
||||||
@ -532,7 +533,10 @@ extern struct conf Conf;
|
|||||||
#define _NET_ACTIVE_WINDOW cwm_atoms[10]
|
#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 _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
|
#define CWM_NETWM_START 7
|
||||||
|
|
||||||
extern Atom cwm_atoms[CWM_NO_ATOMS];
|
extern Atom cwm_atoms[CWM_NO_ATOMS];
|
||||||
|
25
group.c
25
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_hide(struct screen_ctx *, struct group_ctx *);
|
||||||
static void group_show(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_fix_hidden_state(struct group_ctx *);
|
||||||
|
static void group_setactive(struct screen_ctx *, int);
|
||||||
|
|
||||||
const char *shortcut_to_name[] = {
|
const char *shortcut_to_name[] = {
|
||||||
"nogroup", "one", "two", "three", "four", "five", "six",
|
"nogroup", "one", "two", "three", "four", "five", "six",
|
||||||
@ -118,17 +119,17 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc)
|
|||||||
xfree(winlist);
|
xfree(winlist);
|
||||||
|
|
||||||
gc->hidden = 0;
|
gc->hidden = 0;
|
||||||
sc->group_active = gc;
|
group_setactive(sc, gc->shortcut - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
group_init(struct screen_ctx *sc)
|
group_init(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
u_int32_t viewports[2] = {0, 0}, ndesks = CALMWM_NGROUPS;
|
||||||
|
|
||||||
TAILQ_INIT(&sc->groupq);
|
TAILQ_INIT(&sc->groupq);
|
||||||
sc->group_hideall = 0;
|
sc->group_hideall = 0;
|
||||||
sc->group_active = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||||
TAILQ_INIT(&sc->groups[i].clients);
|
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);
|
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
|
void
|
||||||
@ -210,7 +224,6 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
|
|||||||
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||||
|
|
||||||
gc = &sc->groups[idx];
|
gc = &sc->groups[idx];
|
||||||
|
|
||||||
group_fix_hidden_state(gc);
|
group_fix_hidden_state(gc);
|
||||||
|
|
||||||
if (gc->hidden)
|
if (gc->hidden)
|
||||||
@ -219,7 +232,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
|
|||||||
group_hide(sc, gc);
|
group_hide(sc, gc);
|
||||||
/* XXX wtf? */
|
/* XXX wtf? */
|
||||||
if (TAILQ_EMPTY(&gc->clients))
|
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)
|
if (showgroup->hidden)
|
||||||
group_show(sc, showgroup);
|
group_show(sc, showgroup);
|
||||||
else
|
else
|
||||||
sc->group_active = showgroup;
|
group_setactive(sc, showgroup->shortcut - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called when a client is deleted */
|
/* called when a client is deleted */
|
||||||
|
11
screen.c
11
screen.c
@ -98,3 +98,14 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
|
|||||||
}
|
}
|
||||||
return (NULL);
|
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);
|
||||||
|
}
|
||||||
|
@ -368,8 +368,7 @@ xev_handle_randr(XEvent *ee)
|
|||||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||||
if (sc->which == (u_int)i) {
|
if (sc->which == (u_int)i) {
|
||||||
XRRUpdateConfiguration(ee);
|
XRRUpdateConfiguration(ee);
|
||||||
sc->xmax = rev->width;
|
screen_update_geometry(sc, rev->width, rev->height);
|
||||||
sc->ymax = rev->height;
|
|
||||||
screen_init_xinerama(sc);
|
screen_init_xinerama(sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user