[gtk/readonly-events-1: 126/149] Always deliver focus events to toplevels



commit 563dd65530605ff821e383876b42390a84e66e26
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 17 09:17:42 2020 -0500

    Always deliver focus events to toplevels
    
    Its was GTK expects. This change gets rid of the "Ignoring an
    unexpected focus event from GDK on a non-toplevel surface."
    warning.

 gdk/gdksurface.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index b16da6eb17..6974e7ec76 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -3983,12 +3983,13 @@ check_autohide (GdkEvent *event)
 }
 
 static gboolean
-is_key_event (GdkEvent *event)
+is_keyboard_event (GdkEvent *event)
 {
   switch ((guint) gdk_event_get_event_type (event))
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
+    case GDK_FOCUS_CHANGE:
       return TRUE;
     default:;
     }
@@ -4008,17 +4009,23 @@ rewrite_event_for_toplevel (GdkEvent *event)
   while (surface->parent)
     surface = surface->parent;
 
-  return gdk_event_key_new (gdk_event_get_event_type (event),
-                            surface,
-                            gdk_event_get_device (event),
-                            gdk_event_get_source_device (event),
-                            gdk_event_get_time (event),
-                            gdk_event_get_modifier_state (event),
-                            gdk_key_event_get_keyval (event),
-                            gdk_key_event_get_keycode (event),
-                            gdk_key_event_get_scancode (event),
-                            gdk_key_event_get_group (event),
-                            gdk_key_event_is_modifier (event));
+  if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
+    return gdk_event_focus_new (surface,
+                                gdk_event_get_device (event),
+                                gdk_event_get_source_device (event),
+                                gdk_focus_event_get_in (event));
+  else
+    return gdk_event_key_new (gdk_event_get_event_type (event),
+                              surface,
+                              gdk_event_get_device (event),
+                              gdk_event_get_source_device (event),
+                              gdk_event_get_time (event),
+                              gdk_event_get_modifier_state (event),
+                              gdk_key_event_get_keyval (event),
+                              gdk_key_event_get_keycode (event),
+                              gdk_key_event_get_scancode (event),
+                              gdk_key_event_get_group (event),
+                              gdk_key_event_is_modifier (event));
 }
 
 static void
@@ -4138,7 +4145,7 @@ gdk_surface_handle_event (GdkEvent *event)
     {
       GdkEvent *emitted;
 
-      if (is_key_event (event))
+      if (is_keyboard_event (event))
         emitted = rewrite_event_for_toplevel (event);
       else
         emitted = gdk_event_ref (event);


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