< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java

Print this page

        

@@ -23,14 +23,16 @@
  * questions.
  */
 
 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;
 
 import javax.swing.*;
 

@@ -42,10 +44,11 @@
 import sun.util.logging.PlatformLogger;
 
 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);
     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);

@@ -173,14 +176,28 @@
         }},
         new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
             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());
         }},
         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {

@@ -208,10 +225,12 @@
     // 2) getting notification from the native level via deliverMoveResizeEvent()
     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
     private volatile boolean isFullScreenMode;
     private boolean isFullScreenAnimationOn;
 
+    private volatile boolean isInFullScreen;
+
     private Window target;
     private LWWindowPeer peer;
     protected CPlatformView contentView;
     protected CPlatformWindow owner;
     protected boolean visible = false; // visibility status from native perspective

@@ -306,10 +325,12 @@
         {
             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
             styleBits = SET(styleBits, RESIZABLE, resizable);
             if (!resizable) {
                 styleBits = SET(styleBits, ZOOMABLE, false);
+            } else {
+                setCanFullscreen(true);
             }
         }
 
         if (target.isAlwaysOnTop()) {
             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);

@@ -678,13 +699,29 @@
         updateFocusabilityForAutoRequestFocus(false);
         nativePushNSWindowToFront(nsWindowPtr);
         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
     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
         nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);

@@ -1072,16 +1109,18 @@
     private void windowWillEnterFullScreen() {
         isFullScreenAnimationOn = true;
     }
 
     private void windowDidEnterFullScreen() {
+        isInFullScreen = true;
         isFullScreenAnimationOn = false;
     }
 
     private void windowWillExitFullScreen() {
         isFullScreenAnimationOn = true;
     }
 
     private void windowDidExitFullScreen() {
+        isInFullScreen = false;
         isFullScreenAnimationOn = false;
     }
 }
< prev index next >