From db6a9e92c3a7a0734120170c708dee8398c70db3 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 15 Dec 2007 20:32:49 +0100 Subject: [PATCH] add uicb_focus_history and bind with -1 to Mod4+Tab by default --- awesomerc | 7 +++++++ focus.c | 27 +++++++++++++++++++++++++++ focus.h | 2 ++ uicb.c | 3 +++ 4 files changed, 39 insertions(+) diff --git a/awesomerc b/awesomerc index 4af8e5637..273a11d5e 100644 --- a/awesomerc +++ b/awesomerc @@ -176,6 +176,13 @@ keys command = "client_focusprev" } key + { + modkey = {"Mod4"} + key = "Tab" + command = "focus_history" + arg = "-1" + } + key { modkey = {"Mod4", "Shift"} key = "j" diff --git a/focus.c b/focus.c index 751a93dc6..b84d62dd6 100644 --- a/focus.c +++ b/focus.c @@ -21,6 +21,7 @@ #include "util.h" #include "tag.h" +#include "layout.h" #include "focus.h" static FocusList * @@ -103,4 +104,30 @@ focus_get_latest_client_for_tag(FocusList *head, TagClientLink *tc, Tag *t) return NULL; } +void +uicb_focus_history(awesome_config *awesomeconf, + int screen, + const char *arg) +{ + int i; + FocusList *fl = awesomeconf->focus; + Tag *curtag = get_current_tag(awesomeconf->screens[screen]); + + if(arg) + { + i = atoi(arg); + + if(i < 0) + { + for(; fl && i < 0; fl = fl->prev) + if(is_client_tagged(awesomeconf->screens[screen].tclink, + fl->client, + curtag)) + i++; + if(fl) + focus(fl->client, True, awesomeconf, screen); + } + } +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 diff --git a/focus.h b/focus.h index 9ecee1443..08cdaf191 100644 --- a/focus.h +++ b/focus.h @@ -28,5 +28,7 @@ void focus_add_client(FocusList **, Client *); void focus_delete_client(FocusList **, Client *); Client * focus_get_latest_client_for_tag(FocusList *, TagClientLink *, Tag *); +UICB_PROTO(uicb_focus_history); + #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 diff --git a/uicb.c b/uicb.c index b0ce627a3..4a21402c6 100644 --- a/uicb.c +++ b/uicb.c @@ -28,6 +28,7 @@ #include "layout.h" #include "mouse.h" #include "statusbar.h" +#include "focus.h" #include "layouts/tile.h" const NameFuncLink UicbList[] = @@ -75,6 +76,8 @@ const NameFuncLink UicbList[] = /* mouse.c */ {"client_movemouse", uicb_client_movemouse}, {"client_resizemouse", uicb_client_resizemouse}, + /* focus.c */ + {"focus_history", uicb_focus_history}, {NULL, NULL} };