< prev index next >

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

Print this page

        

@@ -100,11 +100,11 @@
     }
 
     /**
      * Returns the bounds of the given window, in absolute coordinates
      */
-    static Rectangle getWindowGeometry(long window)
+    static Rectangle getWindowGeometry(long window, int scale)
     {
         XToolkit.awtLock();
         try
         {
             int res = XlibWrapper.XGetGeometry(XToolkit.getDisplay(),

@@ -124,11 +124,13 @@
             int x = Native.getInt(XlibWrapper.larg2);
             int y = Native.getInt(XlibWrapper.larg3);
             long width = Native.getUInt(XlibWrapper.larg4);
             long height = Native.getUInt(XlibWrapper.larg5);
 
-            return new Rectangle(x, y, (int)width, (int)height);
+            return new Rectangle(scaleDown(x, scale), scaleDown(y, scale),
+                                 scaleDown((int) width, scale),
+                                 scaleDown((int) height, scale));
         }
         finally
         {
             XToolkit.awtUnlock();
         }

@@ -136,27 +138,28 @@
 
     /**
      * Translates the given point from one window to another. Returns
      * null if the translation is failed
      */
-    static Point translateCoordinates(long src, long dst, Point p)
+    static Point translateCoordinates(long src, long dst, Point p, int scale)
     {
         Point translated = null;
 
         XToolkit.awtLock();
         try
         {
             XTranslateCoordinates xtc =
-                new XTranslateCoordinates(src, dst, p.x, p.y);
+                new XTranslateCoordinates(src, dst, p.x * scale, p.y * scale);
             try
             {
                 int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
                 if ((status != 0) &&
                     ((XErrorHandlerUtil.saved_error == null) ||
                     (XErrorHandlerUtil.saved_error.get_error_code() == XConstants.Success)))
                 {
-                    translated = new Point(xtc.get_dest_x(), xtc.get_dest_y());
+                    translated = new Point(scaleDown(xtc.get_dest_x(), scale),
+                                           scaleDown(xtc.get_dest_y(), scale));
                 }
             }
             finally
             {
                 xtc.dispose();

@@ -172,13 +175,16 @@
 
     /**
      * Translates the given rectangle from one window to another.
      * Returns null if the translation is failed
      */
-    static Rectangle translateCoordinates(long src, long dst, Rectangle r)
+    static Rectangle translateCoordinates(long src, long dst, Rectangle r,
+                                          int scale)
     {
-        Point translatedLoc = translateCoordinates(src, dst, r.getLocation());
+        Point translatedLoc = translateCoordinates(src, dst, r.getLocation(),
+                                                   scale);
+
         if (translatedLoc == null)
         {
             return null;
         }
         else

@@ -404,6 +410,10 @@
             return 0;
         } else {
             return 1 << (7 + button);
         }
     }
+
+    static int scaleDown(int x, int scale) {
+        return x / scale;
+    }
 }
< prev index next >