< prev index next >
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
Print this page
*** 55,64 ****
--- 55,65 ----
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,441 ****
} finally {
awtUnlock();
}
}
! private void processGlobalMotionEvent(XEvent e) {
// 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());
} else {
! lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root());
}
} finally {
awtUnlock();
}
} else if (e.get_type() == XConstants.LeaveNotify) {
--- 421,444 ----
} finally {
awtUnlock();
}
}
! 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(win.scaleDown(ev.get_x_root()),
! win.scaleDown(ev.get_y_root()));
} else {
! lastCursorPos.setLocation(win.scaleDown(ev.get_x_root()),
! win.scaleDown(ev.get_y_root()));
}
} finally {
awtUnlock();
}
} else if (e.get_type() == XConstants.LeaveNotify) {
*** 450,462 ****
// 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());
} else {
! lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root());
}
} finally {
awtUnlock();
}
}
--- 453,467 ----
// Entrance into our window
XCrossingEvent ev = e.get_xcrossing();
awtLock();
try {
if (lastCursorPos == null) {
! lastCursorPos = new Point(win.scaleDown(ev.get_x_root()),
! win.scaleDown(ev.get_y_root()));
} else {
! lastCursorPos.setLocation(win.scaleDown(ev.get_x_root()),
! win.scaleDown(ev.get_y_root()));
}
} finally {
awtUnlock();
}
}
*** 490,503 ****
}
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);
}
if( ev.get_type() == XConstants.MappingNotify ) {
// The 'window' field in this event is unused.
// This application itself does nothing to initiate such an event
--- 495,509 ----
}
private void dispatchEvent(XEvent ev) {
final XAnyEvent xany = ev.get_xany();
! 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,679 ****
XWindowAttributes pattr = new XWindowAttributes();
try {
XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
XToolkit.getDefaultRootWindow(),
pattr.pData);
! screenWidth = pattr.get_width();
! screenHeight = pattr.get_height();
} finally {
pattr.dispose();
}
} finally {
awtUnlock();
--- 674,685 ----
XWindowAttributes pattr = new XWindowAttributes();
try {
XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
XToolkit.getDefaultRootWindow(),
pattr.pData);
! screenWidth = config.scaleDown(pattr.get_width());
! screenHeight = config.scaleDown(pattr.get_height());
} finally {
pattr.dispose();
}
} finally {
awtUnlock();
*** 699,709 ****
@Override
protected int getScreenHeight() {
return getDefaultScreenHeight();
}
! private static Rectangle getWorkArea(long root)
{
XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA");
long native_ptr = Native.allocateLongArray(4);
try
--- 705,715 ----
@Override
protected int getScreenHeight() {
return getDefaultScreenHeight();
}
! private static Rectangle getWorkArea(long root, int scale)
{
XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA");
long native_ptr = Native.allocateLongArray(4);
try
*** 715,725 ****
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);
}
}
finally
{
XlibWrapper.unsafe.freeMemory(native_ptr);
--- 721,734 ----
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(scaleDown(rootX, scale),
! scaleDown(rootY, scale),
! scaleDown(rootWidth, scale),
! scaleDown(rootHeight, scale));
}
}
finally
{
XlibWrapper.unsafe.freeMemory(native_ptr);
*** 748,776 ****
XToolkit.awtLock();
try
{
X11GraphicsConfig x11gc = (X11GraphicsConfig)gc;
! X11GraphicsDevice x11gd = (X11GraphicsDevice)x11gc.getDevice();
long root = XlibUtil.getRootWindow(x11gd.getScreen());
! Rectangle rootBounds = XlibUtil.getWindowGeometry(root);
X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!x11ge.runningXinerama())
{
! Rectangle workArea = XToolkit.getWorkArea(root);
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());
}
finally
{
XToolkit.awtUnlock();
}
--- 757,786 ----
XToolkit.awtLock();
try
{
X11GraphicsConfig x11gc = (X11GraphicsConfig)gc;
! X11GraphicsDevice x11gd = x11gc.getDevice();
long root = XlibUtil.getRootWindow(x11gd.getScreen());
! int scale = x11gc.getScale();
! Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale);
X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!x11ge.runningXinerama())
{
! 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(), scale);
}
finally
{
XToolkit.awtUnlock();
}
*** 781,791 ****
* _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)
{
/*
* 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.
--- 791,802 ----
* _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, 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,852 ****
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);
if (windowLevel > 1)
{
! windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds);
}
// 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);
/*
* struts could be relative to root window bounds, so
* make them relative to the screen bounds in this case
*/
--- 840,866 ----
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,
! scale);
if (windowLevel > 1)
{
! 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 = 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,2495 ****
addEventDispatcher(win.getWindow(), oops_waiter);
oops_updated = false;
long event_number = getEventNumber();
// Generate OOPS ConfigureNotify event
! XlibWrapper.XMoveWindow(getDisplay(), win.getWindow(), ++oops_position, 0);
// Change win position each time to avoid system optimization
if (oops_position > 50) {
oops_position = 0;
}
--- 2499,2510 ----
addEventDispatcher(win.getWindow(), oops_waiter);
oops_updated = false;
long event_number = getEventNumber();
// Generate OOPS ConfigureNotify event
! 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 >