|
17 | 17 |
|
18 | 18 | import java.awt.Component; |
19 | 19 | import java.awt.EventQueue; |
| 20 | +import java.awt.Window; |
20 | 21 | import java.awt.event.ComponentAdapter; |
21 | 22 | import java.awt.event.ComponentEvent; |
22 | 23 | import java.awt.event.WindowAdapter; |
|
27 | 28 | import java.io.StringWriter; |
28 | 29 | import java.lang.Thread.UncaughtExceptionHandler; |
29 | 30 | import java.lang.reflect.Field; |
| 31 | +import java.lang.reflect.Method; |
30 | 32 | import java.lang.reflect.Modifier; |
31 | 33 | import java.util.ArrayList; |
| 34 | +import java.util.Arrays; |
32 | 35 | import java.util.HashSet; |
33 | 36 | import java.util.List; |
34 | 37 | import java.util.concurrent.CountDownLatch; |
@@ -591,13 +594,42 @@ public void componentMoved(final ComponentEvent e) { |
591 | 594 | // fallthrough |
592 | 595 | } |
593 | 596 | } 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 | + } |
594 | 604 | frame.dispose(); |
595 | 605 | } |
596 | 606 | if (terminalException != null) { |
597 | 607 | throw terminalException; |
598 | 608 | } |
599 | 609 | } |
600 | 610 |
|
| 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 | + |
601 | 633 | /** |
602 | 634 | * Permit the punning use of set() by mucking with the builtin "set" Type. |
603 | 635 | * If you call it with 3 arguments, it acts like the Processing set(x, y, |
|
0 commit comments