From 15ec80e80d87cc891bdef54e88dbf549632e526f Mon Sep 17 00:00:00 2001 From: Quantum Date: Thu, 23 Dec 2021 21:00:10 -0500 Subject: [PATCH] [client] input: fix race between window size and guest cursor g_state.posInfoValid could become valid after the guest reports the cursor position, in which case we did not show the cursor until another update occurs. This commit eliminates the race by performing the update when g_state.posInfoValid becomes true. --- client/src/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/src/core.c b/client/src/core.c index eb5e28b2..722d173b 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -268,6 +268,19 @@ void core_updatePositionInfo(void) { g_state.posInfoValid = true; g_state.ds->realignPointer(); + + // g_cursor.guest.valid could have become true in the meantime. + if (g_cursor.guest.valid) + { + // Since posInfoValid was false, core_handleGuestMouseUpdate becomes a + // noop when called on the cursor thread, which means we need to call it + // again in order for the cursor to show up. + core_handleGuestMouseUpdate(); + + // Similarly, the position needs to be valid before the initial mouse + // move, otherwise we wouldn't know if the cursor is in the viewport. + app_handleMouseRelative(0.0, 0.0, 0.0, 0.0); + } } done: