From 85f3a71dd5178013e1a5bc2c42283c08939a5825 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 5 Aug 2021 06:03:09 +1000 Subject: [PATCH] [client] overlay: remember and restore the grab and pointer state When entering overlay mode if the cursor was previously grabbed we should restore the state when exiting overlay mode. This will also correct the pointer setting it to NONE or SQUARE depending on the prior grab state. --- client/src/app.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/app.c b/client/src/app.c index 0d78a8e1..fe454bc8 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -842,6 +842,8 @@ void app_freeOverlays(void) void app_setOverlay(bool enable) { + static bool wasGrabbed = false; + if (g_state.overlayInput == enable) return; @@ -850,6 +852,8 @@ void app_setOverlay(bool enable) if (g_state.overlayInput) { + wasGrabbed = g_cursor.grab; + g_state.io->ConfigFlags &= ~ImGuiConfigFlags_NoMouse; core_setGrabQuiet(false); core_setCursorInView(false); @@ -858,6 +862,8 @@ void app_setOverlay(bool enable) { g_state.io->ConfigFlags |= ImGuiConfigFlags_NoMouse; core_resetOverlayInputState(); + core_setGrabQuiet(wasGrabbed); + app_invalidateWindow(); } }