cvsimport

This commit is contained in:
okan 2014-01-28 20:22:21 +00:00
commit 2b233f0548
7 changed files with 30 additions and 75 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)

6
conf.c
View File

@ -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[] = {

70
parse.y
View File

@ -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);
}

View File

@ -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];

View File

@ -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,