[client] imgui: fix modifier key modification race

imgui really hates it when we update the modifier key state after igNewFrame.
The result is:

    void ImGui::ErrorCheckEndFrameSanityChecks(): Assertion
    `(key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) &&
    "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"'
    failed.

Therefore, we buffer the modifier state information and update it in the IO
object right before we call igNewFrame.
This commit is contained in:
Quantum 2021-08-19 15:57:20 -04:00 committed by Geoffrey McRae
parent c0fa6c414c
commit 9bd205a527
2 changed files with 13 additions and 4 deletions

View file

@ -406,10 +406,10 @@ void app_handleKeyboardTyped(const char * typed)
void app_handleKeyboardModifiers(bool ctrl, bool shift, bool alt, bool super)
{
g_state.io->KeyCtrl = ctrl;
g_state.io->KeyShift = shift;
g_state.io->KeyAlt = alt;
g_state.io->KeySuper = super;
g_state.modCtrl = ctrl;
g_state.modShift = shift;
g_state.modAlt = alt;
g_state.modSuper = super;
}
void app_handleKeyboardLEDs(bool numLock, bool capsLock, bool scrollLock)
@ -806,6 +806,11 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
struct Overlay * overlay;
struct Rect buffer[MAX_OVERLAY_RECTS];
g_state.io->KeyCtrl = g_state.modCtrl;
g_state.io->KeyShift = g_state.modShift;
g_state.io->KeyAlt = g_state.modAlt;
g_state.io->KeySuper = g_state.modSuper;
igNewFrame();
if (g_state.overlayInput)

View file

@ -56,6 +56,10 @@ struct AppState
bool overlayInput;
ImGuiMouseCursor cursorLast;
char * imGuiIni;
bool modCtrl;
bool modShift;
bool modAlt;
bool modSuper;
bool alertShow;
char * alertMessage;