diff --git a/core/different/different.m b/core/different/different.m index c93538dee8..5edfbe0f69 100644 --- a/core/different/different.m +++ b/core/different/different.m @@ -1,7 +1,7 @@ #import #import -#import -// #include +// #import +#include JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_hideMenuBar (JNIEnv *env, jclass clazz, jboolean visible, jboolean kioskMode) @@ -24,3 +24,10 @@ { [NSApp activateIgnoringOtherApps:true]; } + + +JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activate +(JNIEnv *env, jclass klass) +{ + [NSApp activate]; +} diff --git a/core/different/libDifferent_aarch64 b/core/different/libDifferent_aarch64 index f45612d570..8021f386e1 100755 Binary files a/core/different/libDifferent_aarch64 and b/core/different/libDifferent_aarch64 differ diff --git a/core/different/libDifferent_x86_64 b/core/different/libDifferent_x86_64 index 7862ddbac8..342e899ec7 100755 Binary files a/core/different/libDifferent_x86_64 and b/core/different/libDifferent_x86_64 differ diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index 141779be51..bfa6768bee 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -124,9 +124,33 @@ static private Desktop getDesktop() { static native public void showMenuBar(); - // Used by Python (Jython) Mode to bring windows to the front + // deprecated + // https://developer.apple.com/documentation/appkit/nsapplication/activate(ignoringotherapps:) static native public void activateIgnoringOtherApps(); + // added in macOS 14 (Sonoma) + // https://developer.apple.com/documentation/appkit/nsapplication/activate() + static native public void activate(); + + // Used by py5 to bring Sketch to the front + static public boolean activateSketchWindow() { + try { + String osVersion = System.getProperty("os.version"); + int versionNumber = Integer.parseInt(osVersion.split("\\.")[0]); + + if (versionNumber >= 14) { + activate(); + return true; + } else if (versionNumber >= 10) { + activateIgnoringOtherApps(); + return true; + } + } catch (Exception e) { + return false; + } + + return false; + } static { final String NATIVE_FILENAME = "libDifferent.jnilib"; diff --git a/core/src/processing/core/libDifferent.jnilib b/core/src/processing/core/libDifferent.jnilib index c45256c03a..c24b8efe13 100755 Binary files a/core/src/processing/core/libDifferent.jnilib and b/core/src/processing/core/libDifferent.jnilib differ