7010721: Frame#setMaximizedbounds not working properly on dual screen environment
authordcherepanov
Mon, 16 May 2011 18:40:10 +0400
changeset 9663 6a99292d054b
parent 9662 68f9d98224e1
child 9664 ccb1a19d2395
7010721: Frame#setMaximizedbounds not working properly on dual screen environment Reviewed-by: art, anthony
jdk/src/windows/classes/sun/awt/windows/WFramePeer.java
--- a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java	Sat May 14 16:51:25 2011 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java	Mon May 16 18:40:10 2011 +0400
@@ -107,8 +107,16 @@
             Rectangle currentDevBounds = currentDevGC.getBounds();
             Rectangle primaryDevBounds = primaryDevGC.getBounds();
 
-            b.width -= (currentDevBounds.width - primaryDevBounds.width);
-            b.height -= (currentDevBounds.height - primaryDevBounds.height);
+            boolean isCurrentDevLarger =
+                ((currentDevBounds.width - primaryDevBounds.width > 0) ||
+                 (currentDevBounds.height - primaryDevBounds.height > 0));
+
+            // the window manager doesn't seem to compensate for differences when
+            // the primary monitor is larger than the monitor that display the window
+            if (isCurrentDevLarger) {
+                b.width -= (currentDevBounds.width - primaryDevBounds.width);
+                b.height -= (currentDevBounds.height - primaryDevBounds.height);
+            }
         }
     }