diff --git a/src/client.c b/src/client.c index 9245e24..15e4f65 100644 --- a/src/client.c +++ b/src/client.c @@ -825,7 +825,7 @@ client_new(Window w, XWindowAttributes *wa, bool scan) /* C attributes */ c->win = w; c->flags = 0; - c->screen = W->screen; + c->screen = screen_update_sel(); c->theme = THEME_DEFAULT; c->tag = NULL; c->tabmaster = NULL; diff --git a/src/client.h b/src/client.h index 8fd18cc..443d1ab 100644 --- a/src/client.h +++ b/src/client.h @@ -21,7 +21,7 @@ struct client *client_gb_titlebar(Window w); struct client *client_next_with_pos(struct client *bc, enum position p); void client_swap2(struct client *c1, struct client *c2); void client_swap(struct client *c, enum position p); -#define CCOL(c) (c == c->tag->sel ? &c->scol : &c->ncol) +#define CCOL(c) (c == W->client ? &c->scol : &c->ncol) void client_frame_update(struct client *c, struct colpair *cp); void client_tab_pull(struct client *c); void _client_tab(struct client *c, struct client *cm); diff --git a/src/config.h b/src/config.h index 0ba71a7..9dc8583 100644 --- a/src/config.h +++ b/src/config.h @@ -16,6 +16,7 @@ #include "client.h" #include "status.h" #include "mouse.h" +#include "screen.h" #define THEME_DEFAULT (SLIST_FIRST(&W->h.theme)) @@ -76,6 +77,10 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = { "mouse_swap", uicb_mouse_move }, { "mouse_tab", uicb_mouse_tab }, + /* Screen */ + { "screen_next", uicb_screen_next }, + { "screen_prev", uicb_screen_prev }, + { NULL, NULL } }; diff --git a/src/screen.c b/src/screen.c index b90f057..6dfb080 100644 --- a/src/screen.c +++ b/src/screen.c @@ -88,6 +88,44 @@ screen_update_sel(void) return W->screen; } +static void +screen_select(struct screen *s) +{ + XWarpPointer(W->dpy, None, W->root, 0, 0, 0, 0, + s->ugeo.x + (s->ugeo.w >> 1), + s->ugeo.y + (s->ugeo.h >> 1)); + + W->screen = s; +} + +void +uicb_screen_next(Uicb cmd) +{ + struct screen *s; + (void)cmd; + + if(!(s = SLIST_NEXT(W->screen, next))) + s = SLIST_FIRST(&W->h.screen); + + screen_select(s); +} + +void +uicb_screen_prev(Uicb cmd) +{ + struct screen *s; + (void)cmd; + + SLIST_FOREACH(s, &W->h.screen, next) + if(SLIST_NEXT(W->screen, next) == s) + { + screen_select(s); + return; + } + + screen_select(SLIST_FIRST(&W->h.screen)); +} + void screen_free(void) { diff --git a/src/screen.h b/src/screen.h index 25d9124..41e60de 100644 --- a/src/screen.h +++ b/src/screen.h @@ -43,5 +43,8 @@ screen_gb_mouse(void) void screen_init(void); struct screen* screen_update_sel(void); void screen_free(void); +void uicb_screen_next(Uicb cmd); +void uicb_screen_prev(Uicb cmd); + #endif /* SCREEN_H */ diff --git a/wmfsrc b/wmfsrc index 51c370d..4b7ecba 100644 --- a/wmfsrc +++ b/wmfsrc @@ -130,7 +130,10 @@ #[key] mod = {"Super"} key = "z" func = "tag" cmd = "2" [/key] [key] mod = {"Control"} key = "Right" func = "tag_next" [/key] - [key] mod = {"Control"} key = "Left" func = "tag_prev" [/key] + [key] mod = {"Control"} key = "Left" func = "tag_prev" [/key] + + [key] mod = {"Control"} key = "Up" func = "screen_next" [/key] + [key] mod = {"Control"} key = "Down" func = "screen_prev" [/key] [key] mod = {"Super"} key = "q" func = "client_close" [/key]