Skip to content

Commit dd3da21

Browse files
committed
Fix various present-mode problems
1 parent d68adf4 commit dd3da21

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

runtime/src/jycessing/PAppletJythonDriver.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.awt.Component;
1919
import java.awt.EventQueue;
20+
import java.awt.Window;
2021
import java.awt.event.ComponentAdapter;
2122
import java.awt.event.ComponentEvent;
2223
import java.awt.event.WindowAdapter;
@@ -27,8 +28,10 @@
2728
import java.io.StringWriter;
2829
import java.lang.Thread.UncaughtExceptionHandler;
2930
import java.lang.reflect.Field;
31+
import java.lang.reflect.Method;
3032
import java.lang.reflect.Modifier;
3133
import java.util.ArrayList;
34+
import java.util.Arrays;
3235
import java.util.HashSet;
3336
import java.util.List;
3437
import java.util.concurrent.CountDownLatch;
@@ -591,13 +594,42 @@ public void componentMoved(final ComponentEvent e) {
591594
// fallthrough
592595
}
593596
} finally {
597+
if(PApplet.platform == PApplet.MACOSX && Arrays.asList(args).contains(PApplet.ARGS_FULL_SCREEN)) {
598+
// Frame should be OS-X fullscreen, and it won't stop being that unless the jvm
599+
// exits or we explicitly tell it to minimize.
600+
// (If it's disposed, it'll leave a gray blank window behind it.)
601+
Runner.log("Disabling fullscreen.");
602+
macosxFullScreenToggle(frame);
603+
}
594604
frame.dispose();
595605
}
596606
if (terminalException != null) {
597607
throw terminalException;
598608
}
599609
}
600610

611+
/**
612+
* Use reflection to call
613+
* <code>com.apple.eawt.Application.getApplication().requestToggleFullScreen(window);</code>
614+
*/
615+
static private void macosxFullScreenToggle(final Window window) {
616+
try {
617+
final Class<?> appClass = Class.forName("com.apple.eawt.Application");
618+
619+
final Method getAppMethod = appClass.getMethod("getApplication");
620+
final Object app = getAppMethod.invoke(null, new Object[0]);
621+
622+
final Method requestMethod =
623+
appClass.getMethod("requestToggleFullScreen", Window.class);
624+
requestMethod.invoke(app, window);
625+
626+
} catch (final ClassNotFoundException cnfe) {
627+
// ignored
628+
} catch (Exception e) {
629+
e.printStackTrace();
630+
}
631+
}
632+
601633
/**
602634
* Permit the punning use of set() by mucking with the builtin "set" Type.
603635
* If you call it with 3 arguments, it acts like the Processing set(x, y,

runtime/src/jycessing/mode/run/PdeSketch.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public String[] getPAppletArguments() {
9999
break;
100100
case PRESENTATION:
101101
args.add(PApplet.ARGS_FULL_SCREEN);
102-
args.add(PApplet.ARGS_HIDE_STOP);
103102
break;
104103
}
105104

runtime/src/jycessing/mode/run/SketchServiceProcess.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private ProcessBuilder createServerCommand() {
117117
if (Base.isMacOS()) {
118118
// Suppress dock icon.
119119
command.add("-Dapple.awt.UIElement=true");
120+
command.add("-Xdock:name=Processing");
120121
}
121122

122123
if (PythonMode.VERBOSE) {

0 commit comments

Comments
 (0)