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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
This commit is contained in:
Carlos Garnacho
2021-11-17 23:31:11 +01:00
committed by Marge Bot
parent 0e234d76f4
commit a840c039a0
7 changed files with 67 additions and 5 deletions

View File

@ -28,6 +28,7 @@
#include "backends/meta-idle-manager.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-input-device-x11.h"
#include "compositor/compositor-private.h"
#include "compositor/meta-window-actor-private.h"
#include "core/display-private.h"
#include "core/window-private.h"
@ -67,6 +68,16 @@ stage_has_key_focus (void)
return clutter_stage_get_key_focus (CLUTTER_STAGE (stage)) == stage;
}
static gboolean
stage_has_grab (MetaDisplay *display)
{
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
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 +218,31 @@ meta_display_handle_event (MetaDisplay *display,
G_GNUC_UNUSED gboolean bypass_wayland = FALSE;
MetaGestureTracker *gesture_tracker;
ClutterEventSequence *sequence;
gboolean has_grab;
has_grab = stage_has_grab (display);
if (display->grabbed_in_clutter != has_grab)
{
MetaCompositor *compositor = meta_display_get_compositor (display);
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
meta_display_sync_wayland_input_focus (display);
#endif
if (!display->grabbed_in_clutter && has_grab)
{
display->grabbed_in_clutter = TRUE;
meta_display_cancel_touch (display);
meta_compositor_grab_begin (compositor);
}
else if (display->grabbed_in_clutter && !has_grab)
{
display->grabbed_in_clutter = FALSE;
meta_compositor_grab_end (compositor);
}
}
sequence = clutter_event_get_event_sequence (event);
@ -394,6 +430,13 @@ meta_display_handle_event (MetaDisplay *display,
goto out;
}
if (stage_has_grab (display))
{
bypass_wayland = TRUE;
bypass_clutter = FALSE;
goto out;
}
if (window)
{
/* Events that are likely to trigger compositor gestures should