< prev index next >
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
Print this page
*** 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) {
--- 420,443 ----
} 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();
}
}
--- 452,466 ----
// 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
--- 494,508 ----
}
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
*** 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
--- 704,714 ----
@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);
--- 720,731 ----
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 / scale, rootY / scale,
! rootWidth / scale, 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();
}
--- 754,783 ----
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.
--- 788,799 ----
* _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
*/
--- 837,863 ----
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 = (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
* 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;
}
--- 2496,2507 ----
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 >