Hi,

This patch fixes an error in the calculation of an X11 window size. The inset size was being included in the calculation of the client area size for a window. A jtreg test is included. This was tested with openjdk6 but seems to be present in openjdk7 too.

Bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6721088

Cheers,

Omair
--- jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java.orig        
2009-01-08 16:53:54.000000000 -0500
+++ jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java     2009-01-08 
16:54:08.000000000 -0500
@@ -478,7 +478,10 @@
             // do nothing but accept it.
             Rectangle reqBounds = newDimensions.getBounds();
             Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, 
reqBounds.width, reqBounds.height);
-            newDimensions = new WindowDimensions(newBounds, 
newDimensions.getInsets(), newDimensions.isClientSizeSet());
+            Insets insets = newDimensions.getInsets();
+            Rectangle fixedBounds = new Rectangle(newBounds.x, newBounds.y, 
newBounds.width - insets.left - insets.right,
+                    newBounds.height - insets.top - insets.bottom);
+            newDimensions = new WindowDimensions(fixedBounds, insets, 
newDimensions.isClientSizeSet());
         }
         XToolkit.awtLock();
         try {
--- /dev/null   2009-01-09 04:32:08.413012246 -0500
+++ jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java        2009-01-09 
11:30:54.000000000 -0500
@@ -0,0 +1,50 @@
+/*
+  @test
+  @bug 6721088
+  @summary X11 Window sizes should be what we set them to
+  @author Omair Majid <oma...@redhat.com>
+  @run main TestFrameSize
+ */
+
+import java.awt.Dimension;
+import java.awt.Frame;
+
+/**
+ * TestFrameSize.java
+ * 
+ * Summary: test that X11 Awt windows are drawn with correct sizes
+ * 
+ * Test fails if size of window is wrong
+ */
+
+public class TestFrameSize {
+
+       static Dimension desiredDimensions = new Dimension(200, 200);
+       static int ERROR_MARGIN = 15;
+       static Frame mainWindow;
+
+       public static void drawGui() {
+               mainWindow = new Frame("");
+               mainWindow.setPreferredSize(desiredDimensions);
+               mainWindow.pack();
+               // mainWindow.setVisible(true);
+
+               Dimension actualDimensions = mainWindow.getSize();
+               // System.out.println(desiredDimensions);
+               // System.out.println(actualDimensions);
+               if (Math.abs(actualDimensions.height - 
desiredDimensions.height) > ERROR_MARGIN) {
+                       throw new RuntimeException("Incorrect widow size");
+               }
+
+       }
+
+       public static void main(String[] args) {
+               try {
+                       drawGui();
+               } finally {
+                       if (mainWindow != null) {
+                               mainWindow.dispose();
+                       }
+               }
+       }
+}

Reply via email to