clutter/main: Refactor to remove devices in a single place

As suggested by Carlos in a review of this MR, refactor the logic of
clutter_do_event() to have both adding and removing of devices from the
devices list in a single place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
This commit is contained in:
Jonas Dreßler 2022-11-16 17:58:48 +01:00 committed by Marge Bot
parent edc226a04d
commit 4fa1dab918

View File

@ -762,6 +762,7 @@ clutter_do_event (ClutterEvent *event)
{ {
ClutterContext *context = _clutter_context_get_default(); ClutterContext *context = _clutter_context_get_default();
ClutterActor *event_actor = NULL; ClutterActor *event_actor = NULL;
gboolean filtered;
/* we need the stage for the event */ /* we need the stage for the event */
if (event->any.stage == NULL) if (event->any.stage == NULL)
@ -797,11 +798,14 @@ clutter_do_event (ClutterEvent *event)
context->current_event = g_slist_prepend (context->current_event, event); context->current_event = g_slist_prepend (context->current_event, event);
if (_clutter_event_process_filters (event, event_actor)) filtered = _clutter_event_process_filters (event, event_actor);
{
context->current_event = context->current_event =
g_slist_delete_link (context->current_event, context->current_event); g_slist_delete_link (context->current_event, context->current_event);
if (!filtered)
_clutter_stage_queue_event (event->any.stage, event, TRUE);
if (event->type == CLUTTER_TOUCH_END || if (event->type == CLUTTER_TOUCH_END ||
event->type == CLUTTER_TOUCH_CANCEL || event->type == CLUTTER_TOUCH_CANCEL ||
event->type == CLUTTER_DEVICE_REMOVED) event->type == CLUTTER_DEVICE_REMOVED)
@ -809,25 +813,6 @@ clutter_do_event (ClutterEvent *event)
_clutter_stage_process_queued_events (event->any.stage); _clutter_stage_process_queued_events (event->any.stage);
maybe_remove_device_for_event (event->any.stage, event, TRUE); maybe_remove_device_for_event (event->any.stage, event, TRUE);
} }
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.
*
* This gives us the chance to reliably compress motion events
* because we've "looked ahead" and know all motion events that
* will occur before drawing the frame.
*/
_clutter_stage_queue_event (event->any.stage, event, TRUE);
if (event->type == CLUTTER_TOUCH_END ||
event->type == CLUTTER_TOUCH_CANCEL ||
event->type == CLUTTER_DEVICE_REMOVED)
_clutter_stage_process_queued_events (event->any.stage);
} }
static void static void
@ -917,11 +902,6 @@ _clutter_process_event_details (ClutterActor *stage,
x, y, target); x, y, target);
emit_event (target, event); emit_event (target, event);
if (event->type == CLUTTER_TOUCH_END ||
event->type == CLUTTER_TOUCH_CANCEL)
maybe_remove_device_for_event (CLUTTER_STAGE (stage), event, TRUE);
break; break;
} }
@ -936,9 +916,6 @@ _clutter_process_event_details (ClutterActor *stage,
break; break;
case CLUTTER_DEVICE_REMOVED: case CLUTTER_DEVICE_REMOVED:
maybe_remove_device_for_event (CLUTTER_STAGE (stage), event, TRUE);
break;
case CLUTTER_DEVICE_ADDED: case CLUTTER_DEVICE_ADDED:
case CLUTTER_EVENT_LAST: case CLUTTER_EVENT_LAST:
break; break;