Skip to content

Commit 6e9a982

Browse files
committedSep 27, 2023
8315657: Application window not activated in macOS 14 Sonoma
Backport-of: 29afbbc
1 parent b2850a0 commit 6e9a982

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed
 

‎modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected void runLoop(final Runnable launchable) {
8585
// We need to spin up a nested event loop and wait for the reactivation
8686
// to finish prior to allowing the rest of the initialization to run.
8787
final Runnable wrappedRunnable = () -> {
88-
if (isNormalTaskbarApp()) {
88+
if (isTriggerReactivation()) {
8989
waitForReactivation();
9090
}
9191
launchable.run();
@@ -367,9 +367,9 @@ protected boolean _supportsTransparentWindows() {
367367

368368
// NOTE: this will not return a valid result until the native _runloop
369369
// method has been executed and called the Runnable passed to that method.
370-
native private boolean _isNormalTaskbarApp();
371-
boolean isNormalTaskbarApp() {
372-
return _isNormalTaskbarApp();
370+
native private boolean _isTriggerReactivation();
371+
boolean isTriggerReactivation() {
372+
return _isTriggerReactivation();
373373
}
374374

375375
private native String _getDataDirectory();

‎modules/javafx.graphics/src/main/native-glass/mac/GlassApplication.m

+17-8
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
static BOOL isFullScreenExitingLoop = NO;
5454
static NSMutableDictionary * keyCodeForCharMap = nil;
5555
static BOOL isEmbedded = NO;
56-
static BOOL isNormalTaskbarApp = NO;
56+
static BOOL triggerReactivation = NO;
5757
static BOOL disableSyncRendering = NO;
5858
static BOOL firstActivation = YES;
5959
static BOOL shouldReactivate = NO;
@@ -265,7 +265,7 @@ - (void)applicationDidBecomeActive:(NSNotification *)aNotification
265265
[pool drain];
266266
GLASS_CHECK_EXCEPTION(env);
267267

268-
if (isNormalTaskbarApp && firstActivation) {
268+
if (triggerReactivation && firstActivation) {
269269
LOG("-> deactivate (hide) app");
270270
firstActivation = NO;
271271
shouldReactivate = YES;
@@ -298,7 +298,7 @@ - (void)applicationDidResignActive:(NSNotification *)aNotification
298298
[pool drain];
299299
GLASS_CHECK_EXCEPTION(env);
300300

301-
if (isNormalTaskbarApp && shouldReactivate) {
301+
if (triggerReactivation && shouldReactivate) {
302302
LOG("-> reactivate app");
303303
shouldReactivate = NO;
304304
[NSApp activateIgnoringOtherApps:YES];
@@ -530,7 +530,16 @@ - (void)runLoop:(id)selector
530530
}
531531
if (self->jTaskBarApp == JNI_TRUE)
532532
{
533-
isNormalTaskbarApp = YES;
533+
triggerReactivation = YES;
534+
535+
// The workaround of deactivating and reactivating
536+
// the application so that the system menu bar works
537+
// correctly is no longer needed (and no longer works
538+
// anyway) as of macOS 14
539+
if (@available(macOS 14.0, *)) {
540+
triggerReactivation = NO;
541+
}
542+
534543
// move process from background only to full on app with visible Dock icon
535544
ProcessSerialNumber psn;
536545
if (GetCurrentProcess(&psn) == noErr)
@@ -1060,14 +1069,14 @@ + (BOOL)syncRenderingDisabled {
10601069

10611070
/*
10621071
* Class: com_sun_glass_ui_mac_MacApplication
1063-
* Method: _isNormalTaskbarApp
1072+
* Method: _isTriggerReactivation
10641073
* Signature: ()Z;
10651074
*/
1066-
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_mac_MacApplication__1isNormalTaskbarApp
1075+
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_mac_MacApplication__1isTriggerReactivation
10671076
(JNIEnv *env, jobject japplication)
10681077
{
1069-
LOG("Java_com_sun_glass_ui_mac_MacApplication__1isNormalTaskbarApp");
1070-
return isNormalTaskbarApp;
1078+
LOG("Java_com_sun_glass_ui_mac_MacApplication__1isTriggerReactivation");
1079+
return triggerReactivation;
10711080
}
10721081

10731082
/*

0 commit comments

Comments
 (0)
Please sign in to comment.