< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XBaseWindow.java

Print this page

        

@@ -298,10 +298,26 @@
         eventMask |= XConstants.PropertyChangeMask | XConstants.OwnerGrabButtonMask;
         params.put(EVENT_MASK, Long.valueOf(eventMask));
     }
 
     /**
+     * Returns scale factor of the window. It is used to convert native
+     * coordinates to local and vice verse.
+     */
+    protected int getScale() {
+        return 1;
+    }
+
+    protected int scaleUp(int x) {
+        return x;
+    }
+
+    protected int scaleDown(int x) {
+        return x;
+    }
+
+    /**
      * Creates window with parameters specified by <code>params</code>
      * @see #init
      */
     private final void create(XCreateWindowParams params) {
         XToolkit.awtLock();

@@ -365,12 +381,14 @@
                 if (log.isLoggable(PlatformLogger.Level.FINE)) {
                     log.fine("Creating window for " + this + " with the following attributes: \n" + params);
                 }
                 window = XlibWrapper.XCreateWindow(XToolkit.getDisplay(),
                                    parentWindow.longValue(),
-                                   bounds.x, bounds.y, // location
-                                   bounds.width, bounds.height, // size
+                                                   scaleUp(bounds.x),
+                                                   scaleUp(bounds.y),
+                                                   scaleUp(bounds.width),
+                                                   scaleUp(bounds.height),
                                    0, // border
                                    depth.intValue(), // depth
                                    visual_class.intValue(), // class
                                    visual.longValue(), // visual
                                    value_mask,  // value mask

@@ -490,55 +508,55 @@
             XSizeHints hints = getHints();
             // Note: if PPosition is not set in flags this means that
             // we want to reset PPosition in hints.  This is necessary
             // for locationByPlatform functionality
             if ((flags & XUtilConstants.PPosition) != 0) {
-                hints.set_x(x);
-                hints.set_y(y);
+                hints.set_x(scaleUp(x));
+                hints.set_y(scaleUp(y));
             }
             if ((flags & XUtilConstants.PSize) != 0) {
-                hints.set_width(width);
-                hints.set_height(height);
+                hints.set_width(scaleUp(width));
+                hints.set_height(scaleUp(height));
             } else if ((hints.get_flags() & XUtilConstants.PSize) != 0) {
                 flags |= XUtilConstants.PSize;
             }
             if ((flags & XUtilConstants.PMinSize) != 0) {
-                hints.set_min_width(width);
-                hints.set_min_height(height);
+                hints.set_min_width(scaleUp(width));
+                hints.set_min_height(scaleUp(height));
             } else if ((hints.get_flags() & XUtilConstants.PMinSize) != 0) {
                 flags |= XUtilConstants.PMinSize;
                 //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced.
                 //We don't need to reset minimum size if it's already set
             }
             if ((flags & XUtilConstants.PMaxSize) != 0) {
                 if (maxBounds != null) {
                     if (maxBounds.width != Integer.MAX_VALUE) {
-                        hints.set_max_width(maxBounds.width);
+                        hints.set_max_width(scaleUp(maxBounds.width));
                     } else {
                         hints.set_max_width(XToolkit.getDefaultScreenWidth());
                     }
                     if (maxBounds.height != Integer.MAX_VALUE) {
-                        hints.set_max_height(maxBounds.height);
+                        hints.set_max_height(scaleUp(maxBounds.height));
                     } else {
                         hints.set_max_height(XToolkit.getDefaultScreenHeight());
                     }
                 } else {
-                    hints.set_max_width(width);
-                    hints.set_max_height(height);
+                    hints.set_max_width(scaleUp(width));
+                    hints.set_max_height(scaleUp(height));
                 }
             } else if ((hints.get_flags() & XUtilConstants.PMaxSize) != 0) {
                 flags |= XUtilConstants.PMaxSize;
                 if (maxBounds != null) {
                     if (maxBounds.width != Integer.MAX_VALUE) {
-                        hints.set_max_width(maxBounds.width);
+                        hints.set_max_width(scaleUp(maxBounds.width));
                     } else {
-                        hints.set_max_width(XToolkit.getDefaultScreenWidth());
+                        hints.set_max_width(scaleUp(XToolkit.getDefaultScreenWidth()));
                     }
                     if (maxBounds.height != Integer.MAX_VALUE) {
-                        hints.set_max_height(maxBounds.height);
+                        hints.set_max_height(scaleUp(maxBounds.height));
                     } else {
-                        hints.set_max_height(XToolkit.getDefaultScreenHeight());
+                        hints.set_max_height(scaleUp(XToolkit.getDefaultScreenHeight()));
                     }
                 } else {
                     // Leave intact
                 }
             }

@@ -721,11 +739,13 @@
         }
         width = Math.max(MIN_SIZE, width);
         height = Math.max(MIN_SIZE, height);
         XToolkit.awtLock();
         try {
-             XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getWindow(), x,y,width,height);
+            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getWindow(),
+                                          scaleUp(x), scaleUp(y),
+                                          scaleUp(width), scaleUp(height));
         } finally {
             XToolkit.awtUnlock();
         }
     }
 

@@ -754,11 +774,12 @@
         } else if (srcPeer != null && XlibUtil.isRoot(dst, srcPeer.getScreenNumber())) {
             // from peer into root
             rpt.x = x + srcPeer.getAbsoluteX();
             rpt.y = y + srcPeer.getAbsoluteY();
         } else {
-            rpt = XlibUtil.translateCoordinates(src, dst, new Point(x, y));
+            int scale = srcPeer == null ? 1 : srcPeer.getScale();
+            rpt = XlibUtil.translateCoordinates(src, dst, new Point(x, y), scale);
         }
         return rpt;
     }
 
     /*

@@ -1040,14 +1061,15 @@
     public void handleConfigureNotifyEvent(XEvent xev) {
         XConfigureEvent xe = xev.get_xconfigure();
         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
             insLog.finer("Configure, {0}", xe);
         }
-        x = xe.get_x();
-        y = xe.get_y();
-        width = xe.get_width();
-        height = xe.get_height();
+
+        x = scaleDown(xe.get_x());
+        y = scaleDown(xe.get_y());
+        width = scaleDown(xe.get_width());
+        height = scaleDown(xe.get_height());
     }
     /**
      * Checks ButtonRelease released all Mouse buttons
      */
     static boolean isFullRelease(int buttonState, int button) {
< prev index next >