From fb9a1641116b816ad55127e8767f2f5ea095b733 Mon Sep 17 00:00:00 2001 From: Qian23333 <119576779+Qian23333@users.noreply.github.com> Date: Sun, 15 Jun 2025 09:47:56 +0800 Subject: [PATCH] feat: disable text input when window gains focus --- app/streaming/input/input.cpp | 9 +++++++++ app/streaming/input/input.h | 2 ++ app/streaming/session.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index 7abe2c5d..c36c6718 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -301,6 +301,15 @@ void SdlInputHandler::notifyFocusLost() // Raise all keys that are currently pressed. If we don't do this, certain keys // used in shortcuts that cause focus loss (such as Alt+Tab) may get stuck down. raiseAllKeys(); + + // Re-enable text input when window loses focus + SDL_StartTextInput(); +} + +void SdlInputHandler::notifyFocusGained() +{ + // Disable text input when window gains focus to prevent IME popup interference + SDL_StopTextInput(); } bool SdlInputHandler::isCaptureActive() diff --git a/app/streaming/input/input.h b/app/streaming/input/input.h index f2cae85f..20bbbc33 100644 --- a/app/streaming/input/input.h +++ b/app/streaming/input/input.h @@ -138,6 +138,8 @@ public: void notifyFocusLost(); + void notifyFocusGained(); + bool isCaptureActive(); bool isSystemKeyCaptureActive(); diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 5c0052af..fc1413d9 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -2108,6 +2108,7 @@ void Session::execInternal() if (m_Preferences->muteOnFocusLoss) { m_AudioMuted = false; } + m_InputHandler->notifyFocusGained(); break; case SDL_WINDOWEVENT_LEAVE: m_InputHandler->notifyMouseLeave(); @@ -2420,4 +2421,3 @@ DispatchDeferredCleanup: // reference. QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this)); } -