mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Kill conf_get_int(), it was a silly function anyway.
Since it's only used once just put the (simplified) logic into conf_client() instead. This means we can kill an enum and CONF_IGNORECASE, too. ok okan@
This commit is contained in:
12
calmwm.h
12
calmwm.h
@@ -32,10 +32,6 @@
|
|||||||
|
|
||||||
#define CONFFILE ".cwmrc"
|
#define CONFFILE ".cwmrc"
|
||||||
|
|
||||||
enum conftype {
|
|
||||||
CONF_BWIDTH, CONF_IGNORE,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||||
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define MouseMask (ButtonMask|PointerMotionMask)
|
#define MouseMask (ButtonMask|PointerMotionMask)
|
||||||
@@ -215,12 +211,9 @@ TAILQ_HEAD(xevent_q, xevent);
|
|||||||
* Match a window.
|
* Match a window.
|
||||||
*/
|
*/
|
||||||
#define CONF_MAX_WINTITLE 256
|
#define CONF_MAX_WINTITLE 256
|
||||||
#define CONF_IGNORECASE 0x01
|
|
||||||
struct winmatch {
|
struct winmatch {
|
||||||
TAILQ_ENTRY(winmatch) entry;
|
TAILQ_ENTRY(winmatch) entry;
|
||||||
|
|
||||||
char title[CONF_MAX_WINTITLE];
|
char title[CONF_MAX_WINTITLE];
|
||||||
int opts;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TAILQ_HEAD(winmatch_q, winmatch);
|
TAILQ_HEAD(winmatch_q, winmatch);
|
||||||
@@ -422,16 +415,11 @@ struct screen_ctx *screen_current(void);
|
|||||||
void screen_updatestackingorder(void);
|
void screen_updatestackingorder(void);
|
||||||
|
|
||||||
void conf_setup(struct conf *, const char *);
|
void conf_setup(struct conf *, const char *);
|
||||||
int conf_get_int(struct client_ctx *, enum conftype);
|
|
||||||
void conf_client(struct client_ctx *);
|
void conf_client(struct client_ctx *);
|
||||||
void conf_bindkey(struct conf *,
|
|
||||||
void (*)(struct client_ctx *, void *),
|
|
||||||
int, int, int, void *);
|
|
||||||
void conf_bindname(struct conf *, char *, char *);
|
void conf_bindname(struct conf *, char *, char *);
|
||||||
void conf_unbind(struct conf *, struct keybinding *);
|
void conf_unbind(struct conf *, struct keybinding *);
|
||||||
int conf_changed(char *);
|
int conf_changed(char *);
|
||||||
void conf_reload(struct conf *);
|
void conf_reload(struct conf *);
|
||||||
char *conf_get_str(struct client_ctx *, enum conftype);
|
|
||||||
|
|
||||||
void kbfunc_client_lower(struct client_ctx *, void *);
|
void kbfunc_client_lower(struct client_ctx *, void *);
|
||||||
void kbfunc_client_raise(struct client_ctx *, void *);
|
void kbfunc_client_raise(struct client_ctx *, void *);
|
||||||
|
|||||||
62
conf.c
62
conf.c
@@ -174,53 +174,27 @@ conf_setup(struct conf *c, const char *conffile)
|
|||||||
(void)parse_config(c->conf_path, c);
|
(void)parse_config(c->conf_path, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
conf_get_int(struct client_ctx *cc, enum conftype ctype)
|
|
||||||
{
|
|
||||||
int val = -1, ignore = 0;
|
|
||||||
char *wname;
|
|
||||||
struct winmatch *wm;
|
|
||||||
|
|
||||||
wname = cc->name;
|
|
||||||
|
|
||||||
/* Can wname be NULL? */
|
|
||||||
|
|
||||||
if (wname != NULL) {
|
|
||||||
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) {
|
|
||||||
int (*cmpfun)(const char *, const char *, size_t) =
|
|
||||||
wm->opts & CONF_IGNORECASE ? strncasecmp : strncmp;
|
|
||||||
if ((*cmpfun)(wm->title, wname, strlen(wm->title)) == 0) {
|
|
||||||
ignore = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
ignore = 1;
|
|
||||||
|
|
||||||
switch (ctype) {
|
|
||||||
case CONF_BWIDTH:
|
|
||||||
/*
|
|
||||||
* XXX this will be a list, specified in the
|
|
||||||
* configuration file.
|
|
||||||
*/
|
|
||||||
val = ignore ? 0 : 3;
|
|
||||||
break;
|
|
||||||
case CONF_IGNORE:
|
|
||||||
val = ignore;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
conf_client(struct client_ctx *cc)
|
conf_client(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
cc->bwidth = conf_get_int(cc, CONF_BWIDTH);
|
struct winmatch *wm;
|
||||||
cc->flags |= conf_get_int(cc, CONF_IGNORE) ? CLIENT_IGNORE : 0;
|
char *wname = cc->name;
|
||||||
|
int ignore = 0;
|
||||||
|
|
||||||
|
/* Can wname be NULL? */
|
||||||
|
if (wname != NULL) {
|
||||||
|
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) {
|
||||||
|
if (strncasecmp(wm->title, wname, strlen(wm->title))
|
||||||
|
== 0) {
|
||||||
|
ignore = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
ignore = 1;
|
||||||
|
|
||||||
|
cc->bwidth = ignore ? 0 : 3;
|
||||||
|
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
1
parse.y
1
parse.y
@@ -152,7 +152,6 @@ main : FONTNAME STRING {
|
|||||||
|
|
||||||
XCALLOC(wm, struct winmatch);
|
XCALLOC(wm, struct winmatch);
|
||||||
strlcpy(wm->title, $2, sizeof(wm->title));
|
strlcpy(wm->title, $2, sizeof(wm->title));
|
||||||
wm->opts |= CONF_IGNORECASE;
|
|
||||||
TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
|
TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
|
||||||
|
|
||||||
free($2);
|
free($2);
|
||||||
|
|||||||
Reference in New Issue
Block a user