OpenJDK / jdk / jdk
changeset 42190:26d4a824fdea
8143914: Provide Mac-specific fullscreen support
Reviewed-by: serb, ssadetsky
author | azvegint |
---|---|
date | Thu, 03 Nov 2016 03:49:42 +0300 |
parents | d3cb1015f025 |
children | e5ba7d74e3c6 |
files | jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java |
diffstat | 1 files changed, 42 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Nov 02 23:05:52 2016 +0300 +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Nov 03 03:49:42 2016 +0300 @@ -25,10 +25,12 @@ package sun.lwawt.macosx; +import com.apple.eawt.FullScreenAdapter; +import com.apple.eawt.FullScreenUtilities; +import com.apple.eawt.event.FullScreenEvent; import java.awt.*; import java.awt.Dialog.ModalityType; import java.awt.event.*; -import java.awt.peer.WindowPeer; import java.beans.*; import java.lang.reflect.InvocationTargetException; @@ -44,6 +46,7 @@ import com.apple.laf.*; import com.apple.laf.ClientPropertyApplicator.Property; import com.sun.awt.AWTUtilities; +import sun.lwawt.LWWindowPeer.PeerType; public class CPlatformWindow extends CFRetainedResource implements PlatformWindow { private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h); @@ -175,10 +178,24 @@ c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString())); }}, new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { - c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString())); + boolean zoomable = Boolean.parseBoolean(value.toString()); + if (c.target instanceof RootPaneContainer + && c.getPeer().getPeerType() == PeerType.FRAME) { + if (c.isInFullScreen && !zoomable) { + c.toggleFullScreen(); + } + } + c.setStyleBits(ZOOMABLE, zoomable); }}, new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { - c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString())); + boolean fullscrenable = Boolean.parseBoolean(value.toString()); + if (c.target instanceof RootPaneContainer + && c.getPeer().getPeerType() == PeerType.FRAME) { + if (c.isInFullScreen && !fullscrenable) { + c.toggleFullScreen(); + } + } + c.setStyleBits(FULLSCREENABLE, fullscrenable); }}, new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) { nativeRevalidateNSWindowShadow(c.getNSWindowPtr()); @@ -210,6 +227,8 @@ private volatile boolean isFullScreenMode; private boolean isFullScreenAnimationOn; + private volatile boolean isInFullScreen; + private Window target; private LWWindowPeer peer; protected CPlatformView contentView; @@ -308,6 +327,8 @@ styleBits = SET(styleBits, RESIZABLE, resizable); if (!resizable) { styleBits = SET(styleBits, ZOOMABLE, false); + } else { + setCanFullscreen(true); } } @@ -680,9 +701,25 @@ updateFocusabilityForAutoRequestFocus(true); } + private void setCanFullscreen(final boolean canFullScreen) { + if (target instanceof RootPaneContainer + && getPeer().getPeerType() == PeerType.FRAME) { + + if (isInFullScreen && !canFullScreen) { + toggleFullScreen(); + } + + final RootPaneContainer rpc = (RootPaneContainer) target; + rpc.getRootPane().putClientProperty( + CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen); + } + } + @Override public void setResizable(final boolean resizable) { + setCanFullscreen(resizable); setStyleBits(RESIZABLE, resizable); + setStyleBits(ZOOMABLE, resizable); } @Override @@ -1074,6 +1111,7 @@ } private void windowDidEnterFullScreen() { + isInFullScreen = true; isFullScreenAnimationOn = false; } @@ -1082,6 +1120,7 @@ } private void windowDidExitFullScreen() { + isInFullScreen = false; isFullScreenAnimationOn = false; } }