From 42d06129c6023c92653a4460cf32d675cf838288 Mon Sep 17 00:00:00 2001 From: Jim Date: Mon, 9 Dec 2024 21:27:20 -0500 Subject: [PATCH 1/7] add activate() jni call --- core/different/different.m | 11 +++++++++-- core/different/libDifferent_aarch64 | Bin 50273 -> 50408 bytes core/different/libDifferent_x86_64 | Bin 33240 -> 8736 bytes core/src/processing/core/ThinkDifferent.java | 1 + core/src/processing/core/libDifferent.jnilib | Bin 115809 -> 66792 bytes 5 files changed, 10 insertions(+), 2 deletions(-) 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 f45612d57094336a311d7a3adb3633c73b6bd769..5074f3385708c8c4c9e101eba7bc2c7650f5441b 100755 GIT binary patch delta 943 zcmYjPZAep57(VCTJHHz90~Zrr-pr4bv@s9|v)#Ld$g~`0I4x{LmrlZs>56dXqJ9_= z%#JV&v;O5rp}0bVer!rnRK%hWe^g{YQm7zbX6GozXrF-`Viqk4ilR_0L6k*Fe<1UMmd z2RC7?A((H*tE7eRt@Oh-4yXanh7n4GXpJCb!w7AIxdlkUGYSxs2^R9Ph3pjabtyIT zEmxa$=cj{>`XTS*89n$S5Yhqg20;~@(|n}V3dAiGKmkNJ#&aEJ@>Qr5eERuRQmD98 zJP}4H1-6v}Gk~-n3N4W8@B%`+xlmMbz(9N^1D45slZ18Tm&urxgV4zDe)HtkMe@f~ zMs$*e*d#?^io6M#vl&V9CgSqnib#B&puN4%dB)!7Kx8YDOZ<|ijMkh7r1(G5^P$%x zL!?wnL?v$ztx6g>D{&ECcI*KO>YFx%J}GLFh0FqUlnCMa!6wLpBODumVQB!@cJ{bD z&YsSOzAlHy>~{B}avqKNzI#tllBLN3Vwy^J#jsVs@Ot3+W;O)hqWcvbvmZUn07Ip=*nA6pJ09zG^EFF6{ct@ zu4#9~@C8Qj>1P1Ru?MA)qKKZ9Mm~}s5escJ1|lsO6k(A=O6b!Pyg~fDRvg#2)y>=< zoU~prwmh`Xt*BD-K66>eL#cI>&PrYVuc%IXJuC)~xi=9tdseb|N%hEXj delta 775 zcmXw1ZAep57(QqB+*)Mi$dS3G*AbSOS~jO8?OrodD8Wh*L)r$7tjI)*KvwRDhW#)m zZ-rr!kraiQF^zsCY;zF)5KpJA2`|=Y7umb?$S{@-=CpQ}T5h zJa!VZaC{-2?%S$SQ{zk%o1DwtpG%Bh5!fvPoKx6GON=8TQXwLo>tISYfltT$gS48` zWS~+lbwQofQrLuPIz%d>KR}2c*X=>%l#sRPS0T9Z91aN~17#UhflQXMv$Vc7m@{cJ zk1Q6==6(1$RDf{>f#qn}fv$`BypB+-1Wn9BHvzC3+}Q@7SRrdl|E-6ua(h-!AU;1E zQxi+7t&}mUGg~28TYxpKwzBrjhT$!RZtTwfYIPEctU$15Gs;2MMskG8Dvon+N5-4 zdaQop)#7Zl@4$_D{e_O`U`q7Y!O3HmYTL|8?(09b;2PJIq~m7S*!$+z4x`O+?hp&x zle_L5c{Dw=%VvAK+VQdsg5zFgVEB#J_xEY}P20EijjmqP#(v}1r4zZ&9$ej#W@-5s pfQ50V@^dnBDzYU%|M^f~q|RB+=Bj^Oe>d8@G%)9wxqI){@_+QszH|Tp diff --git a/core/different/libDifferent_x86_64 b/core/different/libDifferent_x86_64 index 7862ddbac8803853a40a5955d01558b2151ad5b8..29df9d82e18c4a519a46242dd4189589f41f73cd 100755 GIT binary patch delta 941 zcmZuwO=uHA6rTOVL`rrWO`E7`cCA8HOk!lMh~!6mSjCv4MtX@h*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4RnyU&YiFB&48EHL=< z_a8-!Zq}>R_!wuz0*7S6m?l`8Q-ehcu*SA2-fw$7H@;B!OvOQYzb?oHoZw+WI4rv) znZF`)mSGKyiZxP%dos#qn8Hu!In6y8aWk9|cl@}!iBb`$XA2F$R!?W;-z2D{)v!g)q2Gdr$8q2ds7SU? z6^Po^|Dn#c!^%I@iI|OIG^TKQiV&+RrPv{P7Z}6UvmG-lHQ$vIE3Z|~u8A?yaf-3r0 zOi|G)jcieooFUs<{9kr?OqPr1n=gER_44AV_t1j&wf@E9#>L;CoO!OK$#H3E!|dHH zv4EP&mYi+Hf%D&Y?CX~tEw4N!B%I>lyU%`faopx`%w@Hl^Ta0AG-5e+@@skY-ii9R z9lzx64jd^mj7hhyJ-^}92X8#Gx} Date: Sat, 11 Jan 2025 18:42:12 -0500 Subject: [PATCH 2/7] new activateSketchWindow static method for macOS --- core/src/processing/core/ThinkDifferent.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index bf1d201384..411e093e84 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -129,6 +129,22 @@ static private Desktop getDesktop() { static native public void activate(); + // Used by py5 to bring windows to the front + static public void activateSketchWindow() { + try { + String osVersion = System.getProperty("os.version"); + int versionNumber = Integer.parseInt(osVersion.split("\\.")[0]); + + if (versionNumber >= 14) { + activate(); + } else if (versionNumber >= 10) { + activateIgnoringOtherApps(); + } + } catch (Exception e) { + // ignore + } + } + static { final String NATIVE_FILENAME = "libDifferent.jnilib"; try { From 03a4c03e32d7d0f4cd7bf2bc36fccdbdb088bb6d Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 11 Jan 2025 18:47:26 -0500 Subject: [PATCH 3/7] recompile native code --- core/different/different.m | 2 -- core/different/libDifferent_aarch64 | Bin 50408 -> 50408 bytes core/different/libDifferent_x86_64 | Bin 8736 -> 8736 bytes core/src/processing/core/libDifferent.jnilib | Bin 66792 -> 66792 bytes 4 files changed, 2 deletions(-) diff --git a/core/different/different.m b/core/different/different.m index 5edfbe0f69..400284063c 100644 --- a/core/different/different.m +++ b/core/different/different.m @@ -18,14 +18,12 @@ [NSApp setPresentationOptions:0]; } - JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activateIgnoringOtherApps (JNIEnv *env, jclass klass) { [NSApp activateIgnoringOtherApps:true]; } - JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activate (JNIEnv *env, jclass klass) { diff --git a/core/different/libDifferent_aarch64 b/core/different/libDifferent_aarch64 index 5074f3385708c8c4c9e101eba7bc2c7650f5441b..8021f386e1efcd502b0fdbf5739638227760833b 100755 GIT binary patch delta 542 zcmaFS$^4>|c|wOEhaCeL{D4pl91~~Si!#_lcnMHJ5TAA8TWi4tsDuqvB4M&6qrK=H zsAvRK6vStme34ap@&qQ9&1)E^FzM$#^GLFgwqChQPpein=17wfP^khCGlI2n1J(0` z*~~ybGkf&pe3nWe(|z)57E=~sIexCqDy&Z|HjCJ8VB`h4*a4^vgc&AZw0EBTfR$&n zh{GFuxbrfh4rXj*aPBh9W_Aag~?S1^y)imJRCs&_zuK!Oh5vv zi4W)|5MKexH;3{apnQ;0exTSHXvi5r`4gc0d?+6lvJ0U60I2*$ARnlGv-&|PCWT$E zdA>1SH%zX%{oPdkr?>ynqbb{rO_}S?zP8#n(WSL)a^hhJh1WCXuTP)idiW;WtDm#G z_jMll^DI`VD1bq5X>&@5rhnh$gNGXwQun8aOi4)|c|wPvh#dnM{D4plA`@rYi}Kh*cnMHJ5T9w{TWi4_sDuqvB4@HCqrK<~ zsAvRK6vStme34ap@&qQ9&1)E^FzItRZ;$K^H>g`ZJ;+}!`7D*pOev0&U$dC9)EI5&+^oX-#A5OTR-Vlqb{iP^K(2NGssv#k`^kI` zVw3OK>ueTrcw-NDV=2^C6E+JrxH+)RsbyehxG_2QfH>Qf8X)t|A*1LPMfW5v=(9VknGvAo2 zgq%n-xO*VK$Rc6=)x?LBA0AFnUo|~$0^{0C*3)P4Xx1Dp*i<9>G132wWL9NV6r-9# K`bnVEKmY&~&xDcy diff --git a/core/different/libDifferent_x86_64 b/core/different/libDifferent_x86_64 index 29df9d82e18c4a519a46242dd4189589f41f73cd..342e899ec782c80034a09f315be5fe58dabe2f80 100755 GIT binary patch delta 111 zcmZ4BvcP4-3TFA{$}6uLoa~==WUcdFWc}@w3IhX!01z|qa4|42@lQU^T*=J9;6B-z z#gs)@j-P9D4U0GzW8>s0e9nxvlW*{qGG3qT$A3zwksqXqfgue_$MSDB6gba6Ie?LU IlY#;h0BztMg8%>k delta 111 zcmZ4BvcP4-3TF8OP5SY#^^DEi8|KTizSoe3OqeS28oDI8JtE zF=eSS+RnMThDDrb6gba6Ie?LU IlY#;h0Pm9=#{d8T diff --git a/core/src/processing/core/libDifferent.jnilib b/core/src/processing/core/libDifferent.jnilib index cbeef9189fb4e21a710900e5ee3faa78795c8235..c24b8efe13ae9410ae970282172ae9fc0e1f4bae 100755 GIT binary patch delta 654 zcmaFS$?~F;Wy1<#h33jDuNs`}pLS%e^Il~A?UV`w1A_n%Gw^URFfj2mOfGP#U}j)& zpZwazltoyMpKEiCh&UHx5V>AGQZ&F$}| z>OZ~xj~-3gW^Bq_clNc_wuvsSWz!Rx866Z}&y>GDeTwVhn{2Os&hFmVdEn2pSfQc- z2EnDxDIuEvebWyzGd3us?oSVyl9DRE;H!zi!&^<=B7%8K*!-TIo>0GMOW9+qy6F#@ t857jwraWP__TT1vyExm#R&}@QmSyHHrzGy$<)ppXb8(_PFVJ})006Ujq7VQ8 delta 660 zcmaFS$?~F;Wy1<#g#%6c@vrra&D$I1%d@`Mo2$aWz#ss`3_M&63@m&MlM7rbn3+-> zC%<+vWvMaR&bhfpM4XFp;^ZlE&Wyg3Z^)H09-r(de@ZBpAEb+cAq`45@^8NAdX0aR zL5F~#h#f@k2ZUk}nLN|MUX;fk!cBmRg7{36=L%R0ghp79i_+C8v#`+05Kz22RGP9AT~3I&m%iI z-=z}8bCYXCS~stBjklQSz_Xd7ZUZA9$mtG1#URXMKbfyVZ1SCYoy{T*Z|ntO&Mbwx zYr97&XCTHtr3T2pQ!}~RK(~HMjfVrsN8f>1jtOKOkO2gIKo^1d zI#9kjlWqw1ObYXi;=I={ zuU{F_XdSsHV$*XzPMJqcLeZN!y;tha&9pv0J&~EwK|$~1Jo}l|r%SU|eLAd{Jm2pk z1HVI&=XAC$vhm+1T~}3}evp~5LE*XeS?})20`~egK|3!R%zR_65^^HV;O>F^B8!Ce zR}&vjf5^<3puTE)+yut8m#nAH;?b-*TCk}`^kbs`8Of~5s3=A?h4hm^=YaqKPSK#> From 0ed2e028e59f8d646779b17bdd68f89b904945b1 Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 11 Jan 2025 20:47:22 -0500 Subject: [PATCH 4/7] improve comments --- core/src/processing/core/ThinkDifferent.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index 411e093e84..2bc8935d00 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -124,12 +124,15 @@ 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 windows to the front + // Used by py5 to bring Sketch to the front static public void activateSketchWindow() { try { String osVersion = System.getProperty("os.version"); @@ -141,7 +144,7 @@ static public void activateSketchWindow() { activateIgnoringOtherApps(); } } catch (Exception e) { - // ignore + // do nothing } } From 1cfbd9ece68e95de946e72ed524e2b4d8cce6f85 Mon Sep 17 00:00:00 2001 From: Jim Date: Sun, 12 Jan 2025 09:19:49 -0500 Subject: [PATCH 5/7] make spacing consistent --- core/different/different.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/different/different.m b/core/different/different.m index 400284063c..5edfbe0f69 100644 --- a/core/different/different.m +++ b/core/different/different.m @@ -18,12 +18,14 @@ [NSApp setPresentationOptions:0]; } + JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activateIgnoringOtherApps (JNIEnv *env, jclass klass) { [NSApp activateIgnoringOtherApps:true]; } + JNIEXPORT void JNICALL Java_processing_core_ThinkDifferent_activate (JNIEnv *env, jclass klass) { From 2105c56c5fbd60ee5c0d5e3fb3601213bd246e1d Mon Sep 17 00:00:00 2001 From: Jim Date: Sun, 12 Jan 2025 09:20:14 -0500 Subject: [PATCH 6/7] return true or false instead of hiding exception --- core/src/processing/core/ThinkDifferent.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index 2bc8935d00..c87efa440e 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -133,18 +133,20 @@ static private Desktop getDesktop() { static native public void activate(); // Used by py5 to bring Sketch to the front - static public void activateSketchWindow() { + 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) { - // do nothing + return false; } } From 6dc53695da653737db1a17032462241b3f45a52f Mon Sep 17 00:00:00 2001 From: Jim Date: Sun, 12 Jan 2025 09:24:34 -0500 Subject: [PATCH 7/7] add missing return statement --- core/src/processing/core/ThinkDifferent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index c87efa440e..bfa6768bee 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -148,6 +148,8 @@ static public boolean activateSketchWindow() { } catch (Exception e) { return false; } + + return false; } static {