From 58a3c0c494461740707141562534dabcfc940551 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 23 Dec 2007 16:16:02 +0100 Subject: [PATCH] add new UICB: uicb_focus_client_byname --- client.c | 12 ++++++++++++ client.h | 1 + focus.c | 11 +++++++++++ focus.h | 1 + uicb.c | 1 + 5 files changed, 26 insertions(+) diff --git a/client.c b/client.c index 9a6f0d67..13fcc4a8 100644 --- a/client.c +++ b/client.c @@ -147,6 +147,18 @@ get_client_bywin(Client *list, Window w) return c; } +Client * +get_client_byname(Client *list, char *name) +{ + Client *c; + + for(c = list; c; c = c->next) + if(strstr(c->name, name)) + return c; + + return NULL; +} + void client_updatetitle(Client *c) { diff --git a/client.h b/client.h index 87e131ad..47449c66 100644 --- a/client.h +++ b/client.h @@ -26,6 +26,7 @@ Bool client_isvisible(Client *, int); Client * get_client_bywin(Client *, Window); +Client * get_client_byname(Client *, char *); void client_attach(Client *); void client_detach(Client *); void client_ban(Client *); diff --git a/focus.c b/focus.c index cd58593a..25ed7946 100644 --- a/focus.c +++ b/focus.c @@ -133,4 +133,15 @@ uicb_focus_history(int screen, char *arg) } } +void +uicb_focus_client_byname(int screen, char *arg) +{ + Client *c; + Tag *curtag = get_current_tag(screen); + + if(arg && (c = get_client_byname(globalconf.clients, arg)) + && is_client_tagged(c, curtag, screen)) + focus(c, True, screen); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/focus.h b/focus.h index 9c9f52cd..2aa257ea 100644 --- a/focus.h +++ b/focus.h @@ -29,6 +29,7 @@ void focus_delete_client(Client *); Client * focus_get_latest_client_for_tag(int, Tag *); UICB_PROTO(uicb_focus_history); +UICB_PROTO(uicb_focus_client_byname); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/uicb.c b/uicb.c index 40e887c6..0410279e 100644 --- a/uicb.c +++ b/uicb.c @@ -80,6 +80,7 @@ const NameFuncLink UicbList[] = {"client_resizemouse", uicb_client_resizemouse}, /* focus.c */ {"focus_history", uicb_focus_history}, + {"focus_client_byname", uicb_focus_client_byname}, /* widgets.c */ {"widget_tell", uicb_widget_tell}, {NULL, NULL}