event: FocusIn and FocusOut events handlers

We need to handle FocusIn event to update focused client, when client
with GAIM sends SetInputFocus message (that is FocusIn event for WM).

Signed-off-by: Mariusz Ceier <mceier@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Mariusz Ceier 2009-02-28 21:08:41 +01:00 committed by Julien Danjou
parent 9b654095ec
commit 926f458331
1 changed files with 27 additions and 0 deletions

27
event.c
View File

@ -548,6 +548,32 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
return 0;
}
/** The focus in event handler.
* \param data currently unused.
* \param connection The connection to the X server.
* \param ev The event.
*/
static int
event_handle_focusin(void *data __attribute__ ((unused)),
xcb_connection_t *connection,
xcb_focus_in_event_t *ev)
{
/* filter focus-in events */
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
&& (ev->detail == XCB_NOTIFY_DETAIL_VIRTUAL
|| ev->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL
|| ev->detail == XCB_NOTIFY_DETAIL_POINTER))
return 0;
client_t *c;
if((c = client_getbytitlebarwin(ev->event))
|| (c = client_getbywin(ev->event)))
client_focus(c, false);
return 0;
}
/** The expose event handler.
* \param data currently unused.
* \param connection The connection to the X server.
@ -864,6 +890,7 @@ void a_xcb_set_event_handlers(void)
xcb_event_set_destroy_notify_handler(&globalconf.evenths, event_handle_destroynotify, NULL);
xcb_event_set_enter_notify_handler(&globalconf.evenths, event_handle_enternotify, NULL);
xcb_event_set_leave_notify_handler(&globalconf.evenths, event_handle_leavenotify, NULL);
xcb_event_set_focus_in_handler(&globalconf.evenths, event_handle_focusin, NULL);
xcb_event_set_motion_notify_handler(&globalconf.evenths, event_handle_motionnotify, NULL);
xcb_event_set_expose_handler(&globalconf.evenths, event_handle_expose, NULL);
xcb_event_set_key_press_handler(&globalconf.evenths, event_handle_key, NULL);