From 9085874d4eccbd61f28391f2c9f5cb92b7718a3f Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Tue, 28 Jan 2025 02:43:03 +0200 Subject: [PATCH] Fix text input not working on X11 --- Source/Engine/Platform/SDL/SDLWindow.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index 84c02c0df..15d3fa418 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -184,6 +184,10 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings) // Initialize using the shared Display instance from SDL if (SDLPlatform::UsesX11() && SDLPlatform::GetXDisplay() == nullptr) SDLPlatform::InitX11(GetX11Display()); + + // Window focus changes breaks the text input for some reason, just keep it enabled for good + if (SDLPlatform::UsesX11() && _settings.AllowInput) + SDL_StartTextInput(_window); #endif } @@ -416,7 +420,10 @@ void SDLWindow::HandleEvent(SDL_Event& event) case SDL_EVENT_WINDOW_FOCUS_GAINED: { OnGotFocus(); - SDL_StartTextInput(_window); + if (IsPopupWindow(_settings.Type)) + _window = _window; + if (_settings.AllowInput && !SDLPlatform::UsesX11()) + SDL_StartTextInput(_window); const SDL_Rect* currentClippingRect = SDL_GetWindowMouseRect(_window); if (_isClippingCursor && currentClippingRect == nullptr) { @@ -427,7 +434,10 @@ void SDLWindow::HandleEvent(SDL_Event& event) } case SDL_EVENT_WINDOW_FOCUS_LOST: { - SDL_StopTextInput(_window); + if (IsPopupWindow(_settings.Type)) + _window = _window; + if (_settings.AllowInput && !SDLPlatform::UsesX11()) + SDL_StopTextInput(_window); const SDL_Rect* currentClippingRect = SDL_GetWindowMouseRect(_window); if (currentClippingRect != nullptr) SDL_SetWindowMouseRect(_window, nullptr);