events: Use the event target actor to determine window for event

We use get_window_for_event() to check whether an event happened on top
of a window or on top of shell UI to decide whether to bypass delivering
the event to Clutter. In case of crossing events though, we can't just
use the device actor to determine whether to forward the event to
Clutter or not: We do want to forward CLUTTER_LEAVE events which
happened on top of shell UI. In that case the device actor is already a
window actor (the pointer already is on top of a window), but the shell
still needs to get the LEAVE crossing event.

Since the event source actor got removed from the detail of
ClutterEvent, the context we're looking for (which actor did the pointer
leave) is now the target actor that the event gets emitted to. Since the
last commit, we also made event filters aware of this context by passing
the target actor to them, so use this context now to determine whether
we're on top of a window or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
This commit is contained in:
Jonas Dreßler 2022-03-05 23:46:24 +01:00 committed by Marge Bot
parent 2aad56b949
commit 0280b0aaa5

View File

@ -81,23 +81,20 @@ stage_has_grab (MetaDisplay *display)
static MetaWindow *
get_window_for_event (MetaDisplay *display,
const ClutterEvent *event)
const ClutterEvent *event,
ClutterActor *event_actor)
{
switch (display->event_route)
{
case META_EVENT_ROUTE_NORMAL:
{
ClutterActor *target;
MetaWindowActor *window_actor;
/* Always use the key focused window for key events. */
if (IS_KEY_EVENT (event))
return stage_has_key_focus () ? display->focus_window : NULL;
target = clutter_stage_get_device_actor (clutter_event_get_stage (event),
clutter_event_get_device (event),
clutter_event_get_event_sequence (event));
window_actor = meta_window_actor_from_actor (target);
window_actor = meta_window_actor_from_actor (event_actor);
if (window_actor)
return meta_window_actor_get_meta_window (window_actor);
else
@ -339,7 +336,7 @@ meta_display_handle_event (MetaDisplay *display,
}
#endif
window = get_window_for_event (display, event);
window = get_window_for_event (display, event, event_actor);
display->current_time = event->any.time;