[gtk+] GdkDeviceManagerXI2: Make focus events contain a GdkDevice.



commit ed3198146cebcc01e30f64e93029a521cf09494e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jun 7 15:30:37 2010 +0200

    GdkDeviceManagerXI2: Make focus events contain a GdkDevice.

 gdk/x11/gdkdevicemanager-xi2.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 9915a3a..f9a9cd7 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -614,20 +614,24 @@ translate_keyboard_string (GdkEventKey *event)
 
 static void
 generate_focus_event (GdkWindow *window,
-		      gboolean   in)
+                      GdkDevice *device,
+                      gboolean   in)
 {
-  GdkEvent event;
+  GdkEvent *event;
 
-  event.type = GDK_FOCUS_CHANGE;
-  event.focus_change.window = window;
-  event.focus_change.send_event = FALSE;
-  event.focus_change.in = in;
+  event = gdk_event_new (GDK_FOCUS_CHANGE);
+  event->focus_change.window = g_object_ref (window);
+  event->focus_change.send_event = FALSE;
+  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
 handle_focus_change (GdkWindow *window,
+                     GdkDevice *device,
                      gint       detail,
                      gint       mode,
                      gboolean   in)
@@ -687,7 +691,7 @@ handle_focus_change (GdkWindow *window,
     }
 
   if (HAS_FOCUS (toplevel) != had_focus)
-    generate_focus_event (window, (in) ? TRUE : FALSE);
+    generate_focus_event (window, device, (in) ? TRUE : FALSE);
 }
 
 static gdouble *
@@ -1071,8 +1075,12 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
     case XI_FocusOut:
       {
         XIEnterEvent *xev = (XIEnterEvent *) ev;
+        GdkDevice *device;
+
+        device = g_hash_table_lookup (device_manager->id_table,
+                                      GINT_TO_POINTER (xev->deviceid));
 
-        handle_focus_change (window, xev->detail, xev->mode,
+        handle_focus_change (window, device, xev->detail, xev->mode,
                              (ev->evtype == XI_FocusIn) ? TRUE : FALSE);
 
         return_val = FALSE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]