--- old/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-11-06 02:13:06.248904960 -0500 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-11-06 02:13:06.100830962 -0500 @@ -57,6 +57,7 @@ import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; import sun.util.logging.PlatformLogger; +import static sun.awt.X11.XlibUtil.scaleDown; public final class XToolkit extends UNIXToolkit implements Runnable { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XToolkit"); @@ -422,7 +423,7 @@ } } - private void processGlobalMotionEvent(XEvent e) { + private void processGlobalMotionEvent(XEvent e, XBaseWindow win) { // Only our windows guaranteely generate MotionNotify, so we // should track enter/leave, to catch the moment when to // switch to XQueryPointer @@ -431,9 +432,11 @@ awtLock(); try { if (lastCursorPos == null) { - lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root()); + lastCursorPos = new Point(win.scaleDown(ev.get_x_root()), + win.scaleDown(ev.get_y_root())); } else { - lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root()); + lastCursorPos.setLocation(win.scaleDown(ev.get_x_root()), + win.scaleDown(ev.get_y_root())); } } finally { awtUnlock(); @@ -452,9 +455,11 @@ awtLock(); try { if (lastCursorPos == null) { - lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root()); + lastCursorPos = new Point(win.scaleDown(ev.get_x_root()), + win.scaleDown(ev.get_y_root())); } else { - lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root()); + lastCursorPos.setLocation(win.scaleDown(ev.get_x_root()), + win.scaleDown(ev.get_y_root())); } } finally { awtUnlock(); @@ -492,10 +497,11 @@ private void dispatchEvent(XEvent ev) { final XAnyEvent xany = ev.get_xany(); - if (windowToXWindow(xany.get_window()) != null && - (ev.get_type() == XConstants.MotionNotify || ev.get_type() == XConstants.EnterNotify || ev.get_type() == XConstants.LeaveNotify)) - { - processGlobalMotionEvent(ev); + XBaseWindow baseWindow = windowToXWindow(xany.get_window()); + if (baseWindow != null && (ev.get_type() == XConstants.MotionNotify + || ev.get_type() == XConstants.EnterNotify + || ev.get_type() == XConstants.LeaveNotify)) { + processGlobalMotionEvent(ev, baseWindow); } if( ev.get_type() == XConstants.MappingNotify ) { @@ -670,8 +676,8 @@ XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData); - screenWidth = pattr.get_width(); - screenHeight = pattr.get_height(); + screenWidth = config.scaleDown(pattr.get_width()); + screenHeight = config.scaleDown(pattr.get_height()); } finally { pattr.dispose(); } @@ -701,7 +707,7 @@ return getDefaultScreenHeight(); } - private static Rectangle getWorkArea(long root) + private static Rectangle getWorkArea(long root, int scale) { XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA"); @@ -717,7 +723,10 @@ int rootWidth = (int)Native.getLong(native_ptr, 2); int rootHeight = (int)Native.getLong(native_ptr, 3); - return new Rectangle(rootX, rootY, rootWidth, rootHeight); + return new Rectangle(scaleDown(rootX, scale), + scaleDown(rootY, scale), + scaleDown(rootWidth, scale), + scaleDown(rootHeight, scale)); } } finally @@ -750,15 +759,16 @@ try { X11GraphicsConfig x11gc = (X11GraphicsConfig)gc; - X11GraphicsDevice x11gd = (X11GraphicsDevice)x11gc.getDevice(); + X11GraphicsDevice x11gd = x11gc.getDevice(); long root = XlibUtil.getRootWindow(x11gd.getScreen()); - Rectangle rootBounds = XlibUtil.getWindowGeometry(root); + int scale = x11gc.getScale(); + Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale); X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!x11ge.runningXinerama()) { - Rectangle workArea = XToolkit.getWorkArea(root); + Rectangle workArea = XToolkit.getWorkArea(root, scale); if (workArea != null) { return new Insets(workArea.y, @@ -768,7 +778,7 @@ } } - return getScreenInsetsManually(root, rootBounds, gc.getBounds()); + return getScreenInsetsManually(root, rootBounds, gc.getBounds(), scale); } finally { @@ -783,7 +793,8 @@ * * This method should be called under XToolkit.awtLock() */ - private Insets getScreenInsetsManually(long root, Rectangle rootBounds, Rectangle screenBounds) + private Insets getScreenInsetsManually(long root, Rectangle rootBounds, + Rectangle screenBounds, int scale) { /* * During the manual calculation of screen insets we iterate @@ -831,20 +842,23 @@ if (strutPresent) { // second, verify that window is located on the proper screen - Rectangle windowBounds = XlibUtil.getWindowGeometry(window); + Rectangle windowBounds = XlibUtil.getWindowGeometry(window, + scale); if (windowLevel > 1) { - windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds); + windowBounds = XlibUtil.translateCoordinates(window, root, + windowBounds, + scale); } // if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect // if the struts area intersects with screenBounds, however some window // managers don't set this hint correctly, so we just get intersection with windowBounds if (windowBounds != null && windowBounds.intersects(screenBounds)) { - int left = (int)Native.getLong(native_ptr, 0); - int right = (int)Native.getLong(native_ptr, 1); - int top = (int)Native.getLong(native_ptr, 2); - int bottom = (int)Native.getLong(native_ptr, 3); + int left = scaleDown((int)Native.getLong(native_ptr, 0), scale); + int right = scaleDown((int)Native.getLong(native_ptr, 1), scale); + int top = scaleDown((int)Native.getLong(native_ptr, 2), scale); + int bottom = scaleDown((int)Native.getLong(native_ptr, 3), scale); /* * struts could be relative to root window bounds, so @@ -2487,7 +2501,8 @@ oops_updated = false; long event_number = getEventNumber(); // Generate OOPS ConfigureNotify event - XlibWrapper.XMoveWindow(getDisplay(), win.getWindow(), ++oops_position, 0); + XlibWrapper.XMoveWindow(getDisplay(), win.getWindow(), + win.scaleUp(++oops_position), 0); // Change win position each time to avoid system optimization if (oops_position > 50) { oops_position = 0;