1 /*
   2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 import java.awt.*;
  29 import java.awt.Dialog.ModalityType;
  30 import java.awt.event.*;
  31 import java.awt.peer.WindowPeer;
  32 import java.beans.*;
  33 import java.lang.reflect.InvocationTargetException;
  34 import java.util.ArrayList;
  35 import java.util.Arrays;
  36 import java.util.List;
  37 import java.util.Objects;
  38 
  39 import javax.swing.*;
  40 
  41 import sun.awt.*;
  42 import sun.awt.AWTAccessor.ComponentAccessor;
  43 import sun.awt.AWTAccessor.WindowAccessor;
  44 import sun.java2d.SurfaceData;
  45 import sun.java2d.opengl.CGLSurfaceData;
  46 import sun.lwawt.*;
  47 import sun.util.logging.PlatformLogger;
  48 
  49 import com.apple.laf.*;
  50 import com.apple.laf.ClientPropertyApplicator.Property;
  51 import com.sun.awt.AWTUtilities;
  52 
  53 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  54     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
  55     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  56     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  57     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  58     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  59     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  60     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  61     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  62     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  63     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  64     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  65     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  66     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  67     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  68     private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType);
  69     private static native void nativeDispose(long nsWindowPtr);
  70     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
  71     private static native void nativeExitFullScreenMode(long nsWindowPtr);
  72     static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
  73 
  74     // Loger to report issues happened during execution but that do not affect functionality
  75     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  76     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
  77 
  78     // for client properties
  79     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
  80     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
  81 
  82     public static final String WINDOW_ALPHA = "Window.alpha";
  83     public static final String WINDOW_SHADOW = "Window.shadow";
  84 
  85     public static final String WINDOW_STYLE = "Window.style";
  86     public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
  87 
  88     public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
  89     public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
  90 
  91     public static final String WINDOW_CLOSEABLE = "Window.closeable";
  92     public static final String WINDOW_MINIMIZABLE = "Window.minimizable";
  93     public static final String WINDOW_ZOOMABLE = "Window.zoomable";
  94     public static final String WINDOW_HIDES_ON_DEACTIVATE="Window.hidesOnDeactivate";
  95 
  96     public static final String WINDOW_DOC_MODAL_SHEET = "apple.awt.documentModalSheet";
  97     public static final String WINDOW_FADE_DELEGATE = "apple.awt._windowFadeDelegate";
  98     public static final String WINDOW_FADE_IN = "apple.awt._windowFadeIn";
  99     public static final String WINDOW_FADE_OUT = "apple.awt._windowFadeOut";
 100     public static final String WINDOW_FULLSCREENABLE = "apple.awt.fullscreenable";
 101 
 102 
 103     // Yeah, I know. But it's easier to deal with ints from JNI
 104     static final int MODELESS = 0;
 105     static final int DOCUMENT_MODAL = 1;
 106     static final int APPLICATION_MODAL = 2;
 107     static final int TOOLKIT_MODAL = 3;
 108 
 109     // window style bits
 110     static final int _RESERVED_FOR_DATA = 1 << 0;
 111 
 112     // corresponds to native style mask bits
 113     static final int DECORATED = 1 << 1;
 114     static final int TEXTURED = 1 << 2;
 115     static final int UNIFIED = 1 << 3;
 116     static final int UTILITY = 1 << 4;
 117     static final int HUD = 1 << 5;
 118     static final int SHEET = 1 << 6;
 119 
 120     static final int CLOSEABLE = 1 << 7;
 121     static final int MINIMIZABLE = 1 << 8;
 122 
 123     static final int RESIZABLE = 1 << 9; // both a style bit and prop bit
 124     static final int NONACTIVATING = 1 << 24;
 125     static final int IS_DIALOG = 1 << 25;
 126     static final int IS_MODAL = 1 << 26;
 127     static final int IS_POPUP = 1 << 27;
 128 
 129     static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE;
 130 
 131     // corresponds to method-based properties
 132     static final int HAS_SHADOW = 1 << 10;
 133     static final int ZOOMABLE = 1 << 11;
 134 
 135     static final int ALWAYS_ON_TOP = 1 << 15;
 136     static final int HIDES_ON_DEACTIVATE = 1 << 17;
 137     static final int DRAGGABLE_BACKGROUND = 1 << 19;
 138     static final int DOCUMENT_MODIFIED = 1 << 21;
 139     static final int FULLSCREENABLE = 1 << 23;
 140 
 141     static final int _METHOD_PROP_BITMASK = RESIZABLE | HAS_SHADOW | ZOOMABLE | ALWAYS_ON_TOP | HIDES_ON_DEACTIVATE | DRAGGABLE_BACKGROUND | DOCUMENT_MODIFIED | FULLSCREENABLE;
 142 
 143     // corresponds to callback-based properties
 144     static final int SHOULD_BECOME_KEY = 1 << 12;
 145     static final int SHOULD_BECOME_MAIN = 1 << 13;
 146     static final int MODAL_EXCLUDED = 1 << 16;
 147 
 148     static final int _CALLBACK_PROP_BITMASK = SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN | MODAL_EXCLUDED;
 149 
 150     static int SET(final int bits, final int mask, final boolean value) {
 151         if (value) return (bits | mask);
 152         return bits & ~mask;
 153     }
 154 
 155     static boolean IS(final int bits, final int mask) {
 156         return (bits & mask) != 0;
 157     }
 158 
 159     @SuppressWarnings("unchecked")
 160     static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] {
 161         new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) {
 162             c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString()));
 163         }},
 164         new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) {
 165             c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
 166         }},
 167         new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
 168             AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
 169         }},
 170         new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 171             c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
 172         }},
 173         new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 174             c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString()));
 175         }},
 176         new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 177             c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
 178         }},
 179         new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 180             c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
 181         }},
 182         new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 183             c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
 184         }},
 185         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 186             nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
 187         }},
 188         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 189             if (value == null || !(value instanceof java.io.File)) {
 190                 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
 191                 return;
 192             }
 193 
 194             final String filename = ((java.io.File)value).getAbsolutePath();
 195             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
 196         }}
 197     }) {
 198         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 199             Component root = SwingUtilities.getRoot(p);
 200             if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
 201             return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
 202         }
 203     };
 204 
 205     // Bounds of the native widget but in the Java coordinate system.
 206     // In order to keep it up-to-date we will update them on
 207     // 1) setting native bounds via nativeSetBounds() call
 208     // 2) getting notification from the native level via deliverMoveResizeEvent()
 209     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 210     private volatile boolean isFullScreenMode;
 211     private boolean isFullScreenAnimationOn;
 212 
 213     private Window target;
 214     private LWWindowPeer peer;
 215     protected CPlatformView contentView;
 216     protected CPlatformWindow owner;
 217     protected boolean visible = false; // visibility status from native perspective
 218     private boolean undecorated; // initialized in getInitialStyleBits()
 219     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 220     private CPlatformResponder responder;
 221 
 222     public CPlatformWindow() {
 223         super(0, true);
 224     }
 225 
 226     /*
 227      * Delegate initialization (create native window and all the
 228      * related resources).
 229      */
 230     @Override // PlatformWindow
 231     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 232         initializeBase(_target, _peer, _owner, new CPlatformView());
 233 
 234         final int styleBits = getInitialStyleBits();
 235 
 236         responder = createPlatformResponder();
 237         contentView = createContentView();
 238         contentView.initialize(peer, responder);
 239 
 240         final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
 241         Rectangle bounds;
 242         if (!IS(DECORATED, styleBits)) {
 243             // For undecorated frames the move/resize event does not come if the frame is centered on the screen
 244             // so we need to set a stub location to force an initial move/resize. Real bounds would be set later.
 245             bounds = new Rectangle(0, 0, 1, 1);
 246         } else {
 247             bounds = _peer.constrainBounds(_target.getBounds());
 248         }
 249         final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(),
 250                 ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height);
 251         setPtr(nativeWindowPtr);
 252 
 253         if (target instanceof javax.swing.RootPaneContainer) {
 254             final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
 255             if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() {
 256                 public void propertyChange(final PropertyChangeEvent evt) {
 257                     CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane);
 258                     rootpane.removePropertyChangeListener("ancestor", this);
 259                 }
 260             });
 261         }
 262 
 263         validateSurface();
 264     }
 265 
 266     protected void initializeBase(Window target, LWWindowPeer peer, PlatformWindow owner, CPlatformView view) {
 267         this.peer = peer;
 268         this.target = target;
 269         if (owner instanceof CPlatformWindow) {
 270             this.owner = (CPlatformWindow)owner;
 271         }
 272         this.contentView = view;
 273     }
 274 
 275     protected CPlatformResponder createPlatformResponder() {
 276         return new CPlatformResponder(peer, false);
 277     }
 278 
 279     protected CPlatformView createContentView() {
 280         return new CPlatformView();
 281     }
 282 
 283     protected int getInitialStyleBits() {
 284         // defaults style bits
 285         int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
 286 
 287         if (isNativelyFocusableWindow()) {
 288             styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
 289             styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
 290         }
 291 
 292         final boolean isFrame = (target instanceof Frame);
 293         final boolean isDialog = (target instanceof Dialog);
 294         final boolean isPopup = (target.getType() == Window.Type.POPUP);
 295         if (isDialog) {
 296             styleBits = SET(styleBits, MINIMIZABLE, false);
 297         }
 298 
 299         // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
 300         {
 301             this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
 302             if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
 303         }
 304 
 305         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 306         {
 307             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 308             styleBits = SET(styleBits, RESIZABLE, resizable);
 309             if (!resizable) {
 310                 styleBits = SET(styleBits, ZOOMABLE, false);
 311             }
 312         }
 313 
 314         if (target.isAlwaysOnTop()) {
 315             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 316         }
 317 
 318         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 319             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 320         }
 321 
 322         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 323         if (isPopup) {
 324             styleBits = SET(styleBits, TEXTURED, false);
 325             // Popups in applets don't activate applet's process
 326             styleBits = SET(styleBits, NONACTIVATING, true);
 327             styleBits = SET(styleBits, IS_POPUP, true);
 328         }
 329 
 330         if (Window.Type.UTILITY.equals(target.getType())) {
 331             styleBits = SET(styleBits, UTILITY, true);
 332         }
 333 
 334         if (target instanceof javax.swing.RootPaneContainer) {
 335             javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
 336             Object prop = null;
 337 
 338             prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
 339             if (prop != null) {
 340                 styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
 341             }
 342 
 343             if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
 344                 prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
 345                 if (prop != null) {
 346                     styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString()));
 347                 }
 348             }
 349 
 350             prop = rootpane.getClientProperty(WINDOW_STYLE);
 351             if (prop != null) {
 352                 if ("small".equals(prop))  {
 353                     styleBits = SET(styleBits, UTILITY, true);
 354                     if (target.isAlwaysOnTop() && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) {
 355                         styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true);
 356                     }
 357                 }
 358                 if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true);
 359                 if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true);
 360                 if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true);
 361             }
 362 
 363             prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE);
 364             if (prop != null) {
 365                 styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString()));
 366             }
 367 
 368             prop = rootpane.getClientProperty(WINDOW_CLOSEABLE);
 369             if (prop != null) {
 370                 styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString()));
 371             }
 372 
 373             prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE);
 374             if (prop != null) {
 375                 styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString()));
 376             }
 377 
 378             prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
 379             if (prop != null) {
 380                 styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
 381             }
 382 
 383             prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
 384             if (prop != null) {
 385                 styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
 386             }
 387 
 388             prop = rootpane.getClientProperty(WINDOW_SHADOW);
 389             if (prop != null) {
 390                 styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
 391             }
 392 
 393             prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
 394             if (prop != null) {
 395                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
 396             }
 397         }
 398 
 399         if (isDialog) {
 400             styleBits = SET(styleBits, IS_DIALOG, true);
 401             if (((Dialog) target).isModal()) {
 402                 styleBits = SET(styleBits, IS_MODAL, true);
 403             }
 404         }
 405 
 406         peer.setTextured(IS(TEXTURED, styleBits));
 407 
 408         return styleBits;
 409     }
 410 
 411     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
 412     private void setStyleBits(final int mask, final boolean value) {
 413         nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
 414     }
 415 
 416     private native void _toggleFullScreenMode(final long model);
 417 
 418     public void toggleFullScreen() {
 419         _toggleFullScreenMode(getNSWindowPtr());
 420     }
 421 
 422     @Override // PlatformWindow
 423     public void setMenuBar(MenuBar mb) {
 424         final long nsWindowPtr = getNSWindowPtr();
 425         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
 426         if (mbPeer != null) {
 427             nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel());
 428         } else {
 429             nativeSetNSWindowMenuBar(nsWindowPtr, 0);
 430         }
 431     }
 432 
 433     @Override // PlatformWindow
 434     public void dispose() {
 435         contentView.dispose();
 436         nativeDispose(getNSWindowPtr());
 437         CPlatformWindow.super.dispose();
 438     }
 439 
 440     @Override // PlatformWindow
 441     public FontMetrics getFontMetrics(Font f) {
 442         // TODO: not implemented
 443         (new RuntimeException("unimplemented")).printStackTrace();
 444         return null;
 445     }
 446 
 447     @Override // PlatformWindow
 448     public Insets getInsets() {
 449         return nativeGetNSWindowInsets(getNSWindowPtr());
 450     }
 451 
 452     @Override // PlatformWindow
 453     public Point getLocationOnScreen() {
 454         return new Point(nativeBounds.x, nativeBounds.y);
 455     }
 456 
 457     @Override
 458     public GraphicsDevice getGraphicsDevice() {
 459         return contentView.getGraphicsDevice();
 460     }
 461 
 462     @Override // PlatformWindow
 463     public SurfaceData getScreenSurface() {
 464         // TODO: not implemented
 465         return null;
 466     }
 467 
 468     @Override // PlatformWindow
 469     public SurfaceData replaceSurfaceData() {
 470         return contentView.replaceSurfaceData();
 471     }
 472 
 473     @Override // PlatformWindow
 474     public void setBounds(int x, int y, int w, int h) {
 475 //        assert CThreading.assertEventQueue();
 476         nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
 477     }
 478 
 479     private boolean isMaximized() {
 480         return undecorated ? this.normalBounds != null
 481                 : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
 482     }
 483 
 484     private void maximize() {
 485         if (peer == null || isMaximized()) {
 486             return;
 487         }
 488         if (!undecorated) {
 489             CWrapper.NSWindow.zoom(getNSWindowPtr());
 490         } else {
 491             deliverZoom(true);
 492 
 493             // We need an up to date size of the peer, so we flush the native events
 494             // to be sure that there are no setBounds requests in the queue.
 495             LWCToolkit.flushNativeSelectors();
 496             this.normalBounds = peer.getBounds();
 497 
 498             GraphicsConfiguration config = getPeer().getGraphicsConfiguration();
 499             Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets();
 500             Rectangle toBounds = config.getBounds();
 501             setBounds(toBounds.x + i.left,
 502                       toBounds.y + i.top,
 503                       toBounds.width - i.left - i.right,
 504                       toBounds.height - i.top - i.bottom);
 505         }
 506     }
 507 
 508     private void unmaximize() {
 509         if (!isMaximized()) {
 510             return;
 511         }
 512         if (!undecorated) {
 513             CWrapper.NSWindow.zoom(getNSWindowPtr());
 514         } else {
 515             deliverZoom(false);
 516 
 517             Rectangle toBounds = this.normalBounds;
 518             this.normalBounds = null;
 519             setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
 520         }
 521     }
 522 
 523     public boolean isVisible() {
 524         return this.visible;
 525     }
 526 
 527     @Override // PlatformWindow
 528     public void setVisible(boolean visible) {
 529         final long nsWindowPtr = getNSWindowPtr();
 530 
 531         // Configure stuff
 532         updateIconImages();
 533         updateFocusabilityForAutoRequestFocus(false);
 534 
 535         boolean wasMaximized = isMaximized();
 536 
 537         // Actually show or hide the window
 538         LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
 539         if (blocker == null || !visible) {
 540             // If it ain't blocked, or is being hidden, go regular way
 541             if (visible) {
 542                 CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());
 543 
 544                 boolean isPopup = (target.getType() == Window.Type.POPUP);
 545                 if (isPopup) {
 546                     // Popups in applets don't activate applet's process
 547                     CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
 548                 } else {
 549                     CWrapper.NSWindow.orderFront(nsWindowPtr);
 550                 }
 551 
 552                 boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
 553                 if (!isKeyWindow) {
 554                     CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
 555                 }
 556             } else {
 557                 // immediately hide the window
 558                 CWrapper.NSWindow.orderOut(nsWindowPtr);
 559                 // process the close
 560                 CWrapper.NSWindow.close(nsWindowPtr);
 561             }
 562         } else {
 563             // otherwise, put it in a proper z-order
 564             CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
 565                     ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
 566         }
 567         this.visible = visible;
 568 
 569         // Manage the extended state when showing
 570         if (visible) {
 571             // Apply the extended state as expected in shared code
 572             if (target instanceof Frame) {
 573                 if (!wasMaximized && isMaximized()) {
 574                     // setVisible could have changed the native maximized state
 575                     deliverZoom(true);
 576                 } else {
 577                     int frameState = ((Frame)target).getExtendedState();
 578                     if ((frameState & Frame.ICONIFIED) != 0) {
 579                         // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 580                         frameState = Frame.ICONIFIED;
 581                     }
 582                     switch (frameState) {
 583                         case Frame.ICONIFIED:
 584                             CWrapper.NSWindow.miniaturize(nsWindowPtr);
 585                             break;
 586                         case Frame.MAXIMIZED_BOTH:
 587                             maximize();
 588                             break;
 589                         default: // NORMAL
 590                             unmaximize(); // in case it was maximized, otherwise this is a no-op
 591                             break;
 592                     }
 593                 }
 594             }
 595         }
 596 
 597         nativeSynthesizeMouseEnteredExitedEvents();
 598 
 599         // Configure stuff #2
 600         updateFocusabilityForAutoRequestFocus(true);
 601 
 602         // Manage parent-child relationship when showing
 603         if (visible) {
 604             // Order myself above my parent
 605             if (owner != null && owner.isVisible()) {
 606                 CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
 607                 applyWindowLevel(target);
 608             }
 609 
 610             // Order my own children above myself
 611             for (Window w : target.getOwnedWindows()) {
 612                 WindowPeer p = (WindowPeer)w.getPeer();
 613                 if (p instanceof LWWindowPeer) {
 614                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
 615                     if (pw != null && pw.isVisible()) {
 616                         CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr);
 617                         pw.applyWindowLevel(w);
 618                     }
 619                 }
 620             }
 621         }
 622 
 623         // Deal with the blocker of the window being shown
 624         if (blocker != null && visible) {
 625             // Make sure the blocker is above its siblings
 626             ((CPlatformWindow)blocker.getPlatformWindow()).orderAboveSiblings();
 627         }
 628     }
 629 
 630     @Override // PlatformWindow
 631     public void setTitle(String title) {
 632         nativeSetNSWindowTitle(getNSWindowPtr(), title);
 633     }
 634 
 635     // Should be called on every window key property change.
 636     @Override // PlatformWindow
 637     public void updateIconImages() {
 638         final long nsWindowPtr = getNSWindowPtr();
 639         final CImage cImage = getImageForTarget();
 640         nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr);
 641     }
 642 
 643     public long getNSWindowPtr() {
 644         final long nsWindowPtr = ptr;
 645         if (nsWindowPtr == 0L) {
 646             if(logger.isLoggable(PlatformLogger.Level.FINE)) {
 647                 logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
 648             }
 649         }
 650         return nsWindowPtr;
 651     }
 652 
 653     public SurfaceData getSurfaceData() {
 654         return contentView.getSurfaceData();
 655     }
 656 
 657     @Override  // PlatformWindow
 658     public void toBack() {
 659         final long nsWindowPtr = getNSWindowPtr();
 660         nativePushNSWindowToBack(nsWindowPtr);
 661     }
 662 
 663     @Override  // PlatformWindow
 664     public void toFront() {
 665         final long nsWindowPtr = getNSWindowPtr();
 666         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
 667         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
 668         if( w != null && w.getPeer() != null
 669                 && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
 670                 && !lwcToolkit.isApplicationActive()) {
 671             lwcToolkit.activateApplicationIgnoringOtherApps();
 672         }
 673         updateFocusabilityForAutoRequestFocus(false);
 674         nativePushNSWindowToFront(nsWindowPtr);
 675         updateFocusabilityForAutoRequestFocus(true);
 676     }
 677 
 678     @Override
 679     public void setResizable(final boolean resizable) {
 680         setStyleBits(RESIZABLE, resizable);
 681     }
 682 
 683     @Override
 684     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
 685         nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
 686     }
 687 
 688     @Override
 689     public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
 690         // Cross-app activation requests are not allowed.
 691         if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
 692             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
 693         {
 694             focusLogger.fine("the app is inactive, so the request is rejected");
 695             return true;
 696         }
 697         return false;
 698     }
 699 
 700     @Override
 701     public boolean requestWindowFocus() {
 702 
 703         long ptr = getNSWindowPtr();
 704         if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
 705             CWrapper.NSWindow.makeMainWindow(ptr);
 706         }
 707         CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
 708         return true;
 709     }
 710 
 711     @Override
 712     public boolean isActive() {
 713         long ptr = getNSWindowPtr();
 714         return CWrapper.NSWindow.isKeyWindow(ptr);
 715     }
 716 
 717     @Override
 718     public void updateFocusableWindowState() {
 719         final boolean isFocusable = isNativelyFocusableWindow();
 720         setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
 721     }
 722 
 723     @Override
 724     public Graphics transformGraphics(Graphics g) {
 725         // is this where we can inject a transform for HiDPI?
 726         return g;
 727     }
 728 
 729     @Override
 730     public void setAlwaysOnTop(boolean isAlwaysOnTop) {
 731         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
 732     }
 733 
 734     @Override
 735     public void setOpacity(float opacity) {
 736         CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
 737     }
 738 
 739     @Override
 740     public void setOpaque(boolean isOpaque) {
 741         CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
 742         boolean isTextured = (peer == null) ? false : peer.isTextured();
 743         if (!isTextured) {
 744             if (!isOpaque) {
 745                 CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0);
 746             } else if (peer != null) {
 747                 Color color = peer.getBackground();
 748                 if (color != null) {
 749                     int rgb = color.getRGB();
 750                     CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb);
 751                 }
 752             }
 753         }
 754 
 755         //This is a temporary workaround. Looks like after 7124236 will be fixed
 756         //the correct place for invalidateShadow() is CGLayer.drawInCGLContext.
 757         SwingUtilities.invokeLater(this::invalidateShadow);
 758     }
 759 
 760     @Override
 761     public void enterFullScreenMode() {
 762         isFullScreenMode = true;
 763         nativeEnterFullScreenMode(getNSWindowPtr());
 764     }
 765 
 766     @Override
 767     public void exitFullScreenMode() {
 768         nativeExitFullScreenMode(getNSWindowPtr());
 769         isFullScreenMode = false;
 770     }
 771 
 772     @Override
 773     public boolean isFullScreenMode() {
 774         return isFullScreenMode;
 775     }
 776 
 777     @Override
 778     public void setWindowState(int windowState) {
 779         if (peer == null || !peer.isVisible()) {
 780             // setVisible() applies the state
 781             return;
 782         }
 783 
 784         int prevWindowState = peer.getState();
 785         if (prevWindowState == windowState) return;
 786 
 787         final long nsWindowPtr = getNSWindowPtr();
 788         if ((windowState & Frame.ICONIFIED) != 0) {
 789             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 790             windowState = Frame.ICONIFIED;
 791         }
 792         switch (windowState) {
 793             case Frame.ICONIFIED:
 794                 if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 795                     // let's return into the normal states first
 796                     // the zoom call toggles between the normal and the max states
 797                     unmaximize();
 798                 }
 799                 CWrapper.NSWindow.miniaturize(nsWindowPtr);
 800                 break;
 801             case Frame.MAXIMIZED_BOTH:
 802                 if (prevWindowState == Frame.ICONIFIED) {
 803                     // let's return into the normal states first
 804                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 805                 }
 806                 maximize();
 807                 break;
 808             case Frame.NORMAL:
 809                 if (prevWindowState == Frame.ICONIFIED) {
 810                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 811                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 812                     // the zoom call toggles between the normal and the max states
 813                     unmaximize();
 814                 }
 815                 break;
 816             default:
 817                 throw new RuntimeException("Unknown window state: " + windowState);
 818         }
 819 
 820         // NOTE: the SWP.windowState field gets updated to the newWindowState
 821         //       value when the native notification comes to us
 822     }
 823 
 824     @Override
 825     public void setModalBlocked(boolean blocked) {
 826         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 827             return;
 828         }
 829 
 830         if (blocked) {
 831             // We are going to show a modal window. Previously displayed window will be
 832             // blocked/disabled. So we have to send mouse exited event to it now, since
 833             // all mouse events are discarded for blocked/disabled windows.
 834             nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited);
 835         }
 836 
 837         nativeSetEnabled(getNSWindowPtr(), !blocked);
 838         checkBlockingAndOrder();
 839     }
 840 
 841     public final void invalidateShadow(){
 842         nativeRevalidateNSWindowShadow(getNSWindowPtr());
 843     }
 844 
 845     // ----------------------------------------------------------------------
 846     //                          UTILITY METHODS
 847     // ----------------------------------------------------------------------
 848 
 849     /**
 850      * Find image to install into Title or into Application icon. First try
 851      * icons installed for toplevel. Null is returned, if there is no icon and
 852      * default Duke image should be used.
 853      */
 854     private CImage getImageForTarget() {
 855         CImage icon = null;
 856         try {
 857             icon = CImage.getCreator().createFromImages(target.getIconImages());
 858         } catch (Exception ignored) {
 859             // Perhaps the icon passed into Java is broken. Skipping this icon.
 860         }
 861         return icon;
 862     }
 863 
 864     /*
 865      * Returns LWWindowPeer associated with this delegate.
 866      */
 867     @Override
 868     public LWWindowPeer getPeer() {
 869         return peer;
 870     }
 871 
 872     @Override
 873     public boolean isUnderMouse() {
 874         return contentView.isUnderMouse();
 875     }
 876 
 877     public CPlatformView getContentView() {
 878         return contentView;
 879     }
 880 
 881     @Override
 882     public long getLayerPtr() {
 883         return contentView.getWindowLayerPtr();
 884     }
 885 
 886     private void validateSurface() {
 887         SurfaceData surfaceData = getSurfaceData();
 888         if (surfaceData instanceof CGLSurfaceData) {
 889             ((CGLSurfaceData)surfaceData).validate();
 890         }
 891     }
 892 
 893     void flushBuffers() {
 894         if (isVisible() && !nativeBounds.isEmpty() && !isFullScreenMode) {
 895             try {
 896                 LWCToolkit.invokeAndWait(new Runnable() {
 897                     @Override
 898                     public void run() {
 899                         //Posting an empty to flush the EventQueue without blocking the main thread
 900                     }
 901                 }, target);
 902             } catch (InvocationTargetException e) {
 903                 e.printStackTrace();
 904             }
 905         }
 906     }
 907 
 908     /**
 909      * Helper method to get a pointer to the native view from the PlatformWindow.
 910      */
 911     static long getNativeViewPtr(PlatformWindow platformWindow) {
 912         long nativePeer = 0L;
 913         if (platformWindow instanceof CPlatformWindow) {
 914             nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
 915         } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
 916             nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
 917         }
 918         return nativePeer;
 919     }
 920 
 921     /*************************************************************
 922      * Callbacks from the AWTWindow and AWTView objc classes.
 923      *************************************************************/
 924     private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
 925         // Fix for 7150349: ingore "gained" notifications when the app is inactive.
 926         if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
 927             focusLogger.fine("the app is inactive, so the notification is ignored");
 928             return;
 929         }
 930 
 931         LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
 932         responder.handleWindowFocusEvent(gained, oppositePeer);
 933     }
 934 
 935     protected void deliverMoveResizeEvent(int x, int y, int width, int height,
 936                                         boolean byUser) {
 937         checkZoom();
 938 
 939         final Rectangle oldB = nativeBounds;
 940         nativeBounds = new Rectangle(x, y, width, height);
 941         if (peer != null) {
 942             peer.notifyReshape(x, y, width, height);
 943             // System-dependent appearance optimization.
 944             if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
 945                     || isFullScreenAnimationOn) {
 946                 flushBuffers();
 947             }
 948         }
 949     }
 950 
 951     private void deliverWindowClosingEvent() {
 952         if (peer != null && peer.getBlocker() == null) {
 953             peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
 954         }
 955     }
 956 
 957     private void deliverIconify(final boolean iconify) {
 958         if (peer != null) {
 959             peer.notifyIconify(iconify);
 960         }
 961     }
 962 
 963     private void deliverZoom(final boolean isZoomed) {
 964         if (peer != null) {
 965             peer.notifyZoom(isZoomed);
 966         }
 967     }
 968 
 969     private void checkZoom() {
 970         if (target instanceof Frame && isVisible()) {
 971             Frame targetFrame = (Frame)target;
 972             if (targetFrame.getExtendedState() != Frame.MAXIMIZED_BOTH && isMaximized()) {
 973                 deliverZoom(true);
 974             } else if (targetFrame.getExtendedState() == Frame.MAXIMIZED_BOTH && !isMaximized()) {
 975                 deliverZoom(false);
 976             }
 977         }
 978     }
 979 
 980     private void deliverNCMouseDown() {
 981         if (peer != null) {
 982             peer.notifyNCMouseDown();
 983         }
 984     }
 985 
 986     /*
 987      * Our focus model is synthetic and only non-simple window
 988      * may become natively focusable window.
 989      */
 990     private boolean isNativelyFocusableWindow() {
 991         if (peer == null) {
 992             return false;
 993         }
 994 
 995         return !peer.isSimpleWindow() && target.getFocusableWindowState();
 996     }
 997 
 998     /*
 999      * An utility method for the support of the auto request focus.
1000      * Updates the focusable state of the window under certain
1001      * circumstances.
1002      */
1003     private void updateFocusabilityForAutoRequestFocus(boolean isFocusable) {
1004         if (target.isAutoRequestFocus() || !isNativelyFocusableWindow()) return;
1005         setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
1006     }
1007 
1008     private boolean checkBlockingAndOrder() {
1009         LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
1010         if (blocker == null) {
1011             return false;
1012         }
1013 
1014         if (blocker instanceof CPrinterDialogPeer) {
1015             return true;
1016         }
1017 
1018         CPlatformWindow pWindow = (CPlatformWindow)blocker.getPlatformWindow();
1019 
1020         pWindow.orderAboveSiblings();
1021 
1022         final long nsWindowPtr = pWindow.getNSWindowPtr();
1023         CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
1024         CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
1025         CWrapper.NSWindow.makeMainWindow(nsWindowPtr);
1026 
1027         return true;
1028     }
1029 
1030     private boolean isOneOfOwnersOrSelf(CPlatformWindow window) {
1031         while (window != null) {
1032             if (this == window) {
1033                 return true;
1034             }
1035             window = window.owner;
1036         }
1037         return false;
1038     }
1039 
1040     private CPlatformWindow getRootOwner() {
1041         CPlatformWindow rootOwner = this;
1042         while (rootOwner.owner != null) {
1043             rootOwner = rootOwner.owner;
1044         }
1045         return rootOwner;
1046     }
1047 
1048     private void orderAboveSiblings() {
1049         // Recursively pop up the windows from the very bottom, (i.e. root owner) so that
1050         // the windows are ordered above their nearest owner; ancestors of the window,
1051         // which is going to become 'main window', are placed above their siblings.
1052         CPlatformWindow rootOwner = getRootOwner();
1053         if (rootOwner.isVisible()) {
1054             CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr());
1055         }
1056         final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
1057         orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
1058     }
1059 
1060     private void orderAboveSiblingsImpl(Window[] windows) {
1061         ArrayList<Window> childWindows = new ArrayList<Window>();
1062 
1063         final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
1064         final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
1065 
1066         // Go through the list of windows and perform ordering.
1067         for (Window w : windows) {
1068             final Object p = componentAccessor.getPeer(w);
1069             if (p instanceof LWWindowPeer) {
1070                 CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
1071                 if (pw != null && pw.isVisible()) {
1072                     // If the window is one of ancestors of 'main window' or is going to become main by itself,
1073                     // the window should be ordered above its siblings; otherwise the window is just ordered
1074                     // above its nearest parent.
1075                     if (pw.isOneOfOwnersOrSelf(this)) {
1076                         CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
1077                     } else {
1078                         CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
1079                                 pw.owner.getNSWindowPtr());
1080                     }
1081                     pw.applyWindowLevel(w);
1082                 }
1083             }
1084             // Retrieve the child windows for each window from the list and store them for future use.
1085             // Note: we collect data about child windows even for invisible owners, since they may have
1086             // visible children.
1087             childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
1088         }
1089         // If some windows, which have just been ordered, have any child windows, let's start new iteration
1090         // and order these child windows.
1091         if (!childWindows.isEmpty()) {
1092             orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
1093         }
1094     }
1095 
1096     protected void applyWindowLevel(Window target) {
1097         if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
1098             CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
1099         } else if (target.getType() == Window.Type.POPUP) {
1100             CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
1101         }
1102     }
1103 
1104     // ----------------------------------------------------------------------
1105     //                          NATIVE CALLBACKS
1106     // ----------------------------------------------------------------------
1107 
1108     private void windowDidBecomeMain() {
1109         assert CThreading.assertAppKit();
1110 
1111         if (checkBlockingAndOrder()) return;
1112         // If it's not blocked, make sure it's above its siblings
1113         orderAboveSiblings();
1114     }
1115 
1116     private void windowWillEnterFullScreen() {
1117         isFullScreenAnimationOn = true;
1118     }
1119 
1120     private void windowDidEnterFullScreen() {
1121         isFullScreenAnimationOn = false;
1122     }
1123 
1124     private void windowWillExitFullScreen() {
1125         isFullScreenAnimationOn = true;
1126     }
1127 
1128     private void windowDidExitFullScreen() {
1129         isFullScreenAnimationOn = false;
1130     }
1131 }