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: jpereda, aghaisas
  • Loading branch information
kevinrushforth committed Sep 26, 2023
1 parent 5d1254f commit f2dd4bd
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

7 comments on commit f2dd4bd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@kevinrushforth
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jfx jfx21u

@kevinrushforth
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jfx21u

@openjdk
Copy link

@openjdk openjdk bot commented on f2dd4bd Sep 26, 2023

Choose a reason for hiding this comment

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

@kevinrushforth The target branch jfx21u does not exist

@openjdk
Copy link

@openjdk openjdk bot commented on f2dd4bd Sep 26, 2023

Choose a reason for hiding this comment

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

@kevinrushforth the backport was successfully created on the branch kevinrushforth-backport-f2dd4bdb in my personal fork of openjdk/jfx21u. To create a pull request with this backport targeting openjdk/jfx21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f2dd4bdb from the openjdk/jfx repository.

The commit being backported was authored by Kevin Rushforth on 26 Sep 2023 and was reviewed by Jose Pereda and Ajit Ghaisas.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jfx21u:

$ git fetch https://github.com/openjdk-bots/jfx21u.git kevinrushforth-backport-f2dd4bdb:kevinrushforth-backport-f2dd4bdb
$ git checkout kevinrushforth-backport-f2dd4bdb
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jfx21u.git kevinrushforth-backport-f2dd4bdb

@kevinrushforth
Copy link
Member Author

Choose a reason for hiding this comment

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

/tag 22+11

@openjdk
Copy link

@openjdk openjdk bot commented on f2dd4bd Sep 28, 2023

Choose a reason for hiding this comment

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

@kevinrushforth The tag 22+11 was successfully created.

Please sign in to comment.