[gtk+/gtk-3-16] main: Push the current event on the stack before we start needing it



commit d87769dcd527d50e808e8e21fa5160df94734495
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri Jun 5 19:21:40 2015 +0200

    main: Push the current event on the stack before we start needing it
    
    The changes in commit 13e22e20300b7312e52bba7d077fc7e231695fc1 made
    _gtk_window_check_handle_wm_event() indirectly depend on
    gtk_get_current_event_time() which relies on the current event being
    available on the current_events stack.
    
    Since the current event is only pushed on the stack afterwards we get
    an invalid timestamp which breaks ewmh window moving.
    
    This fixes the issue by pushing the current event before we start
    relying on it being there in gtk_main_do_event() and, as a byproduct,
    also fixes a potential memory leak when we have a rewritten event and
    return early due to _gtk_window_check_handle_wm_event() being TRUE.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750384

 gtk/gtkmain.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index f50025e..ddf82a5 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1567,6 +1567,11 @@ gtk_main_do_event (GdkEvent *event)
       event_widget = gtk_get_event_widget (event);
     }
 
+  /* Push the event onto a stack of current events for
+   * gtk_current_event_get().
+   */
+  current_events = g_list_prepend (current_events, event);
+
   window_group = gtk_main_get_window_group (event_widget);
   device = gdk_event_get_device (event);
 
@@ -1582,7 +1587,7 @@ gtk_main_do_event (GdkEvent *event)
        !gtk_widget_is_ancestor (event_widget, grab_widget)))
     {
       if (_gtk_window_check_handle_wm_event (event))
-        return;
+        goto cleanup;
     }
 
   /* Find out the topmost widget where captured event propagation
@@ -1607,17 +1612,7 @@ gtk_main_do_event (GdkEvent *event)
    */
   if (device &&
       _gtk_window_group_widget_is_blocked_for_device (window_group, grab_widget, device))
-    {
-      if (rewritten_event)
-        gdk_event_free (rewritten_event);
-
-      return;
-    }
-
-  /* Push the event onto a stack of current events for
-   * gtk_current_event_get().
-   */
-  current_events = g_list_prepend (current_events, event);
+    goto cleanup;
 
   /* Not all events get sent to the grabbing widget.
    * The delete, destroy, expose, focus change and resize
@@ -1793,6 +1788,7 @@ gtk_main_do_event (GdkEvent *event)
       _gtk_tooltip_handle_event (event);
     }
 
+ cleanup:
   tmp_list = current_events;
   current_events = g_list_remove_link (current_events, tmp_list);
   g_list_free_1 (tmp_list);


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