From 1f23d88c7a13cf48941a9c1d31dbcd92348f4d60 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Wed, 6 May 2026 01:00:52 -0700 Subject: [PATCH] overlay: prevent overlay from queueing up keyboard input while overlay is not visible (#677) ## Link to GitHub Issue or related Pull Request, if one exists Fixes #675 Yet another regression from #604 ## Description of change When overlay was hidden (not visible) it was still accepting keyboard input, so when it became visible again the queued up keystrokes got processed all at once. Also, fix a bug with monitor settings update kicking in when in windowed mode - this really should have been only for full screen. ## Testing Tested DDR windowed / full screen, TDJ with subscreen overlay windowed / fullscreen. --- src/spice2x/hooks/graphics/graphics.cpp | 2 +- src/spice2x/overlay/imgui/impl_spice.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/spice2x/hooks/graphics/graphics.cpp b/src/spice2x/hooks/graphics/graphics.cpp index b27f49c..f3e19e6 100644 --- a/src/spice2x/hooks/graphics/graphics.cpp +++ b/src/spice2x/hooks/graphics/graphics.cpp @@ -1401,7 +1401,7 @@ void update_monitor_on_boot(std::optional target_orientati } void update_monitor_at_runtime() { - if (monitor_settings_changed) { + if (!GRAPHICS_WINDOWED && monitor_settings_changed) { log_misc("graphics", "applying monitor updates at runtime as window regained focus..."); update_monitor(false, target_orientation_on_boot, target_refresh_rate_on_boot); } diff --git a/src/spice2x/overlay/imgui/impl_spice.cpp b/src/spice2x/overlay/imgui/impl_spice.cpp index 26f7316..7a1c14e 100644 --- a/src/spice2x/overlay/imgui/impl_spice.cpp +++ b/src/spice2x/overlay/imgui/impl_spice.cpp @@ -352,6 +352,8 @@ void ImGui_ImplSpice_NewFrame() { // only process new input from devices if window is in focus // (when not in focus, all mouse/keyboard events are treated as released) const auto accept_new_input = superexit::has_focus() && !rawinput::OS_WINDOW_ACTIVE; + const auto accept_new_keyboard_input = accept_new_input && + (overlay::OVERLAY && overlay::OVERLAY->has_focus()); // remember old state std::array KeysDownOld; @@ -410,7 +412,7 @@ void ImGui_ImplSpice_NewFrame() { break; } case rawinput::KEYBOARD: { - if (accept_new_input) { + if (accept_new_keyboard_input) { // iterate all virtual key codes for (size_t vKey = 0; vKey < VKEY_MAX; vKey++) { // get state (combined from all pages)