simplify atom handling; allows us to limit to one round-trip to server
for gathering Atoms.
This commit is contained in:
parent
08420f85c8
commit
1ca1aa39ab
@ -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.
|
||||
*
|
||||
* $OpenBSD: calmwm.c,v 1.79 2013/07/08 15:46:16 okan Exp $
|
||||
* $OpenBSD: calmwm.c,v 1.80 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -37,6 +37,8 @@
|
||||
|
||||
char **cwm_argv;
|
||||
Display *X_Dpy;
|
||||
Atom cwmh[CWMH_NITEMS];
|
||||
Atom ewmh[EWMH_NITEMS];
|
||||
|
||||
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
||||
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
||||
@ -129,7 +131,7 @@ x_init(const char *dpyname)
|
||||
|
||||
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
||||
|
||||
xu_getatoms();
|
||||
conf_atoms();
|
||||
|
||||
conf_cursor(&Conf);
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
* $OpenBSD: calmwm.h,v 1.217 2013/07/09 01:24:49 okan Exp $
|
||||
* $OpenBSD: calmwm.h,v 1.218 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#ifndef _CALMWM_H_
|
||||
@ -447,6 +447,7 @@ void menuq_clear(struct menu_q *);
|
||||
|
||||
int parse_config(const char *, struct conf *);
|
||||
|
||||
void conf_atoms(void);
|
||||
void conf_autogroup(struct conf *, int, char *);
|
||||
void conf_bind_kbd(struct conf *, char *, char *);
|
||||
int conf_bind_mouse(struct conf *, char *, char *);
|
||||
@ -464,7 +465,6 @@ void xev_loop(void);
|
||||
|
||||
void xu_btn_grab(Window, int, u_int);
|
||||
void xu_btn_ungrab(Window, int, u_int);
|
||||
void xu_getatoms(void);
|
||||
int xu_getprop(Window, Atom, Atom, long, u_char **);
|
||||
int xu_get_wm_state(Window, int *);
|
||||
int xu_getstrprop(Window, Atom, char **);
|
||||
@ -558,11 +558,7 @@ enum {
|
||||
_NET_WM_STATE_ADD,
|
||||
_NET_WM_STATE_TOGGLE
|
||||
};
|
||||
struct atom_ctx {
|
||||
char *name;
|
||||
Atom atom;
|
||||
};
|
||||
extern struct atom_ctx cwmh[CWMH_NITEMS];
|
||||
extern struct atom_ctx ewmh[EWMH_NITEMS];
|
||||
extern Atom cwmh[CWMH_NITEMS];
|
||||
extern Atom ewmh[EWMH_NITEMS];
|
||||
|
||||
#endif /* _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.
|
||||
*
|
||||
* $OpenBSD: client.c,v 1.134 2013/06/10 21:37:30 okan Exp $
|
||||
* $OpenBSD: client.c,v 1.135 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -529,9 +529,9 @@ client_wm_protocols(struct client_ctx *cc)
|
||||
|
||||
if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) {
|
||||
for (i = 0; i < j; i++) {
|
||||
if (p[i] == cwmh[WM_DELETE_WINDOW].atom)
|
||||
if (p[i] == cwmh[WM_DELETE_WINDOW])
|
||||
cc->xproto |= _WM_DELETE_WINDOW;
|
||||
else if (p[i] == cwmh[WM_TAKE_FOCUS].atom)
|
||||
else if (p[i] == cwmh[WM_TAKE_FOCUS])
|
||||
cc->xproto |= _WM_TAKE_FOCUS;
|
||||
}
|
||||
XFree(p);
|
||||
@ -546,7 +546,7 @@ client_msg(struct client_ctx *cc, Atom proto)
|
||||
bzero(&cm, sizeof(cm));
|
||||
cm.type = ClientMessage;
|
||||
cm.window = cc->win;
|
||||
cm.message_type = cwmh[WM_PROTOCOLS].atom;
|
||||
cm.message_type = cwmh[WM_PROTOCOLS];
|
||||
cm.format = 32;
|
||||
cm.data.l[0] = proto;
|
||||
cm.data.l[1] = CurrentTime;
|
||||
@ -558,7 +558,7 @@ void
|
||||
client_send_delete(struct client_ctx *cc)
|
||||
{
|
||||
if (cc->xproto & _WM_DELETE_WINDOW)
|
||||
client_msg(cc, cwmh[WM_DELETE_WINDOW].atom);
|
||||
client_msg(cc, cwmh[WM_DELETE_WINDOW]);
|
||||
else
|
||||
XKillClient(X_Dpy, cc->win);
|
||||
}
|
||||
@ -569,7 +569,7 @@ client_setname(struct client_ctx *cc)
|
||||
struct winname *wn;
|
||||
char *newname;
|
||||
|
||||
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME].atom, &newname))
|
||||
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME], &newname))
|
||||
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
||||
newname = xstrdup("");
|
||||
|
||||
@ -841,7 +841,7 @@ client_getmwmhints(struct client_ctx *cc)
|
||||
struct mwm_hints *mwmh;
|
||||
|
||||
if (xu_getprop(cc->win,
|
||||
cwmh[_MOTIF_WM_HINTS].atom, cwmh[_MOTIF_WM_HINTS].atom,
|
||||
cwmh[_MOTIF_WM_HINTS], cwmh[_MOTIF_WM_HINTS],
|
||||
PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS)
|
||||
if (mwmh->flags & MWM_HINTS_DECORATIONS &&
|
||||
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
||||
|
@ -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.
|
||||
*
|
||||
* $OpenBSD: conf.c,v 1.142 2013/07/10 14:11:42 okan Exp $
|
||||
* $OpenBSD: conf.c,v 1.143 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -663,3 +663,40 @@ conf_grab_kbd(Window win)
|
||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||
xu_key_grab(win, kb->modmask, kb->keysym);
|
||||
}
|
||||
|
||||
static char *cwmhints[] = {
|
||||
"WM_STATE",
|
||||
"WM_DELETE_WINDOW",
|
||||
"WM_TAKE_FOCUS",
|
||||
"WM_PROTOCOLS",
|
||||
"_MOTIF_WM_HINTS",
|
||||
"UTF8_STRING",
|
||||
"WM_CHANGE_STATE",
|
||||
};
|
||||
static char *ewmhints[] = {
|
||||
"_NET_SUPPORTED",
|
||||
"_NET_SUPPORTING_WM_CHECK",
|
||||
"_NET_ACTIVE_WINDOW",
|
||||
"_NET_CLIENT_LIST",
|
||||
"_NET_NUMBER_OF_DESKTOPS",
|
||||
"_NET_CURRENT_DESKTOP",
|
||||
"_NET_DESKTOP_VIEWPORT",
|
||||
"_NET_DESKTOP_GEOMETRY",
|
||||
"_NET_VIRTUAL_ROOTS",
|
||||
"_NET_SHOWING_DESKTOP",
|
||||
"_NET_DESKTOP_NAMES",
|
||||
"_NET_WORKAREA",
|
||||
"_NET_WM_NAME",
|
||||
"_NET_WM_DESKTOP",
|
||||
"_NET_CLOSE_WINDOW",
|
||||
"_NET_WM_STATE",
|
||||
"_NET_WM_STATE_MAXIMIZED_VERT",
|
||||
"_NET_WM_STATE_MAXIMIZED_HORZ",
|
||||
};
|
||||
|
||||
void
|
||||
conf_atoms(void)
|
||||
{
|
||||
XInternAtoms(X_Dpy, cwmhints, nitems(cwmhints), False, cwmh);
|
||||
XInternAtoms(X_Dpy, ewmhints, nitems(ewmhints), False, ewmh);
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
* $OpenBSD: group.c,v 1.78 2013/07/09 01:24:49 okan Exp $
|
||||
* $OpenBSD: group.c,v 1.79 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -374,7 +374,7 @@ group_autogroup(struct client_ctx *cc)
|
||||
if (cc->app_class == NULL || cc->app_name == NULL)
|
||||
return;
|
||||
|
||||
if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP].atom,
|
||||
if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP],
|
||||
XA_CARDINAL, 1, (unsigned char **)&grpno) > 0) {
|
||||
if (*grpno == 0xffffffff)
|
||||
no = 0;
|
||||
@ -418,8 +418,8 @@ group_update_names(struct screen_ctx *sc)
|
||||
unsigned char *prop_ret;
|
||||
int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
|
||||
|
||||
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom,
|
||||
cwmh[UTF8_STRING].atom, 0xffffff, (u_char **)&prop_ret)) > 0) {
|
||||
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
|
||||
cwmh[UTF8_STRING], 0xffffff, (u_char **)&prop_ret)) > 0) {
|
||||
prop_ret[j - 1] = '\0'; /* paranoia */
|
||||
while (i < j) {
|
||||
if (prop_ret[i++] == '\0')
|
||||
|
@ -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.
|
||||
*
|
||||
* $OpenBSD: xevents.c,v 1.88 2013/07/10 14:15:58 okan Exp $
|
||||
* $OpenBSD: xevents.c,v 1.89 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -209,7 +209,7 @@ xev_handle_propertynotify(XEvent *ee)
|
||||
} else {
|
||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||
if (sc->rootwin == e->window) {
|
||||
if (e->atom == ewmh[_NET_DESKTOP_NAMES].atom)
|
||||
if (e->atom == ewmh[_NET_DESKTOP_NAMES])
|
||||
group_update_names(sc);
|
||||
}
|
||||
}
|
||||
@ -348,21 +348,21 @@ xev_handle_clientmessage(XEvent *ee)
|
||||
if ((cc = client_find(e->window)) == NULL)
|
||||
return;
|
||||
|
||||
if (e->message_type == cwmh[WM_CHANGE_STATE].atom &&
|
||||
if (e->message_type == cwmh[WM_CHANGE_STATE] &&
|
||||
e->format == 32 && e->data.l[0] == IconicState)
|
||||
client_hide(cc);
|
||||
|
||||
if (e->message_type == ewmh[_NET_CLOSE_WINDOW].atom)
|
||||
if (e->message_type == ewmh[_NET_CLOSE_WINDOW])
|
||||
client_send_delete(cc);
|
||||
|
||||
if (e->message_type == ewmh[_NET_ACTIVE_WINDOW].atom &&
|
||||
if (e->message_type == ewmh[_NET_ACTIVE_WINDOW] &&
|
||||
e->format == 32) {
|
||||
old_cc = client_current();
|
||||
if (old_cc)
|
||||
client_ptrsave(old_cc);
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
if (e->message_type == ewmh[_NET_WM_STATE].atom &&
|
||||
if (e->message_type == ewmh[_NET_WM_STATE] &&
|
||||
e->format == 32)
|
||||
xu_ewmh_handle_net_wm_state_msg(cc,
|
||||
e->data.l[0], e->data.l[1], e->data.l[2]);
|
||||
|
105
app/cwm/xutil.c
105
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.
|
||||
*
|
||||
* $OpenBSD: xutil.c,v 1.71 2013/07/10 14:11:42 okan Exp $
|
||||
* $OpenBSD: xutil.c,v 1.72 2013/07/15 14:50:44 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -159,7 +159,7 @@ xu_get_wm_state(Window win, int *state)
|
||||
{
|
||||
long *p = NULL;
|
||||
|
||||
if (xu_getprop(win, cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 2L,
|
||||
if (xu_getprop(win, cwmh[WM_STATE], cwmh[WM_STATE], 2L,
|
||||
(u_char **)&p) <= 0)
|
||||
return (-1);
|
||||
|
||||
@ -178,51 +178,10 @@ xu_set_wm_state(Window win, int state)
|
||||
dat[1] = None;
|
||||
|
||||
XChangeProperty(X_Dpy, win,
|
||||
cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 32,
|
||||
cwmh[WM_STATE], cwmh[WM_STATE], 32,
|
||||
PropModeReplace, (unsigned char *)dat, 2);
|
||||
}
|
||||
|
||||
struct atom_ctx cwmh[CWMH_NITEMS] = {
|
||||
{"WM_STATE", None},
|
||||
{"WM_DELETE_WINDOW", None},
|
||||
{"WM_TAKE_FOCUS", None},
|
||||
{"WM_PROTOCOLS", None},
|
||||
{"_MOTIF_WM_HINTS", None},
|
||||
{"UTF8_STRING", None},
|
||||
{"WM_CHANGE_STATE", None},
|
||||
};
|
||||
struct atom_ctx ewmh[EWMH_NITEMS] = {
|
||||
{"_NET_SUPPORTED", None},
|
||||
{"_NET_SUPPORTING_WM_CHECK", None},
|
||||
{"_NET_ACTIVE_WINDOW", None},
|
||||
{"_NET_CLIENT_LIST", None},
|
||||
{"_NET_NUMBER_OF_DESKTOPS", None},
|
||||
{"_NET_CURRENT_DESKTOP", None},
|
||||
{"_NET_DESKTOP_VIEWPORT", None},
|
||||
{"_NET_DESKTOP_GEOMETRY", None},
|
||||
{"_NET_VIRTUAL_ROOTS", None},
|
||||
{"_NET_SHOWING_DESKTOP", None},
|
||||
{"_NET_DESKTOP_NAMES", None},
|
||||
{"_NET_WORKAREA", None},
|
||||
{"_NET_WM_NAME", None},
|
||||
{"_NET_WM_DESKTOP", None},
|
||||
{"_NET_CLOSE_WINDOW", None},
|
||||
{"_NET_WM_STATE", None},
|
||||
{"_NET_WM_STATE_MAXIMIZED_VERT",None},
|
||||
{"_NET_WM_STATE_MAXIMIZED_HORZ",None},
|
||||
};
|
||||
|
||||
void
|
||||
xu_getatoms(void)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < nitems(cwmh); i++)
|
||||
cwmh[i].atom = XInternAtom(X_Dpy, cwmh[i].name, False);
|
||||
for (i = 0; i < nitems(ewmh); i++)
|
||||
ewmh[i].atom = XInternAtom(X_Dpy, ewmh[i].name, False);
|
||||
}
|
||||
|
||||
/* Root Window Properties */
|
||||
void
|
||||
xu_ewmh_net_supported(struct screen_ctx *sc)
|
||||
@ -231,9 +190,9 @@ xu_ewmh_net_supported(struct screen_ctx *sc)
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < nitems(ewmh); i++)
|
||||
atom[i] = ewmh[i].atom;
|
||||
atom[i] = ewmh[i];
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTED].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTED],
|
||||
XA_ATOM, 32, PropModeReplace, (unsigned char *)atom, EWMH_NITEMS);
|
||||
}
|
||||
|
||||
@ -243,12 +202,12 @@ xu_ewmh_net_supported_wm_check(struct screen_ctx *sc)
|
||||
Window w;
|
||||
|
||||
w = XCreateSimpleWindow(X_Dpy, sc->rootwin, -1, -1, 1, 1, 0, 0, 0);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTING_WM_CHECK].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTING_WM_CHECK],
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_SUPPORTING_WM_CHECK].atom,
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_SUPPORTING_WM_CHECK],
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME].atom,
|
||||
cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)WMNAME,
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME],
|
||||
cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)WMNAME,
|
||||
strlen(WMNAME));
|
||||
}
|
||||
|
||||
@ -257,7 +216,7 @@ xu_ewmh_net_desktop_geometry(struct screen_ctx *sc)
|
||||
{
|
||||
long geom[2] = { sc->view.w, sc->view.h };
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_GEOMETRY].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_GEOMETRY],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2);
|
||||
}
|
||||
|
||||
@ -274,7 +233,7 @@ xu_ewmh_net_workarea(struct screen_ctx *sc)
|
||||
workareas[i][3] = sc->work.h;
|
||||
}
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_WORKAREA].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_WORKAREA],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)workareas,
|
||||
CALMWM_NGROUPS * 4);
|
||||
}
|
||||
@ -294,7 +253,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
|
||||
winlist = xcalloc(i, sizeof(*winlist));
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
winlist[j++] = cc->win;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST],
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i);
|
||||
free(winlist);
|
||||
}
|
||||
@ -302,7 +261,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
|
||||
void
|
||||
xu_ewmh_net_active_window(struct screen_ctx *sc, Window w)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_ACTIVE_WINDOW].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_ACTIVE_WINDOW],
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
}
|
||||
|
||||
@ -312,7 +271,7 @@ xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *sc)
|
||||
long viewports[2] = {0, 0};
|
||||
|
||||
/* We don't support large desktops, so this is (0, 0). */
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_VIEWPORT].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_VIEWPORT],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)viewports, 2);
|
||||
}
|
||||
|
||||
@ -321,7 +280,7 @@ xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *sc)
|
||||
{
|
||||
long ndesks = CALMWM_NGROUPS;
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_NUMBER_OF_DESKTOPS].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_NUMBER_OF_DESKTOPS],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
|
||||
}
|
||||
|
||||
@ -334,7 +293,7 @@ xu_ewmh_net_showing_desktop(struct screen_ctx *sc)
|
||||
* Note that when we hide all groups, or when all groups are
|
||||
* hidden we could technically set this later on.
|
||||
*/
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SHOWING_DESKTOP].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SHOWING_DESKTOP],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&zero, 1);
|
||||
}
|
||||
|
||||
@ -342,21 +301,21 @@ void
|
||||
xu_ewmh_net_virtual_roots(struct screen_ctx *sc)
|
||||
{
|
||||
/* We don't support virtual roots, so delete if set by previous wm. */
|
||||
XDeleteProperty(X_Dpy, sc->rootwin, ewmh[_NET_VIRTUAL_ROOTS].atom);
|
||||
XDeleteProperty(X_Dpy, sc->rootwin, ewmh[_NET_VIRTUAL_ROOTS]);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CURRENT_DESKTOP].atom,
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CURRENT_DESKTOP],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom,
|
||||
cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)data, n);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
|
||||
cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)data, n);
|
||||
}
|
||||
|
||||
/* Application Window Properties */
|
||||
@ -369,7 +328,7 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc)
|
||||
if (gc)
|
||||
no = gc->shortcut;
|
||||
|
||||
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP].atom,
|
||||
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP],
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1);
|
||||
}
|
||||
|
||||
@ -378,7 +337,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
|
||||
{
|
||||
Atom *state, *p = NULL;
|
||||
|
||||
if ((*n = xu_getprop(cc->win, ewmh[_NET_WM_STATE].atom, XA_ATOM, 64L,
|
||||
if ((*n = xu_getprop(cc->win, ewmh[_NET_WM_STATE], XA_ATOM, 64L,
|
||||
(u_char **)&p)) <= 0)
|
||||
return (NULL);
|
||||
|
||||
@ -408,8 +367,8 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
|
||||
};
|
||||
|
||||
for (i = 0; i < nitems(handlers); i++) {
|
||||
if (first != ewmh[handlers[i].atom].atom &&
|
||||
second != ewmh[handlers[i].atom].atom)
|
||||
if (first != ewmh[handlers[i].atom] &&
|
||||
second != ewmh[handlers[i].atom])
|
||||
continue;
|
||||
switch (action) {
|
||||
case _NET_WM_STATE_ADD:
|
||||
@ -434,9 +393,9 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
|
||||
|
||||
atoms = xu_ewmh_get_net_wm_state(cc, &n);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom)
|
||||
if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ])
|
||||
client_hmaximize(cc);
|
||||
if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom)
|
||||
if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
|
||||
client_vmaximize(cc);
|
||||
}
|
||||
free(atoms);
|
||||
@ -451,20 +410,20 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
|
||||
oatoms = xu_ewmh_get_net_wm_state(cc, &n);
|
||||
atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom));
|
||||
for (i = j = 0; i < n; i++) {
|
||||
if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom &&
|
||||
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom)
|
||||
if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
|
||||
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
|
||||
atoms[j++] = oatoms[i];
|
||||
}
|
||||
free(oatoms);
|
||||
if (cc->flags & CLIENT_HMAXIMIZED)
|
||||
atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom;
|
||||
atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
|
||||
if (cc->flags & CLIENT_VMAXIMIZED)
|
||||
atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom;
|
||||
atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT];
|
||||
if (j > 0)
|
||||
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE].atom,
|
||||
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE],
|
||||
XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, j);
|
||||
else
|
||||
XDeleteProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE].atom);
|
||||
XDeleteProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE]);
|
||||
free(atoms);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user