7033533: realSync() doesn't work with Xfce
Reviewed-by: anthony, serb, leonidr
This commit is contained in:
parent
d0df7fb561
commit
ce0900eb72
jdk/src/solaris/classes/sun/awt/X11
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,7 +46,8 @@ class XRootWindow extends XBaseWindow {
|
||||
}
|
||||
|
||||
private XRootWindow() {
|
||||
super(new XCreateWindowParams(new Object[] {DELAYED, Boolean.TRUE}));
|
||||
super(new XCreateWindowParams(new Object[] { DELAYED, Boolean.TRUE,
|
||||
EVENT_MASK, XConstants.StructureNotifyMask }));
|
||||
}
|
||||
|
||||
public void postInit(XCreateWindowParams params){
|
||||
|
@ -2382,9 +2382,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
|
||||
private static XEventDispatcher oops_waiter;
|
||||
private static boolean oops_updated;
|
||||
private static boolean oops_failed;
|
||||
private XAtom oops;
|
||||
private static final long WORKAROUND_SLEEP = 100;
|
||||
private static boolean oops_move;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
@ -2395,52 +2393,33 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
if (oops_waiter == null) {
|
||||
oops_waiter = new XEventDispatcher() {
|
||||
public void dispatchEvent(XEvent e) {
|
||||
if (e.get_type() == XConstants.SelectionNotify) {
|
||||
XSelectionEvent pe = e.get_xselection();
|
||||
if (pe.get_property() == oops.getAtom()) {
|
||||
oops_updated = true;
|
||||
awtLockNotifyAll();
|
||||
} else if (pe.get_selection() == XAtom.get("WM_S0").getAtom() &&
|
||||
pe.get_target() == XAtom.get("VERSION").getAtom() &&
|
||||
pe.get_property() == 0 &&
|
||||
XlibWrapper.XGetSelectionOwner(getDisplay(), XAtom.get("WM_S0").getAtom()) == 0)
|
||||
{
|
||||
// WM forgot to acquire selection or there is no WM
|
||||
oops_failed = true;
|
||||
awtLockNotifyAll();
|
||||
}
|
||||
|
||||
if (e.get_type() == XConstants.ConfigureNotify) {
|
||||
// OOPS ConfigureNotify event catched
|
||||
oops_updated = true;
|
||||
awtLockNotifyAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (oops == null) {
|
||||
oops = XAtom.get("OOPS");
|
||||
}
|
||||
|
||||
awtLock();
|
||||
try {
|
||||
addEventDispatcher(win.getWindow(), oops_waiter);
|
||||
|
||||
oops_updated = false;
|
||||
oops_failed = false;
|
||||
// Wait for selection notify for oops on win
|
||||
long event_number = getEventNumber();
|
||||
XAtom atom = XAtom.get("WM_S0");
|
||||
if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
eventLog.finer("WM_S0 selection owner {0}", XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom()));
|
||||
}
|
||||
XlibWrapper.XConvertSelection(getDisplay(), atom.getAtom(),
|
||||
XAtom.get("VERSION").getAtom(), oops.getAtom(),
|
||||
win.getWindow(), XConstants.CurrentTime);
|
||||
// Generate OOPS ConfigureNotify event
|
||||
XlibWrapper.XMoveWindow(getDisplay(), win.getWindow(), oops_move ? 0 : 1, 0);
|
||||
// Change win position each time to avoid system optimization
|
||||
oops_move = !oops_move;
|
||||
XSync();
|
||||
|
||||
eventLog.finer("Requested OOPS");
|
||||
eventLog.finer("Generated OOPS ConfigureNotify event");
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
while (!oops_updated && !oops_failed) {
|
||||
while (!oops_updated) {
|
||||
try {
|
||||
// Wait for OOPS ConfigureNotify event
|
||||
awtLockWait(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -2451,20 +2430,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
throw new OperationTimedOut(Long.toString(System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
if (oops_failed && getEventNumber() - event_number == 1) {
|
||||
// If selection update failed we can simply wait some time
|
||||
// hoping some events will arrive
|
||||
awtUnlock();
|
||||
eventLog.finest("Emergency sleep");
|
||||
try {
|
||||
Thread.sleep(WORKAROUND_SLEEP);
|
||||
} catch (InterruptedException ie) {
|
||||
throw new RuntimeException(ie);
|
||||
} finally {
|
||||
awtLock();
|
||||
}
|
||||
}
|
||||
return getEventNumber() - event_number > 2;
|
||||
// Don't take into account OOPS ConfigureNotify event
|
||||
return getEventNumber() - event_number > 1;
|
||||
} finally {
|
||||
removeEventDispatcher(win.getWindow(), oops_waiter);
|
||||
eventLog.finer("Exiting syncNativeQueue");
|
||||
|
Loading…
x
Reference in New Issue
Block a user