diff --git a/calmwm.c b/calmwm.c index f908a04..f95e811 100644 --- a/calmwm.c +++ b/calmwm.c @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include #include #include "calmwm.h" diff --git a/calmwm.h b/calmwm.h index df24939..fddee15 100644 --- a/calmwm.h +++ b/calmwm.h @@ -85,6 +85,10 @@ size_t strlcat(char *, const char *, size_t); #define CWM_RCYCLE 0x0002 #define CWM_INGROUP 0x0004 +/* menu */ +#define CWM_MENU_DUMMY 0x0001 +#define CWM_MENU_FILE 0x0002 + #define KBTOGROUP(X) ((X) - 1) union arg { @@ -272,7 +276,7 @@ TAILQ_HEAD(cmd_q, cmd); struct menu { TAILQ_ENTRY(menu) entry; TAILQ_ENTRY(menu) resultentry; -#define MENU_MAXENTRY 50 +#define MENU_MAXENTRY 200 char text[MENU_MAXENTRY + 1]; char print[MENU_MAXENTRY + 1]; void *ctx; @@ -367,6 +371,10 @@ void search_match_client(struct menu_q *, struct menu_q *, char *); void search_match_exec(struct menu_q *, struct menu_q *, char *); +void search_match_exec_path(struct menu_q *, struct menu_q *, + char *); +void search_match_path_any(struct menu_q *, struct menu_q *, + char *); void search_match_text(struct menu_q *, struct menu_q *, char *); void search_print_client(struct menu *, int); @@ -485,7 +493,7 @@ void xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *); void xu_ewmh_net_showing_desktop(struct screen_ctx *); void xu_ewmh_net_virtual_roots(struct screen_ctx *); void xu_ewmh_net_current_desktop(struct screen_ctx *, long); -void xu_ewmh_net_desktop_names(struct screen_ctx *, unsigned char *, int); +void xu_ewmh_net_desktop_names(struct screen_ctx *, char *, int); void xu_ewmh_net_wm_desktop(struct client_ctx *); @@ -494,7 +502,6 @@ void u_exec(char *); void u_spawn(char *); void *xcalloc(size_t, size_t); -void xfree(void *); void *xmalloc(size_t); char *xstrdup(const char *); diff --git a/client.c b/client.c index 8cb119f..57f2218 100644 --- a/client.c +++ b/client.c @@ -24,9 +24,9 @@ #include #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -166,12 +166,12 @@ client_delete(struct client_ctx *cc) while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { TAILQ_REMOVE(&cc->nameq, wn, entry); if (wn->name != emptystring) - xfree(wn->name); - xfree(wn); + free(wn->name); + free(wn); } client_freehints(cc); - xfree(cc); + free(cc); } void @@ -582,8 +582,8 @@ match: assert(wn != NULL); TAILQ_REMOVE(&cc->nameq, wn, entry); if (wn->name != emptystring) - xfree(wn->name); - xfree(wn); + free(wn->name); + free(wn); cc->nameqlen--; } } diff --git a/conf.c b/conf.c index 57e45a2..b4967e4 100644 --- a/conf.c +++ b/conf.c @@ -24,9 +24,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -202,36 +202,35 @@ conf_clear(struct conf *c) while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) { TAILQ_REMOVE(&c->cmdq, cmd, entry); - xfree(cmd); + free(cmd); } while ((kb = TAILQ_FIRST(&c->keybindingq)) != NULL) { TAILQ_REMOVE(&c->keybindingq, kb, entry); - xfree(kb); + free(kb); } while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) { TAILQ_REMOVE(&c->autogroupq, ag, entry); - xfree(ag->class); - if (ag->name) - xfree(ag->name); - xfree(ag); + free(ag->class); + free(ag->name); + free(ag); } while ((wm = TAILQ_FIRST(&c->ignoreq)) != NULL) { TAILQ_REMOVE(&c->ignoreq, wm, entry); - xfree(wm); + free(wm); } while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) { TAILQ_REMOVE(&c->mousebindingq, mb, entry); - xfree(mb); + free(mb); } for (i = 0; i < CWM_COLOR_MAX; i++) - xfree(c->color[i].name); + free(c->color[i].name); - xfree(c->font); + free(c->font); } void @@ -447,24 +446,22 @@ conf_bindname(struct conf *c, char *name, char *binding) { struct keybinding *current_binding; char *substring, *tmp; - int iter; + int i; current_binding = xcalloc(1, sizeof(*current_binding)); if ((substring = strchr(name, '-')) != NULL) { - for (iter = 0; iter < nitems(bind_mods); iter++) { - if ((tmp = strchr(name, bind_mods[iter].chr)) != + for (i = 0; i < nitems(bind_mods); i++) { + if ((tmp = strchr(name, bind_mods[i].chr)) != NULL && tmp < substring) { - current_binding->modmask |= - bind_mods[iter].mask; + current_binding->modmask |= bind_mods[i].mask; } } /* skip past the modifiers */ substring++; - } else { + } else substring = name; - } if (substring[0] == '[' && substring[strlen(substring)-1] == ']') { @@ -477,23 +474,25 @@ conf_bindname(struct conf *c, char *name, char *binding) if (current_binding->keysym == NoSymbol && current_binding->keycode == 0) { - xfree(current_binding); + free(current_binding); return; } /* We now have the correct binding, remove duplicates. */ conf_unbind(c, current_binding); - if (strcmp("unmap", binding) == 0) + if (strcmp("unmap", binding) == 0) { + free(current_binding); return; + } - for (iter = 0; iter < nitems(name_to_kbfunc); iter++) { - if (strcmp(name_to_kbfunc[iter].tag, binding) != 0) + for (i = 0; i < nitems(name_to_kbfunc); i++) { + if (strcmp(name_to_kbfunc[i].tag, binding) != 0) continue; - current_binding->callback = name_to_kbfunc[iter].handler; - current_binding->flags = name_to_kbfunc[iter].flags; - current_binding->argument = name_to_kbfunc[iter].argument; + current_binding->callback = name_to_kbfunc[i].handler; + current_binding->flags = name_to_kbfunc[i].flags; + current_binding->argument = name_to_kbfunc[i].argument; conf_grab(c, current_binding); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); return; @@ -511,10 +510,7 @@ conf_unbind(struct conf *c, struct keybinding *unbind) { struct keybinding *key = NULL, *keynxt; - for (key = TAILQ_FIRST(&c->keybindingq); - key != TAILQ_END(&c->keybindingq); key = keynxt) { - keynxt = TAILQ_NEXT(key, entry); - + TAILQ_FOREACH_SAFE(key, &c->keybindingq, entry, keynxt) { if (key->modmask != unbind->modmask) continue; @@ -523,7 +519,7 @@ conf_unbind(struct conf *c, struct keybinding *unbind) key->keysym == unbind->keysym) { conf_ungrab(c, key); TAILQ_REMOVE(&c->keybindingq, key, entry); - xfree(key); + free(key); } } } @@ -551,16 +547,15 @@ conf_mousebind(struct conf *c, char *name, char *binding) struct mousebinding *current_binding; char *substring, *tmp; const char *errstr; - int iter; + int i; current_binding = xcalloc(1, sizeof(*current_binding)); if ((substring = strchr(name, '-')) != NULL) { - for (iter = 0; iter < nitems(bind_mods); iter++) { - if ((tmp = strchr(name, bind_mods[iter].chr)) != + for (i = 0; i < nitems(bind_mods); i++) { + if ((tmp = strchr(name, bind_mods[i].chr)) != NULL && tmp < substring) { - current_binding->modmask |= - bind_mods[iter].mask; + current_binding->modmask |= bind_mods[i].mask; } } @@ -573,17 +568,20 @@ conf_mousebind(struct conf *c, char *name, char *binding) if (errstr) warnx("number of buttons is %s: %s", errstr, substring); + /* We now have the correct binding, remove duplicates. */ conf_mouseunbind(c, current_binding); - if (strcmp("unmap", binding) == 0) + if (strcmp("unmap", binding) == 0) { + free(current_binding); return; + } - for (iter = 0; iter < nitems(name_to_mousefunc); iter++) { - if (strcmp(name_to_mousefunc[iter].tag, binding) != 0) + for (i = 0; i < nitems(name_to_mousefunc); i++) { + if (strcmp(name_to_mousefunc[i].tag, binding) != 0) continue; - current_binding->context = name_to_mousefunc[iter].context; - current_binding->callback = name_to_mousefunc[iter].handler; + current_binding->context = name_to_mousefunc[i].context; + current_binding->callback = name_to_mousefunc[i].handler; TAILQ_INSERT_TAIL(&c->mousebindingq, current_binding, entry); return; } @@ -594,16 +592,13 @@ conf_mouseunbind(struct conf *c, struct mousebinding *unbind) { struct mousebinding *mb = NULL, *mbnxt; - for (mb = TAILQ_FIRST(&c->mousebindingq); - mb != TAILQ_END(&c->mousebindingq); mb = mbnxt) { - mbnxt = TAILQ_NEXT(mb, entry); - + TAILQ_FOREACH_SAFE(mb, &c->mousebindingq, entry, mbnxt) { if (mb->modmask != unbind->modmask) continue; if (mb->button == unbind->button) { TAILQ_REMOVE(&c->mousebindingq, mb, entry); - xfree(mb); + free(mb); } } } diff --git a/cwmrc.5 b/cwmrc.5 index ffc4d0c..39ab221 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 31 2012 $ +.Dd $Mdocdate: November 7 2012 $ .Dt CWMRC 5 .Os .Sh NAME @@ -58,8 +58,8 @@ is 0, matching windows will not be added to any group; this may be used to override .Dq sticky group mode . .Pp -The name and class values, respectively, for existing windows -may be obtained using +The name and class values, respectively, for existing windows +are both set in the WM_CLASS property and may be obtained using .Xr xprop 1 . .Pp .It Ic bind Ar keys command diff --git a/font.c b/font.c index 88d6519..3793e55 100644 --- a/font.c +++ b/font.c @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" diff --git a/group.c b/group.c index 3370643..fd507be 100644 --- a/group.c +++ b/group.c @@ -25,9 +25,9 @@ #include #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -129,7 +129,7 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc) } XRestackWindows(X_Dpy, winlist, gc->nhidden); - xfree(winlist); + free(winlist); gc->hidden = 0; group_setactive(sc, gc->shortcut - 1); @@ -387,7 +387,7 @@ group_menu(XButtonEvent *e) cleanup: while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } @@ -472,7 +472,7 @@ group_update_names(struct screen_ctx *sc) strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS : nstrings) * sizeof(*strings)); - p = prop_ret; + p = (char *)prop_ret; while (n < nstrings) { strings[n++] = xstrdup(p); p += strlen(p) + 1; @@ -491,7 +491,7 @@ group_update_names(struct screen_ctx *sc) if (prop_ret != NULL) XFree(prop_ret); if (sc->group_nonames != 0) - xfree(sc->group_names); + free(sc->group_names); sc->group_names = strings; sc->group_nonames = n; @@ -502,7 +502,7 @@ group_update_names(struct screen_ctx *sc) static void group_set_names(struct screen_ctx *sc) { - unsigned char *p, *q; + char *p, *q; size_t len = 0, tlen, slen; int i; diff --git a/kbfunc.c b/kbfunc.c index 48f6411..e8ab152 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -26,9 +26,9 @@ #include #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -170,7 +170,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg) while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } @@ -197,7 +197,7 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg) while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } @@ -297,10 +297,11 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg) } (void)closedir(dirp); } - xfree(path); + free(path); - if ((mi = menu_filter(sc, &menuq, label, NULL, 1, - search_match_exec, NULL)) != NULL) { + if ((mi = menu_filter(sc, &menuq, label, NULL, + CWM_MENU_DUMMY | CWM_MENU_FILE, + search_match_exec_path, NULL)) != NULL) { if (mi->text[0] == '\0') goto out; switch (cmd) { @@ -318,10 +319,10 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg) } out: if (mi != NULL && mi->dummy) - xfree(mi); + free(mi); while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } @@ -374,10 +375,10 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg) (void)strlcpy(mi->text, hostbuf, sizeof(mi->text)); TAILQ_INSERT_TAIL(&menuq, mi, entry); } - xfree(lbuf); + free(lbuf); (void)fclose(fp); - if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1, + if ((mi = menu_filter(sc, &menuq, "ssh", NULL, CWM_MENU_DUMMY, search_match_exec, NULL)) != NULL) { if (mi->text[0] == '\0') goto out; @@ -388,10 +389,10 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg) } out: if (mi != NULL && mi->dummy) - xfree(mi); + free(mi); while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } @@ -404,15 +405,14 @@ kbfunc_client_label(struct client_ctx *cc, union arg *arg) TAILQ_INIT(&menuq); /* dummy is set, so this will always return */ - mi = menu_filter(cc->sc, &menuq, "label", cc->label, 1, + mi = menu_filter(cc->sc, &menuq, "label", cc->label, CWM_MENU_DUMMY, search_match_text, NULL); if (!mi->abort) { - if (cc->label != NULL) - xfree(cc->label); + free(cc->label); cc->label = xstrdup(mi->text); } - xfree(mi); + free(mi); } void diff --git a/menu.c b/menu.c index 4a532a9..e2b6e0e 100644 --- a/menu.c +++ b/menu.c @@ -22,11 +22,12 @@ #include #include +#include #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -37,10 +38,11 @@ enum ctltype { CTL_NONE = -1, CTL_ERASEONE = 0, CTL_WIPE, CTL_UP, CTL_DOWN, CTL_RETURN, - CTL_ABORT, CTL_ALL + CTL_TAB, CTL_ABORT, CTL_ALL }; struct menu_ctx { + struct screen_ctx *sc; char searchstr[MENU_MAXENTRY + 1]; char dispstr[MENU_MAXENTRY*2 + 1]; char promptstr[MENU_MAXENTRY + 1]; @@ -54,6 +56,7 @@ struct menu_ctx { int height; int width; int num; + int flags; int x; int y; void (*match)(struct menu_q *, struct menu_q *, char *); @@ -93,7 +96,7 @@ menu_init(struct screen_ctx *sc) struct menu * menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, - char *initial, int dummy, + char *initial, int flags, void (*match)(struct menu_q *, struct menu_q *, char *), void (*print)(struct menu *, int)) { @@ -114,6 +117,8 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, xsave = mc.x; ysave = mc.y; + mc.sc = sc; + mc.flags = flags; if (prompt == NULL) { evmask = MENUMASK; mc.promptstr[0] = '\0'; @@ -181,8 +186,9 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, } } out: - if (dummy == 0 && mi->dummy) { /* no mouse based match */ - xfree(mi); + if ((mc.flags & CWM_MENU_DUMMY) == 0 && mi->dummy) { + /* no mouse based match */ + free(mi); mi = NULL; } @@ -199,6 +205,38 @@ out: return (mi); } +static struct menu * +menu_complete_path(struct menu_ctx *mc) +{ + struct menu *mi, *mr; + struct menu_q menuq; + char *path = NULL; + + path = xcalloc(1, sizeof(mr->text)); + mr = xcalloc(1, sizeof(*mr)); + + TAILQ_INIT(&menuq); + if ((mi = menu_filter(mc->sc, &menuq, mc->searchstr, NULL, + CWM_MENU_DUMMY, search_match_path_any, NULL)) != NULL) { + mr->abort = mi->abort; + mr->dummy = mi->dummy; + strlcpy(path, mi->text, sizeof(mi->text)); + } + + while ((mi = TAILQ_FIRST(&menuq)) != NULL) { + TAILQ_REMOVE(&menuq, mi, entry); + free(mi); + } + + if (path[0] != '\0') + snprintf(mr->text, sizeof(mr->text), "%s \"%s\"", + mc->searchstr, path); + else if (!mr->abort) + strlcpy(mr->text, mc->searchstr, sizeof(mr->text)); + free(path); + return (mr); +} + static struct menu * menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) @@ -257,6 +295,33 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq, mc->searchstr[0] = '\0'; mc->changed = 1; break; + case CTL_TAB: + if ((mi = TAILQ_FIRST(resultq)) != NULL) { + /* + * - We are in exec_path menu mode + * - It is equal to the input + * We got a command, launch the file menu + */ + if ((mc->flags & CWM_MENU_FILE) && + (strncmp(mc->searchstr, mi->text, + strlen(mi->text))) == 0) + return (menu_complete_path(mc)); + + /* + * Put common prefix of the results into searchstr + */ + (void)strlcpy(mc->searchstr, + mi->text, sizeof(mc->searchstr)); + while ((mi = TAILQ_NEXT(mi, resultentry)) != NULL) { + i = 0; + while (tolower(mc->searchstr[i]) == + tolower(mi->text[i])) + i++; + mc->searchstr[i] = '\0'; + } + mc->changed = 1; + } + break; case CTL_ALL: mc->list = !mc->list; break; @@ -484,6 +549,9 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr) case XK_Return: *ctl = CTL_RETURN; break; + case XK_Tab: + *ctl = CTL_TAB; + break; case XK_Up: *ctl = CTL_UP; break; diff --git a/mousefunc.c b/mousefunc.c index c615052..d61adca 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -24,9 +24,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -253,7 +253,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) } else { while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } } @@ -282,6 +282,6 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg) else while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); - xfree(mi); + free(mi); } } diff --git a/screen.c b/screen.c index 69a638a..b52856f 100644 --- a/screen.c +++ b/screen.c @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" diff --git a/search.c b/search.c index 8d58067..d016d12 100644 --- a/search.c +++ b/search.c @@ -25,13 +25,16 @@ #include #include #include +#include +#include #include #include -#include #include #include "calmwm.h" +#define PATH_EXEC 0x1 + static int strsubmatch(char *, char *, int); /* @@ -161,6 +164,43 @@ search_print_client(struct menu *mi, int list) } } +static void +search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag) +{ + struct menu *mi; + char pattern[MAXPATHLEN]; + glob_t g; + int i; + + TAILQ_INIT(resultq); + + (void)strlcpy(pattern, search, sizeof(pattern)); + (void)strlcat(pattern, "*", sizeof(pattern)); + + if (glob(pattern, GLOB_MARK, NULL, &g) != 0) + return; + for (i = 0; i < g.gl_pathc; i++) { + if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK)) + continue; + mi = xcalloc(1, sizeof(*mi)); + (void)strlcpy(mi->text, g.gl_pathv[i], sizeof(mi->text)); + TAILQ_INSERT_TAIL(resultq, mi, resultentry); + } + globfree(&g); +} + +void +search_match_path_exec(struct menu_q *menuq, struct menu_q *resultq, char *search) +{ + return (search_match_path(menuq, resultq, search, PATH_EXEC)); +} + +void +search_match_path_any(struct menu_q *menuq, struct menu_q *resultq, char *search) +{ + return (search_match_path(menuq, resultq, search, 0)); +} + void search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search) { @@ -196,6 +236,14 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search) } } +void +search_match_exec_path(struct menu_q *menuq, struct menu_q *resultq, char *search) +{ + search_match_exec(menuq, resultq, search); + if (TAILQ_EMPTY(resultq)) + search_match_path_exec(menuq, resultq, search); +} + static int strsubmatch(char *sub, char *str, int zeroidx) { diff --git a/util.c b/util.c index 54faaea..f69f880 100644 --- a/util.c +++ b/util.c @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" diff --git a/xevents.c b/xevents.c index 0d91067..e167189 100644 --- a/xevents.c +++ b/xevents.c @@ -30,9 +30,9 @@ #include #include #include +#include #include #include -#include #include #include "calmwm.h" diff --git a/xmalloc.c b/xmalloc.c index 7860b97..d0697fa 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -23,9 +23,10 @@ #include #include +#include +#include #include #include -#include #include #include "calmwm.h" @@ -35,6 +36,8 @@ xmalloc(size_t siz) { void *p; + if (siz == 0) + errx(1, "xmalloc: zero size"); if ((p = malloc(siz)) == NULL) err(1, "malloc"); @@ -46,18 +49,16 @@ xcalloc(size_t no, size_t siz) { void *p; + if (siz == 0 || no == 0) + errx(1, "xcalloc: zero size"); + if (SIZE_MAX / no < siz) + errx(1, "xcalloc: no * siz > SIZE_MAX"); if ((p = calloc(no, siz)) == NULL) err(1, "calloc"); return (p); } -void -xfree(void *p) -{ - free(p); -} - char * xstrdup(const char *str) { diff --git a/xutil.c b/xutil.c index 5dbc911..9c80dfe 100644 --- a/xutil.c +++ b/xutil.c @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include #include "calmwm.h" @@ -188,7 +188,7 @@ xu_getstrprop(Window win, Atom atm, char **text) { XTextProperty prop2; if (Xutf8TextListToTextProperty(X_Dpy, list, nitems, XUTF8StringStyle, &prop2) == Success) { - *text = xstrdup(prop2.value); + *text = xstrdup((const char *)prop2.value); XFree(prop2.value); } } else { @@ -292,7 +292,8 @@ xu_ewmh_net_supported_wm_check(struct screen_ctx *sc) XChangeProperty(X_Dpy, w, ewmh[_NET_SUPPORTING_WM_CHECK].atom, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1); XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME].atom, - XA_WM_NAME, 8, PropModeReplace, WMNAME, strlen(WMNAME)); + XA_WM_NAME, 8, PropModeReplace, (unsigned char *)WMNAME, + strlen(WMNAME)); } void @@ -339,7 +340,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc) winlist[j++] = cc->win; XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom, XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i); - xfree(winlist); + free(winlist); } void @@ -396,10 +397,10 @@ xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx) } void -xu_ewmh_net_desktop_names(struct screen_ctx *sc, unsigned 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, - cwmh[UTF8_STRING].atom, 8, PropModeReplace, data, n); + cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)data, n); } /* Application Window Properties */