From c5bd2cba98e29ec831d8e656dc0eada002b1b86f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 6 Jul 2023 18:14:34 -0700 Subject: [PATCH] Fix passing of child window focus in WIN_ShowWindow/WIN_RaiseWindow Keyboard focus was being passed to the child window being shown if SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN is false and keyboard focus was not being passed to the child window being activated in WIN_RaiseWindow. --- src/video/windows/SDL_windowswindow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index bdd3d92a2a..c49bda245c 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -859,10 +859,11 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) style = GetWindowLong(hwnd, GWL_EXSTYLE); if (style & WS_EX_NOACTIVATE) { nCmdShow = SW_SHOWNOACTIVATE; + bActivate = SDL_FALSE; } ShowWindow(hwnd, nCmdShow); - if (window->flags & SDL_WINDOW_POPUP_MENU) { + if (window->flags & SDL_WINDOW_POPUP_MENU && bActivate) { if (window->parent == SDL_GetKeyboardFocus()) { WIN_SetKeyboardFocus(window); } @@ -922,6 +923,11 @@ void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) } if (bActivate) { SetForegroundWindow(hwnd); + if (window->flags & SDL_WINDOW_POPUP_MENU) { + if (window->parent == SDL_GetKeyboardFocus()) { + WIN_SetKeyboardFocus(window); + } + } } else { SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, data->copybits_flag | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE); }