From 22bbc2457e17fb8db37073d3c4a2fb7726403012 Mon Sep 17 00:00:00 2001 From: Quantum Date: Wed, 11 Aug 2021 01:43:59 -0400 Subject: [PATCH] [client] wayland: fix deadlock when using wayland:warpSupport=no --- client/displayservers/Wayland/input.c | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/client/displayservers/Wayland/input.c b/client/displayservers/Wayland/input.c index 7ed673d8..92d7493e 100644 --- a/client/displayservers/Wayland/input.c +++ b/client/displayservers/Wayland/input.c @@ -344,16 +344,19 @@ void waylandGrabPointer(void) }); } -void waylandUngrabPointer(void) +inline static void internalUngrabPointer(bool lock) { - INTERLOCKED_SECTION(wlWm.confineLock, + if (lock) + LG_LOCK(wlWm.confineLock); + + if (wlWm.confinedPointer) { - if (wlWm.confinedPointer) - { - zwp_confined_pointer_v1_destroy(wlWm.confinedPointer); - wlWm.confinedPointer = NULL; - } - }); + zwp_confined_pointer_v1_destroy(wlWm.confinedPointer); + wlWm.confinedPointer = NULL; + } + + if (lock) + LG_UNLOCK(wlWm.confineLock); if (!wlWm.warpSupport) { @@ -371,6 +374,11 @@ void waylandUngrabPointer(void) } } +void waylandUngrabPointer(void) +{ + internalUngrabPointer(true); +} + void waylandCapturePointer(void) { if (!wlWm.warpSupport) @@ -411,9 +419,7 @@ void waylandUncapturePointer(void) * - if the user has opted to use captureInputOnly mode. */ if (!wlWm.warpSupport || !app_isFormatValid() || app_isCaptureOnlyMode()) - { - waylandUngrabPointer(); - } + internalUngrabPointer(false); else { wlWm.confinedPointer = zwp_pointer_constraints_v1_confine_pointer(