From 9f05eaf652a96792b8e8aee677b05a820bac52b6 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 28 Jun 2012 14:05:14 +0200 Subject: [PATCH] Simplify client focus code Signed-off-by: Julien Danjou --- client.c | 22 ++++++---------------- client.h | 1 - 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/client.c b/client.c index 1d83c5814..8a2b4989e 100644 --- a/client.c +++ b/client.c @@ -320,21 +320,6 @@ client_hasproto(client_t *c, xcb_atom_t atom) return false; } -/** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS - * \param c Client that should get focus - * \param set_input_focus Should we call xcb_set_input_focus - */ -void -client_set_focus(client_t *c, bool set_input_focus) -{ - bool takefocus = client_hasproto(c, WM_TAKE_FOCUS); - if(set_input_focus) - xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT, - c->window, globalconf.timestamp); - if(takefocus) - window_takefocus(c->window); -} - /** Prepare banning a client by running all needed lua events. * \param c The client. */ @@ -447,9 +432,14 @@ client_focus(client_t *c) client_unban(c); if (!c->nofocus) + { client_focus_update(c); + xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT, + c->window, globalconf.timestamp); + } - client_set_focus(c, !c->nofocus); + if(client_hasproto(c, WM_TAKE_FOCUS)) + window_takefocus(c->window); } /** Stack a window below. diff --git a/client.h b/client.h index 2bb66f172..d98bf2695 100644 --- a/client.h +++ b/client.h @@ -201,7 +201,6 @@ void client_unfocus(client_t *); void client_unfocus_update(client_t *); void client_stack_refresh(void); bool client_hasproto(client_t *, xcb_atom_t); -void client_set_focus(client_t *, bool); void client_ignore_enterleave_events(void); void client_restore_enterleave_events(void); void client_class_setup(lua_State *);