< 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(x / scale, y / scale,
+                                (int) (width / scale),
+                                (int) (height / scale));
         }
         finally
         {
             XToolkit.awtUnlock();
         }

@@ -136,27 +138,27 @@
 
     /**
      * 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(xtc.get_dest_x() / scale, xtc.get_dest_y() / scale);
                 }
             }
             finally
             {
                 xtc.dispose();

@@ -172,13 +174,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
< prev index next >