From a8f461a4ebf5b564d1492137e2f4e0131d9b1f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 1 Apr 2022 10:09:46 +0200 Subject: [PATCH] barrier: Allow releasing without any event in the native implementation This allows for a sticky barrier to hold the pointer until it is released, but the owner of the barrier doesn't need a barrier event to release it. It will be used to implement input capturing. Part-of: --- src/backends/native/meta-barrier-native.c | 2 +- src/backends/x11/meta-barrier-x11.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-barrier-native.c b/src/backends/native/meta-barrier-native.c index 828cdad2f..610ebe9b3 100644 --- a/src/backends/native/meta-barrier-native.c +++ b/src/backends/native/meta-barrier-native.c @@ -640,7 +640,7 @@ meta_barrier_impl_native_release (MetaBarrierImpl *impl, MetaBarrierImplNative *self = META_BARRIER_IMPL_NATIVE (impl); if (self->state == META_BARRIER_STATE_HELD && - event->event_id == self->trigger_serial) + (!event || event->event_id == self->trigger_serial)) { self->state = META_BARRIER_STATE_RELEASE; self->manager->pointer_trap = NULL; diff --git a/src/backends/x11/meta-barrier-x11.c b/src/backends/x11/meta-barrier-x11.c index 174c65979..ea036ebf0 100644 --- a/src/backends/x11/meta-barrier-x11.c +++ b/src/backends/x11/meta-barrier-x11.c @@ -75,6 +75,12 @@ meta_barrier_impl_x11_release (MetaBarrierImpl *impl, MetaBackendX11 *backend_x11 = META_BACKEND_X11 (backend); Display *xdisplay = meta_backend_x11_get_xdisplay (backend_x11); + if (!event) + { + g_warning ("X11 barriers always need barrier events to release"); + return; + } + XIBarrierReleasePointer (xdisplay, META_VIRTUAL_CORE_POINTER_ID, self->xbarrier, event->event_id);