[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.
This commit is contained in:
Geoffrey McRae 2021-08-05 06:03:09 +10:00
parent 38ddfc0b61
commit 85f3a71dd5

View File

@ -842,6 +842,8 @@ void app_freeOverlays(void)
void app_setOverlay(bool enable) void app_setOverlay(bool enable)
{ {
static bool wasGrabbed = false;
if (g_state.overlayInput == enable) if (g_state.overlayInput == enable)
return; return;
@ -850,6 +852,8 @@ void app_setOverlay(bool enable)
if (g_state.overlayInput) if (g_state.overlayInput)
{ {
wasGrabbed = g_cursor.grab;
g_state.io->ConfigFlags &= ~ImGuiConfigFlags_NoMouse; g_state.io->ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
core_setGrabQuiet(false); core_setGrabQuiet(false);
core_setCursorInView(false); core_setCursorInView(false);
@ -858,6 +862,8 @@ void app_setOverlay(bool enable)
{ {
g_state.io->ConfigFlags |= ImGuiConfigFlags_NoMouse; g_state.io->ConfigFlags |= ImGuiConfigFlags_NoMouse;
core_resetOverlayInputState(); core_resetOverlayInputState();
core_setGrabQuiet(wasGrabbed);
app_invalidateWindow();
} }
} }