From 4a865424cd3f0dc78aa652f966b35f5bd2b9f649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 7 Mar 2022 15:16:03 +0100 Subject: [PATCH] clutter: Set event as current_event when going through event filters With the introduction of untrottled event delivery to wayland clients, we moved the _clutter_event_process_filters() call outside of _clutter_process_event(). This also moved the processing of event filters outside of the timespan where the event is added to Clutters current_event stack, making Clutter.get_current_event() no longer available to anything happening inside mutters event filter. One thing that happens in mutters event filter is detecting and triggering keybindings like the alt-tab switcher. Now the alt-tab switcher has a special case where it finishes and activates a window right when the keybinding gets activated, relying on the current event time as the timestamp to activate the window. Now since the current event time is no longer available from inside mutters event filter, we'd pass 0 to meta_window_activate(), causing mutter to send a notification instead of actually activating the window. To fix this, also set a current_event for the ClutterContext when going through event filters, this makes sure Clutter.get_current_event_time() works when called inside keybinding handlers. Part-of: --- clutter/clutter/clutter-main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index e066e5aeb..df872bd42 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -741,6 +741,7 @@ update_device_for_event (ClutterStage *stage, void clutter_do_event (ClutterEvent *event) { + ClutterContext *context = _clutter_context_get_default(); ClutterActor *event_actor = NULL; /* we need the stage for the event */ @@ -775,8 +776,17 @@ clutter_do_event (ClutterEvent *event) event_actor = clutter_stage_get_event_actor (event->any.stage, event); } + context->current_event = g_slist_prepend (context->current_event, event); + if (_clutter_event_process_filters (event, event_actor)) - return; + { + context->current_event = + g_slist_delete_link (context->current_event, context->current_event); + + return; + } + + context->current_event = g_slist_delete_link (context->current_event, context->current_event); /* Instead of processing events when received, we queue them up to * handle per-frame before animations, layout, and drawing.