Skip to content

New ThinkDifferent method activateSketchWindow() #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions core/different/different.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
// #include <jni.h>
// #import <JavaNativeFoundation/JavaNativeFoundation.h>
#include <jni.h>

JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_hideMenuBar
(JNIEnv *env, jclass clazz, jboolean visible, jboolean kioskMode)
Expand All @@ -24,3 +24,10 @@
{
[NSApp activateIgnoringOtherApps:true];
}


JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activate
(JNIEnv *env, jclass klass)
{
[NSApp activate];
}
Binary file modified core/different/libDifferent_aarch64
Binary file not shown.
Binary file modified core/different/libDifferent_x86_64
Binary file not shown.
26 changes: 25 additions & 1 deletion core/src/processing/core/ThinkDifferent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Binary file modified core/src/processing/core/libDifferent.jnilib
Binary file not shown.
Loading