From 32654ce496c840e82d7d4f347f9418a2215dcddb Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 24 Sep 2007 14:21:49 +0200 Subject: [PATCH] new feature: add focus{next,prev}screen ui_callback functions this allows to switch focused screen in multi-head (zaphod) mode --- awesomerc | 2 ++ config.c | 4 ++++ screen.c | 39 +++++++++++++++++++++++++++++++++++++++ screen.h | 2 ++ 4 files changed, 47 insertions(+) diff --git a/awesomerc b/awesomerc index 2320cc24..f44835e6 100644 --- a/awesomerc +++ b/awesomerc @@ -70,6 +70,8 @@ awesome: (("Mod4"), "b", "togglebar"), (("Mod4"), "j", "focusnext"), (("Mod4"), "k", "focusprev"), + (("Mod4", "Control"), "j", "focusnextscreen"), + (("Mod4", "Control"), "k", "focusprevscreen"), (("Mod4"), "h", "setmwfact", "-0.05"), (("Mod4"), "l", "setmwfact", "+0.05"), (("Mod4"), "p", "setborder", "+1"), diff --git a/config.c b/config.c index 54633ded..f4e02040 100644 --- a/config.c +++ b/config.c @@ -33,6 +33,7 @@ #include "draw.h" #include "util.h" #include "statusbar.h" +#include "screen.h" #include "layouts/tile.h" #include "layouts/max.h" #include "layouts/floating.h" @@ -109,6 +110,9 @@ static const NameFuncLink KeyfuncList[] = { {"setmwfact", uicb_setmwfact}, {"setnmaster", uicb_setnmaster}, {"setncols", uicb_setncols}, + /* screen.c */ + {"focusnextscreen", uicb_focusnextscreen}, + {"focusprevscreen", uicb_focusprevscreen}, /* awesome.c */ {"quit", uicb_quit}, /* statusbar.c */ diff --git a/screen.c b/screen.c index 9a3221e9..3b87d5c8 100644 --- a/screen.c +++ b/screen.c @@ -20,7 +20,12 @@ */ #include "util.h" +#include "client.h" #include "screen.h" +#include "tag.h" +#include "layout.h" + +extern Client *sel, *clients; /** Get screens info * \param disp Display ref @@ -85,3 +90,37 @@ get_display_info(Display *disp, int screen, Statusbar statusbar) return si; } + +void +uicb_focusnextscreen(Display *disp, + DC *drawcontext, + awesome_config * awesomeconf, + const char *arg __attribute__ ((unused))) +{ + Client *c; + int next_screen = awesomeconf->screen + 1 >= ScreenCount(disp) ? 0 : awesomeconf->screen + 1; + + for(c = clients; c && !isvisible(c, next_screen, awesomeconf[next_screen - awesomeconf->screen].selected_tags, awesomeconf[next_screen - awesomeconf->screen].ntags); c = c->next); + if(c) + { + focus(c->display, &drawcontext[next_screen - awesomeconf->screen], c, True, &awesomeconf[next_screen - awesomeconf->screen]); + restack(c->display, &drawcontext[next_screen - awesomeconf->screen], &awesomeconf[next_screen - awesomeconf->screen]); + } +} + +void +uicb_focusprevscreen(Display *disp, + DC *drawcontext, + awesome_config * awesomeconf, + const char *arg __attribute__ ((unused))) +{ + Client *c; + int prev_screen = awesomeconf->screen - 1 < 0 ? ScreenCount(disp) - 1 : awesomeconf->screen - 1; + + for(c = clients; c && !isvisible(c, prev_screen, awesomeconf[prev_screen - awesomeconf->screen].selected_tags, awesomeconf[prev_screen - awesomeconf->screen].ntags); c = c->next); + if(c) + { + focus(c->display, &drawcontext[prev_screen - awesomeconf->screen], c, True, &awesomeconf[prev_screen - awesomeconf->screen]); + restack(c->display, &drawcontext[prev_screen - awesomeconf->screen], &awesomeconf[prev_screen - awesomeconf->screen]); + } +} diff --git a/screen.h b/screen.h index b3763020..2a3f5dcc 100644 --- a/screen.h +++ b/screen.h @@ -31,5 +31,7 @@ typedef XineramaScreenInfo ScreenInfo; ScreenInfo * get_screen_info(Display *, int, Statusbar, int *); ScreenInfo * get_display_info(Display *disp, int, Statusbar statusbar); +void uicb_focusnextscreen(Display *, DC *, awesome_config *, const char *); +void uicb_focusprevscreen(Display *, DC *, awesome_config *, const char *); #endif