1
0
Fork 0

clutter: Process device removing events immediately when they come in

Having the stage device list be responsible for delivering the
same events twice (first immediately to clients, then later to Clutter)
was expected to be tricky, a sneaky problem with it right now is the
following case:

While collecting events for a stage update cycle, we get three touch
events from the backend: TOUCH_BEGIN(seq=1) -> TOUCH_END(seq=1) ->
TOUCH_BEGIN(seq=1)

What we do right now when we see a TOUCH_BEGIN event is adding a device
to the stage right when it comes in from the backend. And when we see
a TOUCH_END, we remove the device from the stage not immediately but
only after it went through the queue.

In the case of the three events mentioned above, with the current
behavior, this will happen when they come in from the backend:

- TOUCH_BEGIN(seq=1): device gets added to the stage with seq 1, event
 gets queued
- TOUCH_END(seq=1): Nothing happens, event gets queued
- TOUCH_BEGIN(seq=1): we try to add device to the stage, but seq 1 is
 already there, event gets queued

Now when we go through the queue and see the TOUCH_END, the device with
seq 1 gets removed, but on the subsequent TOUCH_BEGIN, we won't add a
new device, so this event (and all events with seq=1 that are still in
the queue) is now ignored by Clutter because it has no device.

What we want to do here is to cut short once the TOUCH_END event comes
in: Process queued events immediately and make sure the device is
removed from the stage list before a new device can be added. Same goes
for any other events that will lead to devices getting removed.

Small note: Since this leads to clutter_stage_get_device_actor()
returning NULL, I was wondering why we never crash because of this:
Turns out _clutter_actor_handle_event() handles self = NULL just fine
without crashing...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
This commit is contained in:
Jonas Dreßler 2022-11-05 21:16:20 +01:00 committed by Marge Bot
parent 874a5a6d58
commit edc226a04d

View file

@ -823,6 +823,11 @@ clutter_do_event (ClutterEvent *event)
* will occur before drawing the frame. * will occur before drawing the frame.
*/ */
_clutter_stage_queue_event (event->any.stage, event, TRUE); _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