[mutter/wip/carlosg/grabs-pt2: 32/32] core: Handle redirection changes in and out of ClutterGrab grabs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/grabs-pt2: 32/32] core: Handle redirection changes in and out of ClutterGrab grabs
- Date: Thu, 25 Nov 2021 10:22:07 +0000 (UTC)
commit 6faa2b351f9184b941f508dc1d42730103dba931
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Nov 17 23:31:11 2021 +0100
core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.
So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.
clutter/clutter/clutter-stage.c | 9 ++++++---
src/core/events.c | 28 ++++++++++++++++++++++++++++
src/wayland/meta-wayland-pointer.c | 10 ++++++++--
src/wayland/meta-wayland-tablet-tool.c | 8 ++++++++
4 files changed, 50 insertions(+), 5 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 10f62d9333..d780c93bc0 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3426,7 +3426,8 @@ clutter_stage_update_device (ClutterStage *stage,
CLUTTER_LEAVE, 0,
old_actor, new_actor,
point, time);
- _clutter_actor_handle_event (old_actor, root, event);
+ if (!_clutter_event_process_filters (event))
+ _clutter_actor_handle_event (old_actor, root, event);
clutter_event_free (event);
}
@@ -3438,7 +3439,8 @@ clutter_stage_update_device (ClutterStage *stage,
CLUTTER_ENTER, 0,
new_actor, old_actor,
point, time);
- _clutter_actor_handle_event (new_actor, root, event);
+ if (!_clutter_event_process_filters (event))
+ _clutter_actor_handle_event (new_actor, root, event);
clutter_event_free (event);
}
@@ -3559,7 +3561,8 @@ clutter_stage_notify_grab_on_entry (ClutterStage *stage,
grab_actor : old_grab_actor,
entry->coords,
CLUTTER_CURRENT_TIME);
- _clutter_actor_handle_event (deepmost, topmost, event);
+ if (!_clutter_event_process_filters (event))
+ _clutter_actor_handle_event (deepmost, topmost, event);
clutter_event_free (event);
}
}
diff --git a/src/core/events.c b/src/core/events.c
index 8afc720efd..f77c45d0c1 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -66,6 +66,15 @@ stage_has_key_focus (void)
return clutter_stage_get_key_focus (CLUTTER_STAGE (stage)) == stage;
}
+static gboolean
+stage_has_grab (void)
+{
+ MetaBackend *backend = meta_get_backend ();
+ ClutterActor *stage = meta_backend_get_stage (backend);
+
+ return clutter_stage_get_grab_actor (CLUTTER_STAGE (stage)) != NULL;
+}
+
static MetaWindow *
get_window_for_event (MetaDisplay *display,
const ClutterEvent *event)
@@ -207,6 +216,17 @@ meta_display_handle_event (MetaDisplay *display,
MetaGestureTracker *gesture_tracker;
ClutterEventSequence *sequence;
+ if (meta_is_wayland_compositor () &&
+ (event->type == CLUTTER_ENTER ||
+ event->type == CLUTTER_LEAVE) &&
+ (event->any.flags & CLUTTER_EVENT_FLAG_GRAB_NOTIFY) != 0)
+ {
+ meta_display_sync_wayland_input_focus (display);
+
+ if (event->type == CLUTTER_LEAVE)
+ meta_display_cancel_touch (display);
+ }
+
sequence = clutter_event_get_event_sequence (event);
/* Set the pointer emulating sequence on touch begin, if eligible */
@@ -393,6 +413,13 @@ meta_display_handle_event (MetaDisplay *display,
goto out;
}
+ if (stage_has_grab ())
+ {
+ bypass_wayland = TRUE;
+ bypass_clutter = FALSE;
+ goto out;
+ }
+
if (window)
{
/* Events that are likely to trigger compositor gestures should
@@ -463,6 +490,7 @@ meta_display_handle_event (MetaDisplay *display,
}
out:
+
/* If the compositor has a grab, don't pass that through to Wayland */
if (display->event_route == META_EVENT_ROUTE_COMPOSITOR_GRAB)
bypass_wayland = TRUE;
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index abd779ad79..cae8860c8e 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -249,9 +249,11 @@ sync_focus_surface (MetaWaylandPointer *pointer)
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterBackend *clutter_backend = clutter_get_default_backend ();
ClutterSeat *clutter_seat = clutter_backend_get_default_seat (clutter_backend);
+ ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
- if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) &&
- !clutter_seat_is_unfocus_inhibited (clutter_seat))
+ if (clutter_stage_get_grab_actor (stage) != NULL ||
+ (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) &&
+ !clutter_seat_is_unfocus_inhibited (clutter_seat)))
{
meta_wayland_pointer_set_focus (pointer, NULL);
return;
@@ -422,10 +424,14 @@ default_grab_focus (MetaWaylandPointerGrab *grab,
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterBackend *clutter_backend = clutter_get_default_backend ();
ClutterSeat *clutter_seat = clutter_backend_get_default_seat (clutter_backend);
+ ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
if (!meta_wayland_seat_has_pointer (seat))
return;
+ if (clutter_stage_get_grab_actor (stage) != NULL)
+ return;
+
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) &&
!clutter_seat_is_unfocus_inhibited (clutter_seat))
return;
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 51e4e7d5d4..8d4b9c942c 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -549,6 +549,14 @@ sync_focus_surface (MetaWaylandTabletTool *tool,
const ClutterEvent *event)
{
MetaDisplay *display = meta_get_display ();
+ MetaBackend *backend = meta_get_backend ();
+ ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
+
+ if (clutter_stage_get_grab_actor (stage))
+ {
+ meta_wayland_tablet_tool_set_focus (tool, NULL, event);
+ return;
+ }
switch (display->event_route)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]