提交 3c9b71b1 编写于 作者: B bagiras

7033533: realSync() doesn't work with Xfce

Reviewed-by: anthony, serb, leonidr
上级 f243d3c4
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -46,7 +46,8 @@ class XRootWindow extends XBaseWindow { ...@@ -46,7 +46,8 @@ class XRootWindow extends XBaseWindow {
} }
private XRootWindow() { 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){ public void postInit(XCreateWindowParams params){
......
...@@ -2354,9 +2354,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -2354,9 +2354,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
private static XEventDispatcher oops_waiter; private static XEventDispatcher oops_waiter;
private static boolean oops_updated; private static boolean oops_updated;
private static boolean oops_failed; private static boolean oops_move;
private XAtom oops;
private static final long WORKAROUND_SLEEP = 100;
/** /**
* @inheritDoc * @inheritDoc
...@@ -2367,52 +2365,33 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -2367,52 +2365,33 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
if (oops_waiter == null) { if (oops_waiter == null) {
oops_waiter = new XEventDispatcher() { oops_waiter = new XEventDispatcher() {
public void dispatchEvent(XEvent e) { public void dispatchEvent(XEvent e) {
if (e.get_type() == XConstants.SelectionNotify) { if (e.get_type() == XConstants.ConfigureNotify) {
XSelectionEvent pe = e.get_xselection(); // OOPS ConfigureNotify event catched
if (pe.get_property() == oops.getAtom()) { oops_updated = true;
oops_updated = true; awtLockNotifyAll();
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 (oops == null) {
oops = XAtom.get("OOPS");
}
awtLock(); awtLock();
try { try {
addEventDispatcher(win.getWindow(), oops_waiter); addEventDispatcher(win.getWindow(), oops_waiter);
oops_updated = false; oops_updated = false;
oops_failed = false;
// Wait for selection notify for oops on win
long event_number = getEventNumber(); long event_number = getEventNumber();
XAtom atom = XAtom.get("WM_S0"); // Generate OOPS ConfigureNotify event
if (eventLog.isLoggable(PlatformLogger.Level.FINER)) { XlibWrapper.XMoveWindow(getDisplay(), win.getWindow(), oops_move ? 0 : 1, 0);
eventLog.finer("WM_S0 selection owner {0}", XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom())); // Change win position each time to avoid system optimization
} oops_move = !oops_move;
XlibWrapper.XConvertSelection(getDisplay(), atom.getAtom(),
XAtom.get("VERSION").getAtom(), oops.getAtom(),
win.getWindow(), XConstants.CurrentTime);
XSync(); XSync();
eventLog.finer("Requested OOPS"); eventLog.finer("Generated OOPS ConfigureNotify event");
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (!oops_updated && !oops_failed) { while (!oops_updated) {
try { try {
// Wait for OOPS ConfigureNotify event
awtLockWait(timeout); awtLockWait(timeout);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -2423,20 +2402,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -2423,20 +2402,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
throw new OperationTimedOut(Long.toString(System.currentTimeMillis() - start)); throw new OperationTimedOut(Long.toString(System.currentTimeMillis() - start));
} }
} }
if (oops_failed && getEventNumber() - event_number == 1) { // Don't take into account OOPS ConfigureNotify event
// If selection update failed we can simply wait some time return getEventNumber() - event_number > 1;
// 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;
} finally { } finally {
removeEventDispatcher(win.getWindow(), oops_waiter); removeEventDispatcher(win.getWindow(), oops_waiter);
eventLog.finer("Exiting syncNativeQueue"); eventLog.finer("Exiting syncNativeQueue");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册