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
Reviewed-by: jvos
Backport-of: f2dd4bd
  • Loading branch information
Jose Pereda committed Sep 27, 2023
1 parent 07955dd commit 7b3027a
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 @@ -374,9 +374,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();
}

native protected String _getRemoteLayerServerName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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 @@ -266,7 +266,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 @@ -299,7 +299,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 @@ -531,7 +531,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 @@ -1067,14 +1076,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

5 comments on commit 7b3027a

@johanvos
Copy link
Collaborator

Choose a reason for hiding this comment

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

/tag 17.0.9+4

@openjdk
Copy link

@openjdk openjdk bot commented on 7b3027a Sep 27, 2023

Choose a reason for hiding this comment

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

@johanvos The tag 17.0.9+4 was successfully created.

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@johanvos
Copy link
Collaborator

Choose a reason for hiding this comment

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

/tag 17.0.10+0

@openjdk
Copy link

@openjdk openjdk bot commented on 7b3027a Oct 25, 2023

Choose a reason for hiding this comment

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

@johanvos The tag 17.0.10+0 was successfully created.

Please sign in to comment.