瀏覽代碼

Only set window position on creation if on 1st monitor otherwise maximize will be wrong

JoshEngebretson 10 年之前
父節點
當前提交
26a5c4e0ca

+ 5 - 2
Source/Atomic/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -439,10 +439,13 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
             float ratio = float(mode.h) / float(mode.w);
             width = mode.w - 200;
             height = (int) (float (mode.w - 200) * ratio);
-            SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
+
+            // Only set the position if on the first monitor, otherwise, the maximize will be on the wrong monitor
+            if ( (position_.x_ >= 0 && position_.x_ < mode.w) && (position_.y_ >= 0 && position_.y_ < mode.h))
+                SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
 
             if (!maximize)
-                center = true;
+                center = true;                
         }
     }
 

+ 4 - 1
Source/Atomic/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -431,7 +431,10 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
             float ratio = float(mode.h) / float(mode.w);
             width = mode.w - 200;
             height = (int) (float (mode.w - 200) * ratio);
-            SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
+
+            // Only set the position if on the first monitor, otherwise, the maximize will be on the wrong monitor
+            if ( (position_.x_ >= 0 && position_.x_ < mode.w) && (position_.y_ >= 0 && position_.y_ < mode.h))
+                SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
 
             if (!maximize)
                 center = true;

+ 4 - 3
Source/Atomic/Graphics/OpenGL/OGLGraphics.cpp

@@ -383,11 +383,12 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
             width = mode.w - 200;
             height = (int) (float (mode.w - 200) * ratio);
 
-            if (!maximize)
-            {
+            // Only set the position if on the first monitor, otherwise, the maximize will be on the wrong monitor
+            if ( (position_.x_ >= 0 && position_.x_ < mode.w) && (position_.y_ >= 0 && position_.y_ < mode.h))
                 SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
+
+            if (!maximize)
                 center = true;
-            }
         }
     }