8181786: Extra runLater causes impossible states to be possible using javafx.embed.singleThread=true
Reviewed-by: kcr
This commit is contained in:
parent
fbd95a81a8
commit
416b9f9906
@ -161,6 +161,23 @@ class EventDispatchThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
boolean filterAndCheckEvent(AWTEvent event) {
|
||||
boolean eventOK = true;
|
||||
synchronized (eventFilters) {
|
||||
for (int i = eventFilters.size() - 1; i >= 0; i--) {
|
||||
EventFilter f = eventFilters.get(i);
|
||||
EventFilter.FilterAction accept = f.acceptEvent(event);
|
||||
if (accept == EventFilter.FilterAction.REJECT) {
|
||||
eventOK = false;
|
||||
break;
|
||||
} else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return eventOK && SunDragSourceContextPeer.checkEvent(event);
|
||||
}
|
||||
|
||||
void pumpOneEventForFilters(int id) {
|
||||
AWTEvent event = null;
|
||||
boolean eventOK = false;
|
||||
@ -172,20 +189,7 @@ class EventDispatchThread extends Thread {
|
||||
|
||||
event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
|
||||
|
||||
eventOK = true;
|
||||
synchronized (eventFilters) {
|
||||
for (int i = eventFilters.size() - 1; i >= 0; i--) {
|
||||
EventFilter f = eventFilters.get(i);
|
||||
EventFilter.FilterAction accept = f.acceptEvent(event);
|
||||
if (accept == EventFilter.FilterAction.REJECT) {
|
||||
eventOK = false;
|
||||
break;
|
||||
} else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
|
||||
eventOK = filterAndCheckEvent(event);
|
||||
if (!eventOK) {
|
||||
event.consume();
|
||||
}
|
||||
|
@ -719,7 +719,9 @@ public class EventQueue {
|
||||
fwDispatcher.scheduleDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dispatchEventImpl(event, src);
|
||||
if (dispatchThread.filterAndCheckEvent(event)) {
|
||||
dispatchEventImpl(event, src);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1008,6 +1010,32 @@ public class EventQueue {
|
||||
return createSecondaryLoop(null, null, 0);
|
||||
}
|
||||
|
||||
private class FwSecondaryLoopWrapper implements SecondaryLoop {
|
||||
final private SecondaryLoop loop;
|
||||
final private EventFilter filter;
|
||||
|
||||
public FwSecondaryLoopWrapper(SecondaryLoop loop, EventFilter filter) {
|
||||
this.loop = loop;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enter() {
|
||||
if (filter != null) {
|
||||
dispatchThread.addEventFilter(filter);
|
||||
}
|
||||
return loop.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exit() {
|
||||
if (filter != null) {
|
||||
dispatchThread.removeEventFilter(filter);
|
||||
}
|
||||
return loop.exit();
|
||||
}
|
||||
}
|
||||
|
||||
SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
|
||||
pushPopLock.lock();
|
||||
try {
|
||||
@ -1016,7 +1044,7 @@ public class EventQueue {
|
||||
return nextQueue.createSecondaryLoop(cond, filter, interval);
|
||||
}
|
||||
if (fwDispatcher != null) {
|
||||
return fwDispatcher.createSecondaryLoop();
|
||||
return new FwSecondaryLoopWrapper(fwDispatcher.createSecondaryLoop(), filter);
|
||||
}
|
||||
if (dispatchThread == null) {
|
||||
initDispatchThread();
|
||||
|
Loading…
x
Reference in New Issue
Block a user