GdkDeviceManagerXI2: Make focus events contain a GdkDevice.

This commit is contained in:
Carlos Garnacho 2010-06-07 15:30:37 +02:00
parent 07b1a2e081
commit ed3198146c

View File

@ -614,20 +614,24 @@ translate_keyboard_string (GdkEventKey *event)
static void static void
generate_focus_event (GdkWindow *window, generate_focus_event (GdkWindow *window,
GdkDevice *device,
gboolean in) gboolean in)
{ {
GdkEvent event; GdkEvent *event;
event.type = GDK_FOCUS_CHANGE; event = gdk_event_new (GDK_FOCUS_CHANGE);
event.focus_change.window = window; event->focus_change.window = g_object_ref (window);
event.focus_change.send_event = FALSE; event->focus_change.send_event = FALSE;
event.focus_change.in = in; event->focus_change.in = in;
gdk_event_set_device (event, device);
gdk_event_put (&event); gdk_event_put (event);
gdk_event_free (event);
} }
static void static void
handle_focus_change (GdkWindow *window, handle_focus_change (GdkWindow *window,
GdkDevice *device,
gint detail, gint detail,
gint mode, gint mode,
gboolean in) gboolean in)
@ -687,7 +691,7 @@ handle_focus_change (GdkWindow *window,
} }
if (HAS_FOCUS (toplevel) != had_focus) if (HAS_FOCUS (toplevel) != had_focus)
generate_focus_event (window, (in) ? TRUE : FALSE); generate_focus_event (window, device, (in) ? TRUE : FALSE);
} }
static gdouble * static gdouble *
@ -1071,8 +1075,12 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
case XI_FocusOut: case XI_FocusOut:
{ {
XIEnterEvent *xev = (XIEnterEvent *) ev; XIEnterEvent *xev = (XIEnterEvent *) ev;
GdkDevice *device;
handle_focus_change (window, xev->detail, xev->mode, device = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (xev->deviceid));
handle_focus_change (window, device, xev->detail, xev->mode,
(ev->evtype == XI_FocusIn) ? TRUE : FALSE); (ev->evtype == XI_FocusIn) ? TRUE : FALSE);
return_val = FALSE; return_val = FALSE;