From 762645ca32abc07ef041f5e5c7533c80901035e9 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 25 Mar 2008 11:28:07 +0100 Subject: [PATCH] client_focus() now return bool to indicate if it has given focus Signed-off-by: Julien Danjou --- client.c | 18 ++++++++++-------- client.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client.c b/client.c index 961ecf681..9ed700fc2 100644 --- a/client.c +++ b/client.c @@ -178,21 +178,21 @@ client_ban(Client *c) /** Give focus to client, or to first client if c is NULL * \param c client * \param screen Screen ID + * \param raise raise window if true + * \return true if a window (even root) has received focus, false otherwise */ -void +Bool client_focus(Client *c, int screen, Bool raise) { /* if c is NULL or invisible, take next client in the focus history */ - if(!c || (c && (!client_isvisible(c, screen)))) - { - c = focus_get_current_client(screen); + if((!c || (c && (!client_isvisible(c, screen)))) + && !(c = focus_get_current_client(screen))) /* if c is still NULL take next client in the stack */ - if(!c) - for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next); - } + for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next); + /* if c is already the focused window, then stop */ if(c == globalconf.focus->client) - return; + return False; /* unfocus current selected client */ if(globalconf.focus->client) @@ -223,6 +223,8 @@ client_focus(Client *c, int screen, Bool raise) widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS); ewmh_update_net_active_window(c->phys_screen); + + return True; } void diff --git a/client.h b/client.h index 9456cb8be..fea076bad 100644 --- a/client.h +++ b/client.h @@ -27,7 +27,7 @@ Bool client_isvisible(Client *, int); Client * client_get_bywin(Client *, Window); Client * client_get_byname(Client *, char *); -void client_focus(Client *, int, Bool); +Bool client_focus(Client *, int, Bool); void client_stack(Client *); void client_ban(Client *); void client_unban(Client *);