new feature: add focus{next,prev}screen ui_callback functions

this allows to switch focused screen in multi-head (zaphod) mode
This commit is contained in:
Julien Danjou 2007-09-24 14:21:49 +02:00
parent 1a276a7832
commit 32654ce496
4 changed files with 47 additions and 0 deletions

View file

@ -70,6 +70,8 @@ awesome:
(("Mod4"), "b", "togglebar"), (("Mod4"), "b", "togglebar"),
(("Mod4"), "j", "focusnext"), (("Mod4"), "j", "focusnext"),
(("Mod4"), "k", "focusprev"), (("Mod4"), "k", "focusprev"),
(("Mod4", "Control"), "j", "focusnextscreen"),
(("Mod4", "Control"), "k", "focusprevscreen"),
(("Mod4"), "h", "setmwfact", "-0.05"), (("Mod4"), "h", "setmwfact", "-0.05"),
(("Mod4"), "l", "setmwfact", "+0.05"), (("Mod4"), "l", "setmwfact", "+0.05"),
(("Mod4"), "p", "setborder", "+1"), (("Mod4"), "p", "setborder", "+1"),

View file

@ -33,6 +33,7 @@
#include "draw.h" #include "draw.h"
#include "util.h" #include "util.h"
#include "statusbar.h" #include "statusbar.h"
#include "screen.h"
#include "layouts/tile.h" #include "layouts/tile.h"
#include "layouts/max.h" #include "layouts/max.h"
#include "layouts/floating.h" #include "layouts/floating.h"
@ -109,6 +110,9 @@ static const NameFuncLink KeyfuncList[] = {
{"setmwfact", uicb_setmwfact}, {"setmwfact", uicb_setmwfact},
{"setnmaster", uicb_setnmaster}, {"setnmaster", uicb_setnmaster},
{"setncols", uicb_setncols}, {"setncols", uicb_setncols},
/* screen.c */
{"focusnextscreen", uicb_focusnextscreen},
{"focusprevscreen", uicb_focusprevscreen},
/* awesome.c */ /* awesome.c */
{"quit", uicb_quit}, {"quit", uicb_quit},
/* statusbar.c */ /* statusbar.c */

View file

@ -20,7 +20,12 @@
*/ */
#include "util.h" #include "util.h"
#include "client.h"
#include "screen.h" #include "screen.h"
#include "tag.h"
#include "layout.h"
extern Client *sel, *clients;
/** Get screens info /** Get screens info
* \param disp Display ref * \param disp Display ref
@ -85,3 +90,37 @@ get_display_info(Display *disp, int screen, Statusbar statusbar)
return si; 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]);
}
}

View file

@ -31,5 +31,7 @@ typedef XineramaScreenInfo ScreenInfo;
ScreenInfo * get_screen_info(Display *, int, Statusbar, int *); ScreenInfo * get_screen_info(Display *, int, Statusbar, int *);
ScreenInfo * get_display_info(Display *disp, int, Statusbar statusbar); 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 #endif