< prev index next >
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
Print this page
@@ -55,10 +55,11 @@
import sun.awt.util.ThreadGroupUtils;
import sun.print.PrintJob2D;
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");
private static final PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XToolkit");
private static final PlatformLogger timeoutTaskLog = PlatformLogger.getLogger("sun.awt.X11.timeoutTask.XToolkit");
@@ -420,22 +421,24 @@
} finally {
awtUnlock();
}
}
- 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
if (e.get_type() == XConstants.MotionNotify) {
XMotionEvent ev = e.get_xmotion();
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();
}
} else if (e.get_type() == XConstants.LeaveNotify) {
@@ -450,13 +453,15 @@
// Entrance into our window
XCrossingEvent ev = e.get_xcrossing();
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();
}
}
@@ -490,14 +495,15 @@
}
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 ) {
// The 'window' field in this event is unused.
// This application itself does nothing to initiate such an event
@@ -668,12 +674,12 @@
XWindowAttributes pattr = new XWindowAttributes();
try {
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();
}
} finally {
awtUnlock();
@@ -699,11 +705,11 @@
@Override
protected int getScreenHeight() {
return getDefaultScreenHeight();
}
- private static Rectangle getWorkArea(long root)
+ private static Rectangle getWorkArea(long root, int scale)
{
XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA");
long native_ptr = Native.allocateLongArray(4);
try
@@ -715,11 +721,14 @@
int rootX = (int)Native.getLong(native_ptr, 0);
int rootY = (int)Native.getLong(native_ptr, 1);
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
{
XlibWrapper.unsafe.freeMemory(native_ptr);
@@ -748,29 +757,30 @@
XToolkit.awtLock();
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,
workArea.x,
rootBounds.height - workArea.height - workArea.y,
rootBounds.width - workArea.width - workArea.x);
}
}
- return getScreenInsetsManually(root, rootBounds, gc.getBounds());
+ return getScreenInsetsManually(root, rootBounds, gc.getBounds(), scale);
}
finally
{
XToolkit.awtUnlock();
}
@@ -781,11 +791,12 @@
* _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL hints and add these
* hints' values to screen insets.
*
* 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
* all the X windows hierarchy starting from root window. This
* constant is the max level inspected in this hierarchy.
@@ -829,24 +840,27 @@
strutPresent = XA_NET_WM_STRUT.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4);
}
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
* make them relative to the screen bounds in this case
*/
@@ -2485,11 +2499,12 @@
addEventDispatcher(win.getWindow(), oops_waiter);
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;
}
< prev index next >