src/solaris/classes/sun/awt/X11/XDecoratedPeer.java

Print this page

        

@@ -840,12 +840,20 @@
     public void setShellBounds(Rectangle rec) {
         if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell bounds on " +
                                                        this + " to " + rec);
         XToolkit.awtLock();
         try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
-            XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
+            /* X does not allow setting heights or widths to 0: this will cause a BadValue
+             * error. Lets set them to something close enough */
+            int width = rec.width;
+            if (width <= 0)
+                width = 1;
+            int height = rec.height;
+            if (height <= 0)
+                height = 1;
+            updateSizeHints(rec.x, rec.y, width, height);
+            XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), width, height);
             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
         }
         finally {
             XToolkit.awtUnlock();
         }

@@ -853,23 +861,39 @@
     public void setShellSize(Rectangle rec) {
         if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell size on " +
                                                        this + " to " + rec);
         XToolkit.awtLock();
         try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
-            XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
+            /* X does not allow setting heights or widths to 0: this will cause a BadValue
+             * error. Lets set them to something close enough */
+            int width = rec.width;
+            if (width <= 0)
+                width = 1;
+            int height = rec.height;
+            if (height <= 0)
+                height = 1;
+            updateSizeHints(rec.x, rec.y, width, height);
+            XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), width, height);
         }
         finally {
             XToolkit.awtUnlock();
         }
     }
     public void setShellPosition(Rectangle rec) {
         if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell position on " +
                                                        this + " to " + rec);
         XToolkit.awtLock();
         try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
+            /* X does not allow setting heights or widths to 0: this will cause a BadValue
+             * error. Lets set them to something close enough */
+            int width = rec.width;
+            if (width <= 0)
+                width = 1;
+            int height = rec.height;
+            if (height <= 0)
+                height = 1;
+            updateSizeHints(rec.x, rec.y, width, height);
             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
         }
         finally {
             XToolkit.awtUnlock();
         }