diff --git a/calmwm.c b/calmwm.c index 71ee1f6..5ea0ac6 100644 --- a/calmwm.c +++ b/calmwm.c @@ -108,8 +108,11 @@ main(int argc, char **argv) } conf_init(&Conf); - if (conf_path && (parse_config(conf_path, &Conf) == -1)) + if (conf_path && (parse_config(conf_path, &Conf) == -1)) { warnx("config file %s has errors, not loading", conf_path); + conf_clear(&Conf); + conf_init(&Conf); + } free(conf_path); x_init(display_name); diff --git a/calmwm.h b/calmwm.h index e8042c1..b81b32c 100644 --- a/calmwm.h +++ b/calmwm.h @@ -540,7 +540,7 @@ void conf_cursor(struct conf *); void conf_grab_kbd(Window); void conf_grab_mouse(Window); void conf_init(struct conf *); -void conf_ignore(struct conf *, const char *); +int conf_ignore(struct conf *, const char *); void conf_screen(struct screen_ctx *); void xev_process(void); diff --git a/client.c b/client.c index 270a289..456fe60 100644 --- a/client.c +++ b/client.c @@ -119,7 +119,6 @@ client_init(Window win, struct screen_ctx *sc, int mapped) TAILQ_INSERT_TAIL(&Clientq, cc, entry); xu_ewmh_net_client_list(sc); - xu_ewmh_restore_net_wm_state(cc); if (mapped) diff --git a/conf.c b/conf.c index 16faf30..66e29e9 100644 --- a/conf.c +++ b/conf.c @@ -73,16 +73,18 @@ conf_autogroup(struct conf *c, int no, const char *val) TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); } -void +int conf_ignore(struct conf *c, const char *val) { struct winmatch *wm; wm = xcalloc(1, sizeof(*wm)); - (void)strlcpy(wm->title, val, sizeof(wm->title)); + if (strlcpy(wm->title, val, sizeof(wm->title)) >= sizeof(wm->title)) + return (0); TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry); + return (1); } static const char *color_binds[] = { diff --git a/parse.y b/parse.y index 6fbeb8d..861dfb9 100644 --- a/parse.y +++ b/parse.y @@ -153,7 +153,11 @@ main : FONTNAME STRING { free($3); } | IGNORE STRING { - conf_ignore(conf, $2); + if (!conf_ignore(conf, $2)) { + yyerror("ignore windowname too long"); + free($2); + YYERROR; + } free($2); } | BIND STRING string { @@ -547,78 +551,18 @@ popfile(void) int parse_config(const char *filename, struct conf *xconf) { - int errors = 0; + int errors = 0; - conf = xcalloc(1, sizeof(*conf)); + conf = xconf; if ((file = pushfile(filename)) == NULL) { - free(conf); return (-1); } topfile = file; - conf_init(conf); - yyparse(); errors = file->errors; popfile(); - if (errors) { - conf_clear(conf); - } - else { - struct autogroupwin *ag; - struct keybinding *kb; - struct winmatch *wm; - struct cmd *cmd; - struct mousebinding *mb; - int i; - - conf_clear(xconf); - - xconf->flags = conf->flags; - xconf->bwidth = conf->bwidth; - xconf->mamount = conf->mamount; - xconf->snapdist = conf->snapdist; - xconf->gap = conf->gap; - - while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) { - TAILQ_REMOVE(&conf->cmdq, cmd, entry); - TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry); - } - - while ((kb = TAILQ_FIRST(&conf->keybindingq)) != NULL) { - TAILQ_REMOVE(&conf->keybindingq, kb, entry); - TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry); - } - - while ((ag = TAILQ_FIRST(&conf->autogroupq)) != NULL) { - TAILQ_REMOVE(&conf->autogroupq, ag, entry); - TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry); - } - - while ((wm = TAILQ_FIRST(&conf->ignoreq)) != NULL) { - TAILQ_REMOVE(&conf->ignoreq, wm, entry); - TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry); - } - - while ((mb = TAILQ_FIRST(&conf->mousebindingq)) != NULL) { - TAILQ_REMOVE(&conf->mousebindingq, mb, entry); - TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry); - } - - (void)strlcpy(xconf->termpath, conf->termpath, - sizeof(xconf->termpath)); - (void)strlcpy(xconf->lockpath, conf->lockpath, - sizeof(xconf->lockpath)); - - for (i = 0; i < CWM_COLOR_NITEMS; i++) - xconf->color[i] = conf->color[i]; - - xconf->font = conf->font; - } - - free(conf); - return (errors ? -1 : 0); } diff --git a/screen.c b/screen.c index 6dfc0d4..910f353 100644 --- a/screen.c +++ b/screen.c @@ -41,20 +41,18 @@ screen_init(int which) sc = xcalloc(1, sizeof(*sc)); + TAILQ_INIT(&sc->mruq); + sc->which = which; sc->visual = DefaultVisual(X_Dpy, sc->which); sc->colormap = DefaultColormap(X_Dpy, sc->which); sc->rootwin = RootWindow(X_Dpy, sc->which); + conf_screen(sc); xu_ewmh_net_supported(sc); xu_ewmh_net_supported_wm_check(sc); - conf_screen(sc); - screen_update_geometry(sc); - - TAILQ_INIT(&sc->mruq); - group_init(sc); rootattr.cursor = Conf.cursor[CF_NORMAL]; diff --git a/xevents.c b/xevents.c index 6844f98..df5169c 100644 --- a/xevents.c +++ b/xevents.c @@ -346,8 +346,17 @@ xev_handle_clientmessage(XEvent *ee) client_ptrwarp(cc); } - if (e->message_type == ewmh[_NET_WM_DESKTOP] && e->format == 32) - group_movetogroup(cc, e->data.l[0]); + if (e->message_type == ewmh[_NET_WM_DESKTOP] && e->format == 32) { + /* + * The EWMH spec states that if the cardinal returned is + * 0xFFFFFFFF (-1) then the window should appear on all + * desktops, which in our case is assigned to group 0. + */ + if (e->data.l[0] == (unsigned long)-1) + group_movetogroup(cc, 0); + else + group_movetogroup(cc, e->data.l[0]); + } if (e->message_type == ewmh[_NET_WM_STATE] && e->format == 32) xu_ewmh_handle_net_wm_state_msg(cc,