Browse Source

Make sure new windows have mouse and keyboard focus if there's no windowing system

Sam Lantinga 1 year ago
parent
commit
5948ea997f
1 changed files with 9 additions and 3 deletions
  1. 9 3
      src/video/SDL_video.c

+ 9 - 3
src/video/SDL_video.c

@@ -2131,9 +2131,15 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
         parent->first_child = window;
         parent->first_child = window;
     }
     }
 
 
-    if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window, props) < 0) {
-        SDL_DestroyWindow(window);
-        return NULL;
+    if (_this->CreateSDLWindow) {
+        if (_this->CreateSDLWindow(_this, window, props) < 0) {
+            SDL_DestroyWindow(window);
+            return NULL;
+        }
+    } else {
+        /* No windowing system, make sure the new window has focus */
+        SDL_SetMouseFocus(window);
+        SDL_SetKeyboardFocus(window);
     }
     }
 
 
     /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
     /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,