From b6fa296d5af9bfa6fdaf6fd3c8be875654ff8354 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 15 Dec 2021 00:23:44 +1100 Subject: [PATCH] [client] x11: work around issue with desktop switch on i3 For an unknwon reason when LG is on another desktop (hidden) and the user switches to that desktop, the first attempt to grab the pointer results in a GrabFrozen result. This adds some simple retry logic to attempt again after a short (100ms) delay which seems to resolve the issue. --- client/displayservers/X11/x11.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index aa104d60..d7057598 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -1643,7 +1643,10 @@ static void x11GrabPointer(void) XISetMask(mask.mask, XI_Enter ); XISetMask(mask.mask, XI_Leave ); - Status ret = XIGrabDevice( + Status ret; + for(int retry = 0; retry < 2; ++retry) + { + ret = XIGrabDevice( x11.display, x11.pointerDev, x11.window, @@ -1654,6 +1657,13 @@ static void x11GrabPointer(void) XINoOwnerEvents, &mask); + // on some WMs (i3) for an unknown reason the first grab attempt when + // switching to a desktop that has LG on it fails with GrabFrozen, however + // adding as short delay seems to resolve the issue. + if (ret == GrabFrozen && retry == 0) + usleep(100000); + } + if (ret != Success) { x11PrintGrabError("pointer", x11.pointerDev, ret);