< prev index next >

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

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

@@ -531,19 +531,31 @@
         }
     }
 
     @Override
     public boolean updateGraphicsData(GraphicsConfiguration gc) {
+        var old = getGraphicsConfiguration().getDefaultTransform();
         winGraphicsConfig = (Win32GraphicsConfig)gc;
+        if (gc != null && !old.equals(gc.getDefaultTransform())) {
+            syncBounds(); // the bound of the peer depends on the DPI
+        }
         try {
             replaceSurfaceData();
         } catch (InvalidPipeException e) {
             // REMIND : what do we do if our surface creation failed?
         }
         return false;
     }
 
+    /**
+     * Make sure that the native peer's coordinates are in sync with the target.
+     */
+    void syncBounds(){
+        Rectangle r = ((Component)target).getBounds();
+        setBounds(r.x, r.y, r.width, r.height, SET_BOUNDS);
+    }
+
     //This will return null for Components not yet added to a Container
     @Override
     public ColorModel getColorModel() {
         GraphicsConfiguration gc = getGraphicsConfiguration();
         if (gc != null) {
< prev index next >