From 9fbdecf26c6ad21ce6f05bad59ca744f81268649 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 30 Jul 2010 22:07:24 +0200 Subject: [PATCH] Split up client_getbywin() This splits up client_getbywin() into two different functions. One of them finds a client by its frame window, the other checks against the client's own window. Signed-off-by: Uli Schlachter --- event.c | 8 ++++---- mouse.c | 2 +- objects/client.c | 16 +++++++++++++++- objects/client.h | 2 ++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/event.c b/event.c index 45365443..2fb89dab 100644 --- a/event.c +++ b/event.c @@ -183,7 +183,7 @@ event_handle_button(xcb_button_press_event_t *ev) lua_pop(globalconf.L, 1); } - else if((c = client_getbywin(ev->event))) + else if((c = client_getbyframewin(ev->event))) { luaA_object_push(globalconf.L, c); event_button_callback(ev, &c->buttons, -1, 1, NULL); @@ -412,7 +412,7 @@ event_handle_leavenotify(xcb_leave_notify_event_t *ev) if(ev->mode != XCB_NOTIFY_MODE_NORMAL) return; - if((c = client_getbywin(ev->event))) + if((c = client_getbyframewin(ev->event))) { luaA_object_push(globalconf.L, c); luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0); @@ -469,7 +469,7 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev) lua_pop(globalconf.L, 1); } - if((c = client_getbywin(ev->event))) + if((c = client_getbyframewin(ev->event))) { luaA_object_push(globalconf.L, c); luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0); @@ -551,7 +551,7 @@ event_handle_key(xcb_key_press_event_t *ev) /* get keysym ignoring all modifiers */ xcb_keysym_t keysym = keyresolv_get_keysym(ev->detail, 0); client_t *c; - if((c = client_getbywin(ev->event))) + if((c = client_getbyframewin(ev->event))) { luaA_object_push(globalconf.L, c); event_key_callback(ev, &c->keys, -1, 1, &keysym); diff --git a/mouse.c b/mouse.c index e5cf8488..2a1b95f5 100644 --- a/mouse.c +++ b/mouse.c @@ -278,7 +278,7 @@ luaA_mouse_object_under_pointer(lua_State *L) } return 1; } - else if((client = client_getbywin(child))) + else if((client = client_getbyframewin(child))) return luaA_object_push(globalconf.L, client); return 0; diff --git a/objects/client.c b/objects/client.c index 0af0c7aa..19721450 100644 --- a/objects/client.c +++ b/objects/client.c @@ -227,7 +227,21 @@ client_t * client_getbywin(xcb_window_t w) { foreach(c, globalconf.clients) - if((*c)->window == w || (*c)->frame_window == w) + if((*c)->window == w) + return *c; + + return NULL; +} + +/** Get a client by its frame window. + * \param w The client window to find. + * \return A client pointer if found, NULL otherwise. + */ +client_t * +client_getbyframewin(xcb_window_t w) +{ + foreach(c, globalconf.clients) + if((*c)->frame_window == w) return *c; return NULL; diff --git a/objects/client.h b/objects/client.h index 0f70f4cb..d42e8ca6 100644 --- a/objects/client.h +++ b/objects/client.h @@ -139,6 +139,8 @@ LUA_OBJECT_FUNCS(client_class, client_t, client) bool client_maybevisible(client_t *, screen_t *); client_t * client_getbywin(xcb_window_t); +client_t * client_getbyframewin(xcb_window_t); + void client_ban(client_t *); void client_ban_unfocus(client_t *); void client_unban(client_t *);