--- old/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-10-22 10:07:26.143072313 -0400 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-10-22 10:07:25.855072302 -0400 @@ -422,7 +422,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 +431,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 +454,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 +496,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 ) { @@ -701,7 +706,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 +722,8 @@ 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(rootX / scale, rootY / scale, + rootWidth / scale, rootHeight / scale); } } finally @@ -750,15 +756,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 +775,7 @@ } } - return getScreenInsetsManually(root, rootBounds, gc.getBounds()); + return getScreenInsetsManually(root, rootBounds, gc.getBounds(), scale); } finally { @@ -783,7 +790,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 +839,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 = (int)Native.getLong(native_ptr, 0) / scale; + int right = (int)Native.getLong(native_ptr, 1) / scale; + int top = (int)Native.getLong(native_ptr, 2) / scale; + int bottom = (int)Native.getLong(native_ptr, 3) / scale; /* * struts could be relative to root window bounds, so @@ -2487,7 +2498,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;