aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2016-10-04 15:52:32 +0000
committerokan2016-10-04 15:52:32 +0000
commitcb6c7d73322f62354a979a5338b41a5a297c5795 (patch)
treee419fe5eb7e5b15cdf4d1a7fdc9e83b20b918f35
parent2e16db28638cf0e78e6ddae11521a1f589179f67 (diff)
downloadcwm-cb6c7d73322f62354a979a5338b41a5a297c5795.tar.gz
Calculate client nameqlen in client_setname(), the only place it's
needed/used.
-rw-r--r--calmwm.h5
-rw-r--r--client.c15
-rw-r--r--conf.c3
3 files changed, 12 insertions, 11 deletions
diff --git a/calmwm.h b/calmwm.h
index b70c4db..d3b81b9 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.322 2016/10/04 15:18:20 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.323 2016/10/04 15:52:32 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -187,8 +187,6 @@ struct client_ctx {
int flags;
int stackingorder;
struct winname_q nameq;
-#define CLIENT_MAXNAMEQLEN 5
- int nameqlen;
char *name;
char *label;
char *matchname;
@@ -284,6 +282,7 @@ struct conf {
struct cmd_q cmdq;
int ngroups;
int stickygroups;
+ int nameqlen;
int bwidth;
int mamount;
int snapdist;
diff --git a/client.c b/client.c
index 9268d05..9644a98 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: client.c,v 1.227 2016/10/03 14:42:34 okan Exp $
+ * $OpenBSD: client.c,v 1.228 2016/10/04 15:52:32 okan Exp $
*/
#include <sys/types.h>
@@ -605,6 +605,7 @@ client_setname(struct client_ctx *cc)
{
struct winname *wn;
char *newname;
+ int i = 0;
if (!xu_getstrprop(cc->win, ewmh[_NET_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->name = newname;
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
- cc->nameqlen++;
match:
cc->name = wn->name;
- /* Now, do some garbage collection. */
- if (cc->nameqlen > CLIENT_MAXNAMEQLEN) {
- if ((wn = TAILQ_FIRST(&cc->nameq)) == NULL)
- errx(1, "client_setname: window name queue empty");
+ /* Do some garbage collection. */
+ TAILQ_FOREACH(wn, &cc->nameq, entry)
+ i++;
+ if (i > Conf.nameqlen) {
+ wn = TAILQ_FIRST(&cc->nameq);
TAILQ_REMOVE(&cc->nameq, wn, entry);
free(wn->name);
free(wn);
- cc->nameqlen--;
+ i--;
}
}
diff --git a/conf.c b/conf.c
index 156211d..6b523fb 100644
--- a/conf.c
+++ b/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: conf.c,v 1.211 2016/10/04 15:18:20 okan Exp $
+ * $OpenBSD: conf.c,v 1.212 2016/10/04 15:52:32 okan Exp $
*/
#include <sys/types.h>
@@ -259,6 +259,7 @@ conf_init(struct conf *c)
c->mamount = 1;
c->snapdist = 0;
c->ngroups = 10;
+ c->nameqlen = 5;
TAILQ_INIT(&c->ignoreq);
TAILQ_INIT(&c->cmdq);