aboutsummaryrefslogtreecommitdiffstats
path: root/kbfunc.c
diff options
context:
space:
mode:
authoroga2008-05-20 14:50:51 +0000
committeroga2008-05-20 14:50:51 +0000
commitc4a8f44931713f32f250264ca00520aae30fc0e3 (patch)
tree28a04445e99404bad46b8fbdc9070d8635e0fe72 /kbfunc.c
parent073225cc6903924869d463a1014860a78f73b008 (diff)
downloadcwm-c4a8f44931713f32f250264ca00520aae30fc0e3.tar.gz
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 '')
-rw-r--r--kbfunc.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/kbfunc.c b/kbfunc.c
index af2fc76..683da5f 100644
--- a/kbfunc.c
+++ b/kbfunc.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.
*
- * $Id: kbfunc.c,v 1.27 2008/05/19 18:53:09 oga Exp $
+ * $Id: kbfunc.c,v 1.28 2008/05/20 14:50:51 oga Exp $
*/
#include <paths.h>
@@ -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