gtkwindow: Use pointer-oriented function to deal with crossing events
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 9 Aug 2022 16:49:35 +0000 (18:49 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 9 Aug 2022 17:48:15 +0000 (19:48 +0200)
Commit adba0b97 fixed missed pointer crossings by using a helper function that
was already present and looked like did everything that was needed. However
this function was oriented to keyboard focus and it also did update the related
widget state. Doing these changes on pointer-based crossing was misuse, and
could cause weird interactions with keyboard focus management.

Fix this by using gtkmain.c gtk_synthesize_crossing_event() that is in fact
oriented to pointers.

Fixes: adba0b97 (gtkwindow: Synthesize pointer crossing events on state changes)
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5094
gtk/gtkmain.c
gtk/gtkprivate.h
gtk/gtkwindow.c

index f17fb095f576488c88b0fe7838ecbb575256c626..726ee2e9ac1d20c6d9f7ae3565de3cdaa3a27b1f 100644 (file)
@@ -1110,7 +1110,7 @@ translate_coordinates (double     event_x,
   return TRUE;
 }
 
-static void
+void
 gtk_synthesize_crossing_events (GtkRoot         *toplevel,
                                 GtkCrossingType  crossing_type,
                                 GtkWidget       *old_target,
index 3495e07efcbee19c66ce2c0bae4f798b0a8cbcfc..7869347cad67b2719b35ccd77c41ccf52124a0e1 100644 (file)
@@ -152,6 +152,15 @@ char * _gtk_elide_underscores (const char *original);
 
 void setlocale_initialization (void);
 
+void gtk_synthesize_crossing_events (GtkRoot         *toplevel,
+                                     GtkCrossingType  crossing_type,
+                                     GtkWidget       *old_target,
+                                     GtkWidget       *new_target,
+                                     double           surface_x,
+                                     double           surface_y,
+                                     GdkCrossingMode  mode,
+                                     GdkDrop         *drop);
+
 G_END_DECLS
 
 #endif /* __GTK_PRIVATE_H__ */
index 7d7c4a312bf7fbf01726f5eba1080c680763fded..6fcdcf23cfa92697d71e4bb2826d44546ae15c04 100644 (file)
@@ -6462,7 +6462,12 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window,
 
           old_target = g_object_ref (focus->target);
           gtk_pointer_focus_repick_target (focus);
-          synthesize_focus_change_events (window, old_target, focus->target, GTK_CROSSING_POINTER);
+          gtk_synthesize_crossing_events (GTK_ROOT (window),
+                                          GTK_CROSSING_POINTER,
+                                          old_target, focus->target,
+                                          focus->x, focus->y,
+                                          GDK_CROSSING_NORMAL,
+                                          NULL);
           g_object_unref (old_target);
         }