JBR-3575 use flag processEvents in LWCToolkit.invokeAndWait

(cherry picked from commit dcf9ff3315)
This commit is contained in:
Artem Bochkarev
2022-11-11 09:47:26 +07:00
committed by jbrbot
parent 574b1ee1eb
commit 9633ece11d
2 changed files with 13 additions and 2 deletions

View File

@@ -710,6 +710,12 @@ public final class LWCToolkit extends LWToolkit {
public static void invokeAndWait(Runnable runnable, Component component, int timeoutSeconds)
throws InvocationTargetException
{
invokeAndWait(runnable, component, false, -1);
}
public static void invokeAndWait(Runnable runnable, Component component, boolean processEvents, int timeoutSeconds)
throws InvocationTargetException
{
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("invokeAndWait started: " + runnable);
@@ -759,7 +765,7 @@ public final class LWCToolkit extends LWToolkit {
invocationEvent.onDone(() -> eventDispatchThreadFreeFuture.cancel(false));
}
if (!doAWTRunLoop(mediator, false, timeoutSeconds)) {
if (!doAWTRunLoop(mediator, processEvents, timeoutSeconds)) {
invocationEvent.dispose("InvocationEvent has timed out");
}

View File

@@ -40,6 +40,7 @@
#import "sun_lwawt_macosx_LWCToolkit.h"
#import "sizecalc.h"
#import "AWTWindow.h"
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
@@ -612,7 +613,11 @@ JNI_COCOA_ENTER(env);
untilDate:nil
inMode:NSDefaultRunLoopMode
dequeue:YES]) != nil) {
[NSApp sendEvent:event];
if ([event.window isKindOfClass:[AWTWindow_Normal class]]) {
// Filter only events from AWTWindow (to skip events from ScreenMenu)
// See https://youtrack.jetbrains.com/issue/IDEA-305287/Implement-non-blocking-ScreenMenu.invokeOpenLater#focus=Comments-27-6614719.0-0
[NSApp sendEvent:event];
}
}
}