diff --git a/client.c b/client.c index 18c76dbf..7ea66d1b 100644 --- a/client.c +++ b/client.c @@ -669,31 +669,7 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg) window_settrans(sel->win, delta); } -/** Swap current with next client - * \param screen Screen ID - * \param arg nothing - * \ingroup ui_callback - */ -void -uicb_client_swapnext(int screen, char *arg __attribute__ ((unused))) -{ - Client *next, *sel = globalconf.focus->client; - - if(!sel) - return; - - for(next = sel->next; next && !client_isvisible(next, screen); next = next->next); - if(!next) - for(next = globalconf.clients; next && !client_isvisible(next, screen); next = next->next); - if(next) - { - client_list_swap(&globalconf.clients, sel, next); - arrange(screen); - } -} - - -Client * +static Client * client_find_prev_visible(Client *sel) { Client *prev = NULL; @@ -708,6 +684,20 @@ client_find_prev_visible(Client *sel) return prev; } +static Client * +client_find_next_visible(Client *sel) +{ + Client *next = NULL; + + if(!sel) return NULL; + + for(next = sel->next; next && !client_isvisible(next, sel->screen); next = next->next); + if(!next) + for(next = globalconf.clients; next && !client_isvisible(next, sel->screen); next = next->next); + + return next; +} + /** Swap current with previous client * \param screen Screen ID * \param arg nothing @@ -725,6 +715,23 @@ uicb_client_swapprev(int screen, char *arg __attribute__ ((unused))) } } +/** Swap current with next client + * \param screen Screen ID + * \param arg nothing + * \ingroup ui_callback + */ +void +uicb_client_swapnext(int screen, char *arg __attribute__ ((unused))) +{ + Client *next; + + if((next = client_find_next_visible(globalconf.focus->client))) + { + client_list_swap(&globalconf.clients, globalconf.focus->client, next); + arrange(screen); + } +} + /** Move and resize client * \param screen Screen ID * \param arg x y w h diff --git a/client.h b/client.h index 42e3f998..e786babe 100644 --- a/client.h +++ b/client.h @@ -27,7 +27,6 @@ Bool client_isvisible(Client *, int); Client * get_client_bywin(Client *, Window); Client * get_client_byname(Client *, char *); -Client * client_find_prev_visible(Client *); void client_ban(Client *); void focus(Client *, Bool, int); void client_manage(Window, XWindowAttributes *, int);