mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Calculate client nameqlen in client_setname(), the only place it's
needed/used.
This commit is contained in:
parent
9306c1fbd3
commit
5c13775d31
3
calmwm.h
3
calmwm.h
@ -187,8 +187,6 @@ struct client_ctx {
|
|||||||
int flags;
|
int flags;
|
||||||
int stackingorder;
|
int stackingorder;
|
||||||
struct winname_q nameq;
|
struct winname_q nameq;
|
||||||
#define CLIENT_MAXNAMEQLEN 5
|
|
||||||
int nameqlen;
|
|
||||||
char *name;
|
char *name;
|
||||||
char *label;
|
char *label;
|
||||||
char *matchname;
|
char *matchname;
|
||||||
@ -284,6 +282,7 @@ struct conf {
|
|||||||
struct cmd_q cmdq;
|
struct cmd_q cmdq;
|
||||||
int ngroups;
|
int ngroups;
|
||||||
int stickygroups;
|
int stickygroups;
|
||||||
|
int nameqlen;
|
||||||
int bwidth;
|
int bwidth;
|
||||||
int mamount;
|
int mamount;
|
||||||
int snapdist;
|
int snapdist;
|
||||||
|
13
client.c
13
client.c
@ -605,6 +605,7 @@ client_setname(struct client_ctx *cc)
|
|||||||
{
|
{
|
||||||
struct winname *wn;
|
struct winname *wn;
|
||||||
char *newname;
|
char *newname;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME], &newname))
|
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME], &newname))
|
||||||
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
||||||
@ -621,19 +622,19 @@ client_setname(struct client_ctx *cc)
|
|||||||
wn = xmalloc(sizeof(*wn));
|
wn = xmalloc(sizeof(*wn));
|
||||||
wn->name = newname;
|
wn->name = newname;
|
||||||
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
||||||
cc->nameqlen++;
|
|
||||||
|
|
||||||
match:
|
match:
|
||||||
cc->name = wn->name;
|
cc->name = wn->name;
|
||||||
|
|
||||||
/* Now, do some garbage collection. */
|
/* Do some garbage collection. */
|
||||||
if (cc->nameqlen > CLIENT_MAXNAMEQLEN) {
|
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
||||||
if ((wn = TAILQ_FIRST(&cc->nameq)) == NULL)
|
i++;
|
||||||
errx(1, "client_setname: window name queue empty");
|
if (i > Conf.nameqlen) {
|
||||||
|
wn = TAILQ_FIRST(&cc->nameq);
|
||||||
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||||
free(wn->name);
|
free(wn->name);
|
||||||
free(wn);
|
free(wn);
|
||||||
cc->nameqlen--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user