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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-07-30 22:07:24 +02:00
parent 102063dbbd
commit 9fbdecf26c
4 changed files with 22 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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 *);