Browse Source

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.
Sam Lantinga 1 year ago
parent
commit
c5bd2cba98
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/video/windows/SDL_windowswindow.c

+ 7 - 1
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);
     }