Browse Source

Reposition the window also in borderless mode if it's sized as large as the monitor bounds.

Lasse Öörni 8 years ago
parent
commit
fb6492a948

+ 6 - 4
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -2105,13 +2105,15 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
         }
         else 
         {
-            if (newFullscreen)
+            SDL_Rect display_rect;
+            SDL_GetDisplayBounds(monitor, &display_rect);
+
+            if (newFullscreen || (newBorderless && newWidth >= display_rect.w && newHeight >= display_rect.h))
             {
-                // Reposition the window on the specified monitor
-                SDL_Rect display_rect;
-                SDL_GetDisplayBounds(monitor, &display_rect);
+                // Reposition the window on the specified monitor if it's supposed to cover the entire monitor
                 SDL_SetWindowPosition(window_, display_rect.x, display_rect.y);
             }
+
             SDL_SetWindowSize(window_, newWidth, newHeight);
         }
 

+ 5 - 4
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -2352,11 +2352,12 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
             SDL_GetWindowSize(window_, &newWidth, &newHeight);
         }
         else {
-            if (newFullscreen) 
+            SDL_Rect display_rect;
+            SDL_GetDisplayBounds(monitor, &display_rect);
+
+            if (newFullscreen || (newBorderless && newWidth >= display_rect.w && newHeight >= display_rect.h))
             {
-                // Reposition the window on the specified monitor
-                SDL_Rect display_rect;
-                SDL_GetDisplayBounds(monitor, &display_rect);
+                // Reposition the window on the specified monitor if it's supposed to cover the entire monitor
                 SDL_SetWindowPosition(window_, display_rect.x, display_rect.y);
             }
 

+ 3 - 2
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -429,9 +429,10 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
         SDL_Rect display_rect;
         SDL_GetDisplayBounds(monitor, &display_rect);
         SDL_SetWindowPosition(window_, display_rect.x, display_rect.y);
+        bool reposition = fullscreen || (borderless && width >= display_rect.w && height >= display_rect.h);
 
-        int x = fullscreen ? display_rect.x : position_.x_;
-        int y = fullscreen ? display_rect.y : position_.y_;
+        int x = reposition ? display_rect.x : position_.x_;
+        int y = reposition ? display_rect.y : position_.y_;
 
         unsigned flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
         if (fullscreen)