summary refs log tree commit diff
path: root/kbfunc.c
diff options
context:
space:
mode:
authoroga <oga>2008-05-20 14:50:51 +0000
committeroga <oga>2008-05-20 14:50:51 +0000
commit1e46ba72f706d7ab2b0f7a6a14054b908348d10e (patch)
tree0efe57cdad018b6a29f0c0b65113ef08589f953d /kbfunc.c
parent3bb0b451f78d13b4624e52b726f51e4847a84a2f (diff)
downloadcwm-1e46ba72f706d7ab2b0f7a6a14054b908348d10e.tar.gz
cwm-1e46ba72f706d7ab2b0f7a6a14054b908348d10e.tar.xz
cwm-1e46ba72f706d7ab2b0f7a6a14054b908348d10e.zip
Pull out the behaviour in grab_label and search_start into one utility
function menu_filter(). The plan is to eventually merge in grab_menu too.
Shrinks the code a fair bit.

Also, change XMaskEvent for XWindowEvent to prevent getting exposes for other
windows. This is particuarly noticable on slow machines with a LOT of xterms
(todd, you're an odd man).

ok okan@, todd@.
Diffstat (limited to 'kbfunc.c')
-rw-r--r--kbfunc.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/kbfunc.c b/kbfunc.c
index 0446cb7..e006d34 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -128,9 +128,8 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
 	}
 
-	if ((mi = search_start(&menuq,
-	    search_match_client, search_print_client,
-	    "window", 0)) != NULL) {
+	if ((mi = menu_filter(&menuq, "window", NULL, 0,
+	    search_match_client, search_print_client)) != NULL) {
 		cc = (struct client_ctx *)mi->ctx;
 		if (cc->flags & CLIENT_HIDDEN)
 			client_unhide(cc);
@@ -163,8 +162,8 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
 	}
 
-	if ((mi = search_start(&menuq,
-	    search_match_text, NULL, "application", 0)) != NULL)
+	if ((mi = menu_filter(&menuq, "application", NULL, 0,
+	    search_match_text, NULL)) != NULL)
 		u_spawn(((struct cmd *)mi->ctx)->image);
 
 	while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
@@ -301,8 +300,8 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
 	}
 	xfree(path);
 
-	if ((mi = search_start(&menuq,
-	    search_match_exec, NULL, label, 1)) != NULL) {
+	if ((mi = menu_filter(&menuq, label, NULL, 1,
+	    search_match_exec, NULL)) != NULL) {
 		switch (cmd) {
 			case CWM_EXEC_PROGRAM:
 				u_spawn(mi->text);
@@ -376,8 +375,8 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg)
 	fclose(fp);
 
 
-	if ((mi = search_start(&menuq,
-	    search_match_exec, NULL, "ssh", 1)) != NULL) {
+	if ((mi = menu_filter(&menuq, "ssh", NULL, 1,
+	    search_match_exec, NULL)) != NULL) {
 		conf_reload(&Conf);
 		l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
 		    mi->text);
@@ -396,7 +395,24 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg)
 void
 kbfunc_client_label(struct client_ctx *cc, void *arg)
 {
-	grab_label(cc);
+	struct menu	*mi;
+	char		*current;
+	struct menu_q	 menuq;
+
+	TAILQ_INIT(&menuq);
+	
+	if (cc->label != NULL)
+		current = cc->label;
+	else
+		current = NULL;
+
+	if ((mi = menu_filter(&menuq, "label", current, 1,
+	    search_match_text, NULL)) != NULL) {
+		if (cc->label != NULL)
+			xfree(cc->label);
+		cc->label = xstrdup(mi->text);
+		xfree(mi);
+	}
 }
 
 void