Skip to content

Commit

Permalink
8315657: Application window not activated in macOS 14 Sonoma
Browse files Browse the repository at this point in the history
Backport-of: f2dd4bd
  • Loading branch information
kevinrushforth committed Sep 26, 2023
1 parent 7225483 commit 29afbbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void runLoop(final Runnable launchable) {
// We need to spin up a nested event loop and wait for the reactivation
// to finish prior to allowing the rest of the initialization to run.
final Runnable wrappedRunnable = () -> {
if (isNormalTaskbarApp()) {
if (isTriggerReactivation()) {
waitForReactivation();
}
launchable.run();
Expand Down Expand Up @@ -367,9 +367,9 @@ protected boolean _supportsTransparentWindows() {

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

private native String _getDataDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
static BOOL isFullScreenExitingLoop = NO;
static NSMutableDictionary * keyCodeForCharMap = nil;
static BOOL isEmbedded = NO;
static BOOL isNormalTaskbarApp = NO;
static BOOL triggerReactivation = NO;
static BOOL disableSyncRendering = NO;
static BOOL firstActivation = YES;
static BOOL shouldReactivate = NO;
Expand Down Expand Up @@ -265,7 +265,7 @@ - (void)applicationDidBecomeActive:(NSNotification *)aNotification
[pool drain];
GLASS_CHECK_EXCEPTION(env);

if (isNormalTaskbarApp && firstActivation) {
if (triggerReactivation && firstActivation) {
LOG("-> deactivate (hide) app");
firstActivation = NO;
shouldReactivate = YES;
Expand Down Expand Up @@ -298,7 +298,7 @@ - (void)applicationDidResignActive:(NSNotification *)aNotification
[pool drain];
GLASS_CHECK_EXCEPTION(env);

if (isNormalTaskbarApp && shouldReactivate) {
if (triggerReactivation && shouldReactivate) {
LOG("-> reactivate app");
shouldReactivate = NO;
[NSApp activateIgnoringOtherApps:YES];
Expand Down Expand Up @@ -536,7 +536,16 @@ - (void)runLoop:(id)selector
}
if (self->jTaskBarApp == JNI_TRUE)
{
isNormalTaskbarApp = YES;
triggerReactivation = YES;

// The workaround of deactivating and reactivating
// the application so that the system menu bar works
// correctly is no longer needed (and no longer works
// anyway) as of macOS 14
if (@available(macOS 14.0, *)) {
triggerReactivation = NO;
}

// move process from background only to full on app with visible Dock icon
ProcessSerialNumber psn;
if (GetCurrentProcess(&psn) == noErr)
Expand Down Expand Up @@ -1066,14 +1075,14 @@ + (BOOL)syncRenderingDisabled {

/*
* Class: com_sun_glass_ui_mac_MacApplication
* Method: _isNormalTaskbarApp
* Method: _isTriggerReactivation
* Signature: ()Z;
*/
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_mac_MacApplication__1isNormalTaskbarApp
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_mac_MacApplication__1isTriggerReactivation
(JNIEnv *env, jobject japplication)
{
LOG("Java_com_sun_glass_ui_mac_MacApplication__1isNormalTaskbarApp");
return isNormalTaskbarApp;
LOG("Java_com_sun_glass_ui_mac_MacApplication__1isTriggerReactivation");
return triggerReactivation;
}

/*
Expand Down

1 comment on commit 29afbbc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.