[gtk/wip/carlosg/fix-synth-crossing-idle] gdk/x11: Store idle ID, and ensure it is eventually unset



commit a2b9ceaf9947ca229618816b9dd21f73694703dd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Aug 2 12:46:30 2019 +0200

    gdk/x11: Store idle ID, and ensure it is eventually unset
    
    This idle happens on mutter around the x11 display being closed, which
    has it running after it did actually happen. Ensure the window removes
    this idle on dispose.

 gdk/gdkinternals.h |  3 ++-
 gdk/gdkwindow.c    | 25 ++++++++++++++-----------
 2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 2244c2f2de..50ebdaa235 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -322,6 +322,8 @@ struct _GdkWindow
   GdkWindowState old_state;
   GdkWindowState state;
 
+  guint synthesized_crossing_event_id;
+
   guint8 alpha;
   guint8 fullscreen_mode;
 
@@ -337,7 +339,6 @@ struct _GdkWindow
   guint focus_on_map : 1;
   guint shaped : 1;
   guint support_multidevice : 1;
-  guint synthesize_crossing_event_queued : 1;
   guint effective_visibility : 2;
   guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
   guint native_visibility : 2; /* the native visibility of a impl windows */
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 838abcf4c7..ede040b157 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -570,6 +570,12 @@ gdk_window_finalize (GObject *object)
        _gdk_window_destroy (window, TRUE);
     }
 
+  if (window->synthesized_crossing_event_id)
+    {
+      g_source_remove (window->synthesized_crossing_event_id);
+      window->synthesized_crossing_event_id = 0;
+    }
+
   if (window->impl)
     {
       g_object_unref (window->impl);
@@ -8977,7 +8983,7 @@ do_synthesize_crossing_event (gpointer data)
 
   changed_toplevel = data;
 
-  changed_toplevel->synthesize_crossing_event_queued = FALSE;
+  changed_toplevel->synthesized_crossing_event_id = 0;
 
   if (GDK_WINDOW_DESTROYED (changed_toplevel))
     return FALSE;
@@ -9036,17 +9042,14 @@ _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window)
 
   toplevel = get_event_toplevel (changed_window);
 
-  if (!toplevel->synthesize_crossing_event_queued)
+  if (toplevel->synthesized_crossing_event_id == 0)
     {
-      guint id;
-
-      toplevel->synthesize_crossing_event_queued = TRUE;
-
-      id = gdk_threads_add_idle_full (GDK_PRIORITY_EVENTS - 1,
-                                      do_synthesize_crossing_event,
-                                      g_object_ref (toplevel),
-                                      g_object_unref);
-      g_source_set_name_by_id (id, "[gtk+] do_synthesize_crossing_event");
+      toplevel->synthesized_crossing_event_id =
+        gdk_threads_add_idle_full (GDK_PRIORITY_EVENTS - 1,
+                                   do_synthesize_crossing_event,
+                                   toplevel, NULL);
+      g_source_set_name_by_id (toplevel->synthesized_crossing_event_id,
+                               "[gtk+] do_synthesize_crossing_event");
     }
 }
 


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