From 11c52b3330ed42e6fa18a46b20f87144105557c8 Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Fri, 4 Oct 2024 12:54:10 -0300 Subject: [PATCH] imgui: dont capture any input without an active nav window fix keyboard not being available as soon as the emulator opens --- src/imgui/renderer/imgui_core.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/imgui/renderer/imgui_core.cpp b/src/imgui/renderer/imgui_core.cpp index 2473f3713..7094f8f52 100644 --- a/src/imgui/renderer/imgui_core.cpp +++ b/src/imgui/renderer/imgui_core.cpp @@ -148,11 +148,17 @@ bool ProcessEvent(SDL_Event* event) { // Don't block release/up events case SDL_EVENT_MOUSE_MOTION: case SDL_EVENT_MOUSE_WHEEL: - case SDL_EVENT_MOUSE_BUTTON_DOWN: - return GetIO().WantCaptureMouse; + case SDL_EVENT_MOUSE_BUTTON_DOWN: { + const auto& io = GetIO(); + return io.WantCaptureMouse && io.Ctx->NavWindow != nullptr && + io.Ctx->NavWindow->ID != dock_id; + } case SDL_EVENT_TEXT_INPUT: - case SDL_EVENT_KEY_DOWN: - return GetIO().WantCaptureKeyboard; + case SDL_EVENT_KEY_DOWN: { + const auto& io = GetIO(); + return io.WantCaptureKeyboard && io.Ctx->NavWindow != nullptr && + io.Ctx->NavWindow->ID != dock_id; + } case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_AXIS_MOTION: case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: