Switch ignoreq to winname struct since it's basically the same thing;

removes limit on name matching.
This commit is contained in:
okan 2014-01-30 22:17:22 +00:00
parent 7928c1ad7c
commit cc1902f57c
3 changed files with 17 additions and 33 deletions

View File

@ -140,6 +140,7 @@ struct winname {
char *name; char *name;
}; };
TAILQ_HEAD(winname_q, winname); TAILQ_HEAD(winname_q, winname);
TAILQ_HEAD(ignore_q, winname);
struct client_ctx { struct client_ctx {
TAILQ_ENTRY(client_ctx) entry; TAILQ_ENTRY(client_ctx) entry;
@ -199,13 +200,6 @@ struct client_ctx {
TAILQ_HEAD(client_ctx_q, client_ctx); TAILQ_HEAD(client_ctx_q, client_ctx);
TAILQ_HEAD(cycle_entry_q, client_ctx); TAILQ_HEAD(cycle_entry_q, client_ctx);
struct winmatch {
TAILQ_ENTRY(winmatch) entry;
#define WIN_MAXTITLELEN 256
char title[WIN_MAXTITLELEN];
};
TAILQ_HEAD(winmatch_q, winmatch);
struct group_ctx { struct group_ctx {
TAILQ_ENTRY(group_ctx) entry; TAILQ_ENTRY(group_ctx) entry;
struct client_ctx_q clients; struct client_ctx_q clients;
@ -288,7 +282,7 @@ struct conf {
struct keybinding_q keybindingq; struct keybinding_q keybindingq;
struct mousebinding_q mousebindingq; struct mousebinding_q mousebindingq;
struct autogroupwin_q autogroupq; struct autogroupwin_q autogroupq;
struct winmatch_q ignoreq; struct ignore_q ignoreq;
struct cmd_q cmdq; struct cmd_q cmdq;
#define CONF_STICKY_GROUPS 0x0001 #define CONF_STICKY_GROUPS 0x0001
int flags; int flags;
@ -515,7 +509,7 @@ void conf_cursor(struct conf *);
void conf_grab_kbd(Window); void conf_grab_kbd(Window);
void conf_grab_mouse(Window); void conf_grab_mouse(Window);
void conf_init(struct conf *); void conf_init(struct conf *);
int conf_ignore(struct conf *, const char *); void conf_ignore(struct conf *, const char *);
void conf_screen(struct screen_ctx *); void conf_screen(struct screen_ctx *);
void xev_process(void); void xev_process(void);

31
conf.c
View File

@ -99,18 +99,14 @@ conf_autogroup(struct conf *c, int no, const char *val)
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
} }
int void
conf_ignore(struct conf *c, const char *val) conf_ignore(struct conf *c, const char *name)
{ {
struct winmatch *wm; struct winname *wn;
wm = xcalloc(1, sizeof(*wm)); wn = xcalloc(1, sizeof(*wn));
wn->name = xstrdup(name);
if (strlcpy(wm->title, val, sizeof(wm->title)) >= sizeof(wm->title)) TAILQ_INSERT_TAIL(&c->ignoreq, wn, entry);
return (0);
TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry);
return (1);
} }
static const char *color_binds[] = { static const char *color_binds[] = {
@ -289,7 +285,7 @@ conf_clear(struct conf *c)
{ {
struct autogroupwin *aw; struct autogroupwin *aw;
struct binding *kb, *mb; struct binding *kb, *mb;
struct winmatch *wm; struct winname *wn;
struct cmd *cmd; struct cmd *cmd;
int i; int i;
@ -310,9 +306,9 @@ conf_clear(struct conf *c)
free(aw); free(aw);
} }
while ((wm = TAILQ_FIRST(&c->ignoreq)) != NULL) { while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
TAILQ_REMOVE(&c->ignoreq, wm, entry); TAILQ_REMOVE(&c->ignoreq, wn, entry);
free(wm); free(wn);
} }
while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) { while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) {
@ -329,12 +325,11 @@ conf_clear(struct conf *c)
void void
conf_client(struct client_ctx *cc) conf_client(struct client_ctx *cc)
{ {
struct winmatch *wm; struct winname *wn;
char *wname = cc->name;
int ignore = 0; int ignore = 0;
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) { TAILQ_FOREACH(wn, &Conf.ignoreq, entry) {
if (strncasecmp(wm->title, wname, strlen(wm->title)) == 0) { if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) {
ignore = 1; ignore = 1;
break; break;
} }

View File

@ -156,12 +156,7 @@ main : FONTNAME STRING {
free($3); free($3);
} }
| IGNORE STRING { | IGNORE STRING {
if (!conf_ignore(conf, $2)) { conf_ignore(conf, $2);
yyerror("ignore windowname too long");
free($2);
YYERROR;
}
free($2);
} }
| BIND STRING string { | BIND STRING string {
if (!conf_bind_kbd(conf, $2, $3)) { if (!conf_bind_kbd(conf, $2, $3)) {