mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-3017 Focus issue in presence of third-party accessibility tool
(cherry picked from commit88ead5d9e3) (cherry picked from commit97753f15b6)
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
import sun.awt.AWTThreading;
|
||||
|
||||
final class CWrapper {
|
||||
private CWrapper() { }
|
||||
|
||||
@@ -60,7 +62,11 @@ final class CWrapper {
|
||||
*
|
||||
* @param window the pointer of the NSWindow
|
||||
*/
|
||||
static native void orderOut(long window);
|
||||
static void orderOut(long window) {
|
||||
AWTThreading.executeWaitToolkit(() -> nativeOrderOut(window));
|
||||
}
|
||||
|
||||
private static native void nativeOrderOut(long window);
|
||||
|
||||
/**
|
||||
* Removes the window from the screen and releases it. According to
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, 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,6 @@
|
||||
jint preFullScreenLevel;
|
||||
NSRect standardFrame;
|
||||
BOOL isMinimizing;
|
||||
BOOL keyNotificationRecd;
|
||||
}
|
||||
|
||||
// An instance of either AWTWindow_Normal or AWTWindow_Panel
|
||||
@@ -62,7 +61,6 @@
|
||||
@property (nonatomic) jint preFullScreenLevel;
|
||||
@property (nonatomic) NSRect standardFrame;
|
||||
@property (nonatomic) BOOL isMinimizing;
|
||||
@property (nonatomic) BOOL keyNotificationRecd;
|
||||
|
||||
- (id) initWithPlatformWindow:(jobject)javaPlatformWindow
|
||||
ownerWindow:owner
|
||||
|
||||
@@ -250,7 +250,6 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
@synthesize preFullScreenLevel;
|
||||
@synthesize standardFrame;
|
||||
@synthesize isMinimizing;
|
||||
@synthesize keyNotificationRecd;
|
||||
|
||||
- (void) updateMinMaxSize:(BOOL)resizable {
|
||||
if (resizable) {
|
||||
@@ -389,7 +388,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
if (self.nsWindow == nil) return nil; // no hope either
|
||||
[self.nsWindow release]; // the property retains the object already
|
||||
|
||||
self.keyNotificationRecd = NO;
|
||||
self.isEnabled = YES;
|
||||
self.isMinimizing = NO;
|
||||
self.javaPlatformWindow = platformWindow;
|
||||
@@ -772,16 +770,9 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
[AWTToolkit eventCountPlusPlus];
|
||||
#ifdef DEBUG
|
||||
NSLog(@"became main: %d %@ %@ %d", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow], self.keyNotificationRecd);
|
||||
NSLog(@"became main: %d %@ %@", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow]);
|
||||
#endif
|
||||
|
||||
// if for some reason, no KEY notification is received but this main window is also a key window
|
||||
// then we need to execute the KEY notification functionality.
|
||||
if(self.keyNotificationRecd != YES && [self.nsWindow isKeyWindow]) {
|
||||
[self doWindowDidBecomeKey];
|
||||
}
|
||||
self.keyNotificationRecd = NO;
|
||||
|
||||
if (![self.nsWindow isKeyWindow]) {
|
||||
[self activateWindowMenuBar];
|
||||
}
|
||||
@@ -803,12 +794,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
#ifdef DEBUG
|
||||
NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]);
|
||||
#endif
|
||||
[self doWindowDidBecomeKey];
|
||||
self.keyNotificationRecd = YES;
|
||||
}
|
||||
|
||||
- (void) doWindowDidBecomeKey {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
AWTWindow *opposite = [AWTWindow lastKeyWindow];
|
||||
|
||||
if (![self.nsWindow isMainWindow]) {
|
||||
|
||||
@@ -156,11 +156,11 @@ JNI_COCOA_EXIT(env);
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSWindow
|
||||
* Method: orderOut
|
||||
* Method: nativeOrderOut
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderOut
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_nativeOrderOut
|
||||
(JNIEnv *env, jclass cls, jlong windowPtr)
|
||||
{
|
||||
JNI_COCOA_ENTER(env);
|
||||
@@ -169,7 +169,7 @@ JNI_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(orderOut:)
|
||||
on:window
|
||||
withObject:window
|
||||
waitUntilDone:NO];
|
||||
waitUntilDone:YES];
|
||||
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,16 @@ public class AWTThreading {
|
||||
return executeWaitToolkit(callable, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #executeWaitToolkit(Callable)}, but without returning a value.
|
||||
*/
|
||||
public static void executeWaitToolkit(Runnable runnable) {
|
||||
executeWaitToolkit(() -> {
|
||||
runnable.run();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #executeWaitToolkit(Callable)} except that the method waits no longer than the specified timeout.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user