main: Push the current event on the stack before we start needing it

The changes in commit 13e22e2030 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
This commit is contained in:
Rui Matos 2015-06-05 19:21:40 +02:00
parent 3c1a2c8d24
commit ef93257db7

View File

@ -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);