< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java

Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX

@@ -36,11 +36,13 @@
 
 import sun.awt.AWTAccessor;
 import sun.awt.im.InputMethodManager;
 import sun.security.action.GetPropertyAction;
 
-import static sun.java2d.SunGraphicsEnvironment.convertToDeviceSpace;
+import static sun.java2d.SunGraphicsEnvironment.getGCDeviceBounds;
+import static sun.java2d.SunGraphicsEnvironment.toDeviceSpaceAbs;
+import static sun.java2d.SunGraphicsEnvironment.toUserSpace;
 
 class WFramePeer extends WWindowPeer implements FramePeer {
 
     static {
         initIDs();

@@ -95,14 +97,13 @@
      * The method translates the incoming bounds to the values acceptable
      * by the window manager. For more details, please refer to 6699851.
      */
     private Rectangle adjustMaximizedBounds(Rectangle bounds) {
         // All calculations should be done in the device space
-        bounds = convertToDeviceSpace(bounds);
-
+        bounds = toDeviceSpaceAbs(bounds);
         GraphicsConfiguration gc = getGraphicsConfiguration();
-        Rectangle currentDevBounds = convertToDeviceSpace(gc, gc.getBounds());
+        Rectangle currentDevBounds = getGCDeviceBounds(gc);
         // Prepare data for WM_GETMINMAXINFO message.
         // ptMaxPosition should be in coordinate system of the current monitor,
         // not the main monitor, or monitor on which we maximize the window.
         bounds.x -= currentDevBounds.x;
         bounds.y -= currentDevBounds.y;

@@ -146,17 +147,17 @@
         }
     }
 
     @Override
     public final Dimension getMinimumSize() {
+        GraphicsConfiguration gc = getGraphicsConfiguration();
         Dimension d = new Dimension();
         if (!((Frame)target).isUndecorated()) {
-            d.setSize(scaleDownX(getSysMinWidth()),
-                      scaleDownY(getSysMinHeight()));
+            d.setSize(toUserSpace(gc, getSysMinWidth(), getSysMinHeight()));
         }
-        if (((Frame)target).getMenuBar() != null) {
-            d.height += scaleDownY(getSysMenuHeight());
+        if (((Frame) target).getMenuBar() != null) {
+            d.height += toUserSpace(gc, 0, getSysMenuHeight()).height;
         }
         return d;
     }
 
     // Note: Because this method calls resize(), which may be overridden
< prev index next >