cvsimport

This commit is contained in:
okan
2013-07-16 14:30:48 +00:00
8 changed files with 140 additions and 159 deletions

View File

@@ -37,6 +37,8 @@
char **cwm_argv; char **cwm_argv;
Display *X_Dpy; Display *X_Dpy;
Atom cwmh[CWMH_NITEMS];
Atom ewmh[EWMH_NITEMS];
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq); struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq); 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); HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
xu_getatoms(); conf_atoms();
conf_cursor(&Conf); conf_cursor(&Conf);

109
calmwm.h
View File

@@ -115,7 +115,7 @@ enum color {
CWM_COLOR_MENU_BG, CWM_COLOR_MENU_BG,
CWM_COLOR_MENU_FONT, CWM_COLOR_MENU_FONT,
CWM_COLOR_MENU_FONT_SEL, CWM_COLOR_MENU_FONT_SEL,
CWM_COLOR_MAX CWM_COLOR_NITEMS
}; };
struct geom { struct geom {
@@ -235,7 +235,7 @@ struct screen_ctx {
struct geom work; /* workable area, gap-applied */ struct geom work; /* workable area, gap-applied */
struct gap gap; struct gap gap;
struct cycle_entry_q mruq; struct cycle_entry_q mruq;
XftColor xftcolor[CWM_COLOR_MAX]; XftColor xftcolor[CWM_COLOR_NITEMS];
XftDraw *xftdraw; XftDraw *xftdraw;
XftFont *xftfont; XftFont *xftfont;
int xinerama_no; int xinerama_no;
@@ -309,7 +309,7 @@ struct conf {
#define CONF_SNAPDIST 0 #define CONF_SNAPDIST 0
int snapdist; int snapdist;
struct gap gap; struct gap gap;
char *color[CWM_COLOR_MAX]; char *color[CWM_COLOR_NITEMS];
char termpath[MAXPATHLEN]; char termpath[MAXPATHLEN];
char lockpath[MAXPATHLEN]; char lockpath[MAXPATHLEN];
char known_hosts[MAXPATHLEN]; char known_hosts[MAXPATHLEN];
@@ -330,6 +330,53 @@ struct mwm_hints {
#define MWM_DECOR_ALL (1<<0) #define MWM_DECOR_ALL (1<<0)
#define MWM_DECOR_BORDER (1<<1) #define MWM_DECOR_BORDER (1<<1)
extern Display *X_Dpy;
extern struct screen_ctx_q Screenq;
extern struct client_ctx_q Clientq;
extern struct conf Conf;
extern char *homedir;
extern int HasRandr, Randr_ev;
enum {
WM_STATE,
WM_DELETE_WINDOW,
WM_TAKE_FOCUS,
WM_PROTOCOLS,
_MOTIF_WM_HINTS,
UTF8_STRING,
WM_CHANGE_STATE,
CWMH_NITEMS
};
enum {
_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,
#define _NET_WM_STATES_NITEMS 2
_NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ,
EWMH_NITEMS
};
enum {
_NET_WM_STATE_REMOVE,
_NET_WM_STATE_ADD,
_NET_WM_STATE_TOGGLE
};
extern Atom cwmh[CWMH_NITEMS];
extern Atom ewmh[EWMH_NITEMS];
__dead void usage(void); __dead void usage(void);
void client_applysizehints(struct client_ctx *); void client_applysizehints(struct client_ctx *);
@@ -459,6 +506,7 @@ void menuq_clear(struct menu_q *);
int parse_config(const char *, struct conf *); int parse_config(const char *, struct conf *);
void conf_atoms(void);
void conf_autogroup(struct conf *, int, char *); void conf_autogroup(struct conf *, int, char *);
void conf_bind_kbd(struct conf *, char *, char *); void conf_bind_kbd(struct conf *, char *, char *);
int conf_bind_mouse(struct conf *, char *, char *); int conf_bind_mouse(struct conf *, char *, char *);
@@ -476,7 +524,6 @@ void xev_loop(void);
void xu_btn_grab(Window, int, u_int); void xu_btn_grab(Window, int, u_int);
void xu_btn_ungrab(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_getprop(Window, Atom, Atom, long, u_char **);
int xu_get_wm_state(Window, int *); int xu_get_wm_state(Window, int *);
int xu_getstrprop(Window, Atom, char **); int xu_getstrprop(Window, Atom, char **);
@@ -523,58 +570,4 @@ int xasprintf(char **, const char *, ...)
__attribute__((__format__ (printf, 2, 3))) __attribute__((__format__ (printf, 2, 3)))
__attribute__((__nonnull__ (2))); __attribute__((__nonnull__ (2)));
/* Externs */
extern Display *X_Dpy;
extern struct screen_ctx_q Screenq;
extern struct client_ctx_q Clientq;
extern struct conf Conf;
extern char *homedir;
extern int HasRandr, Randr_ev;
enum {
WM_STATE,
WM_DELETE_WINDOW,
WM_TAKE_FOCUS,
WM_PROTOCOLS,
_MOTIF_WM_HINTS,
UTF8_STRING,
WM_CHANGE_STATE,
CWMH_NITEMS
};
enum {
_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,
#define _NET_WM_STATES_NITEMS 2
_NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ,
EWMH_NITEMS
};
enum {
_NET_WM_STATE_REMOVE,
_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];
#endif /* _CALMWM_H_ */ #endif /* _CALMWM_H_ */

View File

@@ -529,9 +529,9 @@ client_wm_protocols(struct client_ctx *cc)
if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) { if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) {
for (i = 0; i < j; i++) { 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; 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; cc->xproto |= _WM_TAKE_FOCUS;
} }
XFree(p); XFree(p);
@@ -546,7 +546,7 @@ client_msg(struct client_ctx *cc, Atom proto)
bzero(&cm, sizeof(cm)); bzero(&cm, sizeof(cm));
cm.type = ClientMessage; cm.type = ClientMessage;
cm.window = cc->win; cm.window = cc->win;
cm.message_type = cwmh[WM_PROTOCOLS].atom; cm.message_type = cwmh[WM_PROTOCOLS];
cm.format = 32; cm.format = 32;
cm.data.l[0] = proto; cm.data.l[0] = proto;
cm.data.l[1] = CurrentTime; cm.data.l[1] = CurrentTime;
@@ -558,7 +558,7 @@ void
client_send_delete(struct client_ctx *cc) client_send_delete(struct client_ctx *cc)
{ {
if (cc->xproto & _WM_DELETE_WINDOW) if (cc->xproto & _WM_DELETE_WINDOW)
client_msg(cc, cwmh[WM_DELETE_WINDOW].atom); client_msg(cc, cwmh[WM_DELETE_WINDOW]);
else else
XKillClient(X_Dpy, cc->win); XKillClient(X_Dpy, cc->win);
} }
@@ -569,7 +569,7 @@ client_setname(struct client_ctx *cc)
struct winname *wn; struct winname *wn;
char *newname; 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)) if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
newname = xstrdup(""); newname = xstrdup("");
@@ -840,8 +840,7 @@ client_getmwmhints(struct client_ctx *cc)
{ {
struct mwm_hints *mwmh; struct mwm_hints *mwmh;
if (xu_getprop(cc->win, if (xu_getprop(cc->win, cwmh[_MOTIF_WM_HINTS], cwmh[_MOTIF_WM_HINTS],
cwmh[_MOTIF_WM_HINTS].atom, cwmh[_MOTIF_WM_HINTS].atom,
PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS) PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS)
if (mwmh->flags & MWM_HINTS_DECORATIONS && if (mwmh->flags & MWM_HINTS_DECORATIONS &&
!(mwmh->decorations & MWM_DECOR_ALL) && !(mwmh->decorations & MWM_DECOR_ALL) &&

41
conf.c
View File

@@ -288,7 +288,7 @@ conf_clear(struct conf *c)
free(mb); free(mb);
} }
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_NITEMS; i++)
free(c->color[i]); free(c->color[i]);
free(c->font); free(c->font);
@@ -624,7 +624,7 @@ conf_unbind_mouse(struct conf *c, struct mousebinding *unbind)
} }
} }
static int cursor_binds[CF_NITEMS] = { static int cursor_binds[] = {
XC_X_cursor, /* CF_DEFAULT */ XC_X_cursor, /* CF_DEFAULT */
XC_fleur, /* CF_MOVE */ XC_fleur, /* CF_MOVE */
XC_left_ptr, /* CF_NORMAL */ XC_left_ptr, /* CF_NORMAL */
@@ -663,3 +663,40 @@ conf_grab_kbd(Window win)
TAILQ_FOREACH(kb, &Conf.keybindingq, entry) TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
xu_key_grab(win, kb->modmask, kb->keysym); 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);
}

View File

@@ -374,7 +374,7 @@ group_autogroup(struct client_ctx *cc)
if (cc->app_class == NULL || cc->app_name == NULL) if (cc->app_class == NULL || cc->app_name == NULL)
return; 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) { XA_CARDINAL, 1, (unsigned char **)&grpno) > 0) {
if (*grpno == 0xffffffff) if (*grpno == 0xffffffff)
no = 0; no = 0;
@@ -418,8 +418,8 @@ group_update_names(struct screen_ctx *sc)
unsigned char *prop_ret; unsigned char *prop_ret;
int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0; int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom, if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
cwmh[UTF8_STRING].atom, 0xffffff, (u_char **)&prop_ret)) > 0) { cwmh[UTF8_STRING], 0xffffff, (u_char **)&prop_ret)) > 0) {
prop_ret[j - 1] = '\0'; /* paranoia */ prop_ret[j - 1] = '\0'; /* paranoia */
while (i < j) { while (i < j) {
if (prop_ret[i++] == '\0') if (prop_ret[i++] == '\0')

View File

@@ -599,7 +599,7 @@ parse_config(const char *filename, struct conf *xconf)
(void)strlcpy(xconf->lockpath, conf->lockpath, (void)strlcpy(xconf->lockpath, conf->lockpath,
sizeof(xconf->lockpath)); sizeof(xconf->lockpath));
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_NITEMS; i++)
xconf->color[i] = conf->color[i]; xconf->color[i] = conf->color[i];
xconf->font = conf->font; xconf->font = conf->font;

View File

@@ -209,7 +209,7 @@ xev_handle_propertynotify(XEvent *ee)
} else { } else {
TAILQ_FOREACH(sc, &Screenq, entry) { TAILQ_FOREACH(sc, &Screenq, entry) {
if (sc->rootwin == e->window) { if (sc->rootwin == e->window) {
if (e->atom == ewmh[_NET_DESKTOP_NAMES].atom) if (e->atom == ewmh[_NET_DESKTOP_NAMES])
group_update_names(sc); group_update_names(sc);
} }
} }
@@ -348,22 +348,20 @@ xev_handle_clientmessage(XEvent *ee)
if ((cc = client_find(e->window)) == NULL) if ((cc = client_find(e->window)) == NULL)
return; return;
if (e->message_type == cwmh[WM_CHANGE_STATE].atom && if (e->message_type == cwmh[WM_CHANGE_STATE] && e->format == 32 &&
e->format == 32 && e->data.l[0] == IconicState) e->data.l[0] == IconicState)
client_hide(cc); client_hide(cc);
if (e->message_type == ewmh[_NET_CLOSE_WINDOW].atom) if (e->message_type == ewmh[_NET_CLOSE_WINDOW])
client_send_delete(cc); client_send_delete(cc);
if (e->message_type == ewmh[_NET_ACTIVE_WINDOW].atom && if (e->message_type == ewmh[_NET_ACTIVE_WINDOW] && e->format == 32) {
e->format == 32) {
old_cc = client_current(); old_cc = client_current();
if (old_cc) if (old_cc)
client_ptrsave(old_cc); client_ptrsave(old_cc);
client_ptrwarp(cc); client_ptrwarp(cc);
} }
if (e->message_type == ewmh[_NET_WM_STATE].atom && if (e->message_type == ewmh[_NET_WM_STATE] && e->format == 32)
e->format == 32)
xu_ewmh_handle_net_wm_state_msg(cc, xu_ewmh_handle_net_wm_state_msg(cc,
e->data.l[0], e->data.l[1], e->data.l[2]); e->data.l[0], e->data.l[1], e->data.l[2]);
} }

110
xutil.c
View File

@@ -159,7 +159,7 @@ xu_get_wm_state(Window win, int *state)
{ {
long *p = NULL; 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) (u_char **)&p) <= 0)
return (-1); return (-1);
@@ -177,64 +177,16 @@ xu_set_wm_state(Window win, int state)
dat[0] = state; dat[0] = state;
dat[1] = None; dat[1] = None;
XChangeProperty(X_Dpy, win, XChangeProperty(X_Dpy, win, cwmh[WM_STATE], cwmh[WM_STATE], 32,
cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 32,
PropModeReplace, (unsigned char *)dat, 2); 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 */ /* Root Window Properties */
void void
xu_ewmh_net_supported(struct screen_ctx *sc) xu_ewmh_net_supported(struct screen_ctx *sc)
{ {
Atom atom[EWMH_NITEMS]; XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTED],
u_int i; XA_ATOM, 32, PropModeReplace, (unsigned char *)ewmh, EWMH_NITEMS);
for (i = 0; i < nitems(ewmh); i++)
atom[i] = ewmh[i].atom;
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTED].atom,
XA_ATOM, 32, PropModeReplace, (unsigned char *)atom, EWMH_NITEMS);
} }
void void
@@ -243,12 +195,12 @@ xu_ewmh_net_supported_wm_check(struct screen_ctx *sc)
Window w; Window w;
w = XCreateSimpleWindow(X_Dpy, sc->rootwin, -1, -1, 1, 1, 0, 0, 0); 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); 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); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME].atom, XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME],
cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)WMNAME, cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)WMNAME,
strlen(WMNAME)); strlen(WMNAME));
} }
@@ -257,7 +209,7 @@ xu_ewmh_net_desktop_geometry(struct screen_ctx *sc)
{ {
long geom[2] = { sc->view.w, sc->view.h }; 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2);
} }
@@ -274,7 +226,7 @@ xu_ewmh_net_workarea(struct screen_ctx *sc)
workareas[i][3] = sc->work.h; 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, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)workareas,
CALMWM_NGROUPS * 4); CALMWM_NGROUPS * 4);
} }
@@ -294,7 +246,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
winlist = xcalloc(i, sizeof(*winlist)); winlist = xcalloc(i, sizeof(*winlist));
TAILQ_FOREACH(cc, &Clientq, entry) TAILQ_FOREACH(cc, &Clientq, entry)
winlist[j++] = cc->win; 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); XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i);
free(winlist); free(winlist);
} }
@@ -302,7 +254,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
void void
xu_ewmh_net_active_window(struct screen_ctx *sc, Window w) 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); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
} }
@@ -312,7 +264,7 @@ xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *sc)
long viewports[2] = {0, 0}; long viewports[2] = {0, 0};
/* We don't support large desktops, so this is (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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)viewports, 2);
} }
@@ -321,7 +273,7 @@ xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *sc)
{ {
long ndesks = CALMWM_NGROUPS; 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
} }
@@ -334,7 +286,7 @@ xu_ewmh_net_showing_desktop(struct screen_ctx *sc)
* Note that when we hide all groups, or when all groups are * Note that when we hide all groups, or when all groups are
* hidden we could technically set this later on. * 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&zero, 1);
} }
@@ -342,21 +294,21 @@ void
xu_ewmh_net_virtual_roots(struct screen_ctx *sc) xu_ewmh_net_virtual_roots(struct screen_ctx *sc)
{ {
/* We don't support virtual roots, so delete if set by previous wm. */ /* 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 void
xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx) 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
} }
void void
xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n) xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n)
{ {
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom, XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)data, n); cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)data, n);
} }
/* Application Window Properties */ /* Application Window Properties */
@@ -369,7 +321,7 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc)
if (gc) if (gc)
no = gc->shortcut; 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1);
} }
@@ -378,7 +330,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
{ {
Atom *state, *p = NULL; 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) (u_char **)&p)) <= 0)
return (NULL); return (NULL);
@@ -408,8 +360,8 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
}; };
for (i = 0; i < nitems(handlers); i++) { for (i = 0; i < nitems(handlers); i++) {
if (first != ewmh[handlers[i].atom].atom && if (first != ewmh[handlers[i].atom] &&
second != ewmh[handlers[i].atom].atom) second != ewmh[handlers[i].atom])
continue; continue;
switch (action) { switch (action) {
case _NET_WM_STATE_ADD: case _NET_WM_STATE_ADD:
@@ -434,9 +386,9 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
atoms = xu_ewmh_get_net_wm_state(cc, &n); atoms = xu_ewmh_get_net_wm_state(cc, &n);
for (i = 0; i < n; i++) { 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); 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); client_vmaximize(cc);
} }
free(atoms); free(atoms);
@@ -451,20 +403,20 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
oatoms = xu_ewmh_get_net_wm_state(cc, &n); oatoms = xu_ewmh_get_net_wm_state(cc, &n);
atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom)); atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom));
for (i = j = 0; i < n; i++) { for (i = j = 0; i < n; i++) {
if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom && if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom) oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
atoms[j++] = oatoms[i]; atoms[j++] = oatoms[i];
} }
free(oatoms); free(oatoms);
if (cc->flags & CLIENT_HMAXIMIZED) 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) 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) 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); XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, j);
else else
XDeleteProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE].atom); XDeleteProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE]);
free(atoms); free(atoms);
} }