< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2017, 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


 259     // In order to keep it up-to-date we will update them on
 260     // 1) setting native bounds via nativeSetBounds() call
 261     // 2) getting notification from the native level via deliverMoveResizeEvent()
 262     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 263     private volatile boolean isFullScreenMode;
 264     private boolean isFullScreenAnimationOn;
 265 
 266     private volatile boolean isInFullScreen;
 267     private volatile boolean isIconifyAnimationActive;
 268     private volatile boolean isZoomed;
 269 
 270     private Window target;
 271     private LWWindowPeer peer;
 272     protected CPlatformView contentView;
 273     protected CPlatformWindow owner;
 274     protected boolean visible = false; // visibility status from native perspective
 275     private boolean undecorated; // initialized in getInitialStyleBits()
 276     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 277     private CPlatformResponder responder;
 278     private long lastBecomeMainTime; // this is necessary to preserve right siblings order


 279 
 280     public CPlatformWindow() {
 281         super(0, true);
 282     }
 283 
 284     /*
 285      * Delegate initialization (create native window and all the
 286      * related resources).
 287      */
 288     @Override // PlatformWindow
 289     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 290         initializeBase(_target, _peer, _owner, new CPlatformView());
 291 
 292         final int styleBits = getInitialStyleBits();
 293 
 294         responder = createPlatformResponder();
 295         contentView = createContentView();
 296         contentView.initialize(peer, responder);
 297 
 298         Rectangle bounds;


 361         if (isNativelyFocusableWindow()) {
 362             styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
 363             styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
 364         }
 365 
 366         final boolean isFrame = (target instanceof Frame);
 367         final boolean isDialog = (target instanceof Dialog);
 368         final boolean isPopup = (target.getType() == Window.Type.POPUP);
 369         if (isDialog) {
 370             styleBits = SET(styleBits, MINIMIZABLE, false);
 371         }
 372 
 373         // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
 374         {
 375             this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
 376             if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
 377         }
 378 
 379         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 380         {
 381             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 382             styleBits = SET(styleBits, RESIZABLE, resizable);
 383             if (!resizable) {
 384                 styleBits = SET(styleBits, ZOOMABLE, false);
 385             }
 386         }
 387 
 388         if (target.isAlwaysOnTop()) {
 389             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 390         }
 391 
 392         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 393             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 394         }
 395 
 396         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 397         if (isPopup) {
 398             styleBits = SET(styleBits, TEXTURED, false);
 399             // Popups in applets don't activate applet's process
 400             styleBits = SET(styleBits, NONACTIVATING, true);
 401             styleBits = SET(styleBits, IS_POPUP, true);


 563                 : isZoomed;
 564     }
 565 
 566     private void maximize() {
 567         if (peer == null || isMaximized()) {
 568             return;
 569         }
 570         if (!undecorated) {
 571             execute(CWrapper.NSWindow::zoom);
 572         } else {
 573             deliverZoom(true);
 574 
 575             // We need an up to date size of the peer, so we flush the native events
 576             // to be sure that there are no setBounds requests in the queue.
 577             LWCToolkit.flushNativeSelectors();
 578             this.normalBounds = peer.getBounds();
 579             Rectangle maximizedBounds = peer.getMaximizedBounds();
 580             setBounds(maximizedBounds.x, maximizedBounds.y,
 581                     maximizedBounds.width, maximizedBounds.height);
 582         }


 583     }
 584 
 585     private void unmaximize() {
 586         if (!isMaximized()) {
 587             return;
 588         }
 589         if (!undecorated) {
 590             execute(CWrapper.NSWindow::zoom);
 591         } else {
 592             deliverZoom(false);
 593 
 594             Rectangle toBounds = this.normalBounds;
 595             this.normalBounds = null;
 596             setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
 597         }
 598     }
 599 
 600     public boolean isVisible() {
 601         return this.visible;
 602     }


 659                     CWrapper.NSWindow.close(ptr);
 660                 });
 661             }
 662         } else {
 663             // otherwise, put it in a proper z-order
 664             CPlatformWindow bw
 665                     = (CPlatformWindow) blocker.getPlatformWindow();
 666             bw.execute(blockerPtr -> {
 667                 execute(ptr -> {
 668                     CWrapper.NSWindow.orderWindow(ptr,
 669                                                   CWrapper.NSWindow.NSWindowBelow,
 670                                                   blockerPtr);
 671                 });
 672             });
 673         }
 674         this.visible = visible;
 675 
 676         // Manage the extended state when showing
 677         if (visible) {
 678             /* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
 679             Frame or Dialog is resizable.
 680             **/
 681             final boolean resizable = (target instanceof Frame) ? ((Frame)target).isResizable() :
 682             ((target instanceof Dialog) ? ((Dialog)target).isResizable() : false);
 683             if (resizable) {
 684                 setCanFullscreen(true);
 685             }
 686 
 687             // Apply the extended state as expected in shared code
 688             if (target instanceof Frame) {
 689                 if (!wasMaximized && isMaximized()) {
 690                     // setVisible could have changed the native maximized state
 691                     deliverZoom(true);
 692                 } else {
 693                     int frameState = ((Frame)target).getExtendedState();
 694                     if ((frameState & Frame.ICONIFIED) != 0) {
 695                         // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 696                         frameState = Frame.ICONIFIED;
 697                     }






 698                     switch (frameState) {
 699                         case Frame.ICONIFIED:
 700                             execute(CWrapper.NSWindow::miniaturize);
 701                             break;
 702                         case Frame.MAXIMIZED_BOTH:
 703                             maximize();
 704                             break;
 705                         default: // NORMAL
 706                             unmaximize(); // in case it was maximized, otherwise this is a no-op
 707                             break;
 708                     }
 709                 }
 710             }
 711         }
 712 
 713         nativeSynthesizeMouseEnteredExitedEvents();
 714 
 715         // Configure stuff #2
 716         updateFocusabilityForAutoRequestFocus(true);
 717 


 797         execute(CPlatformWindow::nativePushNSWindowToFront);
 798         updateFocusabilityForAutoRequestFocus(true);
 799     }
 800 
 801     private void setCanFullscreen(final boolean canFullScreen) {
 802         if (target instanceof RootPaneContainer
 803                 && getPeer().getPeerType() == PeerType.FRAME) {
 804 
 805             if (isInFullScreen && !canFullScreen) {
 806                 toggleFullScreen();
 807             }
 808 
 809             final RootPaneContainer rpc = (RootPaneContainer) target;
 810             rpc.getRootPane().putClientProperty(
 811                     CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen);
 812         }
 813     }
 814 
 815     @Override
 816     public void setResizable(final boolean resizable) {
 817         setCanFullscreen(resizable);
 818         setStyleBits(RESIZABLE, resizable);
 819         setStyleBits(ZOOMABLE, resizable);

 820     }
 821 
 822     @Override
 823     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
 824         execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
 825     }
 826 
 827     @Override
 828     public boolean rejectFocusRequest(FocusEvent.Cause cause) {
 829         // Cross-app activation requests are not allowed.
 830         if (cause != FocusEvent.Cause.MOUSE_EVENT &&
 831             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
 832         {
 833             focusLogger.fine("the app is inactive, so the request is rejected");
 834             return true;
 835         }
 836         return false;
 837     }
 838 
 839     @Override


 907 
 908     @Override
 909     public boolean isFullScreenMode() {
 910         return isFullScreenMode;
 911     }
 912 
 913     @Override
 914     public void setWindowState(int windowState) {
 915         if (peer == null || !peer.isVisible()) {
 916             // setVisible() applies the state
 917             return;
 918         }
 919 
 920         int prevWindowState = peer.getState();
 921         if (prevWindowState == windowState) return;
 922 
 923         if ((windowState & Frame.ICONIFIED) != 0) {
 924             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 925             windowState = Frame.ICONIFIED;
 926         }






 927         switch (windowState) {
 928             case Frame.ICONIFIED:
 929                 if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 930                     // let's return into the normal states first
 931                     // the zoom call toggles between the normal and the max states
 932                     unmaximize();
 933                 }
 934                 execute(CWrapper.NSWindow::miniaturize);
 935                 break;
 936             case Frame.MAXIMIZED_BOTH:
 937                 if (prevWindowState == Frame.ICONIFIED) {
 938                     // let's return into the normal states first
 939                     execute(CWrapper.NSWindow::deminiaturize);
 940                 }
 941                 maximize();
 942                 break;
 943             case Frame.NORMAL:
 944                 if (prevWindowState == Frame.ICONIFIED) {
 945                     execute(CWrapper.NSWindow::deminiaturize);
 946                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {


1110     }
1111 
1112     private void checkZoom() {
1113         if (peer != null) {
1114             int state = peer.getState();
1115             if (state != Frame.MAXIMIZED_BOTH && isMaximized()) {
1116                 deliverZoom(true);
1117             } else if (state == Frame.MAXIMIZED_BOTH && !isMaximized()) {
1118                 deliverZoom(false);
1119             }
1120         }
1121     }
1122 
1123     private void deliverNCMouseDown() {
1124         if (peer != null) {
1125             peer.notifyNCMouseDown();
1126         }
1127     }
1128 
1129     /*















1130      * Our focus model is synthetic and only non-simple window
1131      * may become natively focusable window.
1132      */
1133     private boolean isNativelyFocusableWindow() {
1134         if (peer == null) {
1135             return false;
1136         }
1137 
1138         return !peer.isSimpleWindow() && target.getFocusableWindowState();
1139     }
1140 
1141     private boolean isBlocked() {
1142         LWWindowPeer blocker = (peer != null) ? peer.getBlocker() : null;
1143         return (blocker != null);
1144     }
1145 
1146     /*
1147      * An utility method for the support of the auto request focus.
1148      * Updates the focusable state of the window under certain
1149      * circumstances.


1284         } else if (target.getType() == Window.Type.POPUP) {
1285             execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel));
1286         }
1287     }
1288 
1289     private Window getOwnerFrameOrDialog(Window window) {
1290         Window owner = window.getOwner();
1291         while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
1292             owner = owner.getOwner();
1293         }
1294         return owner;
1295     }
1296 
1297     private boolean isSimpleWindowOwnedByEmbeddedFrame() {
1298         if (peer != null && peer.isSimpleWindow()) {
1299             return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
1300         }
1301         return false;
1302     }
1303 


























1304     // ----------------------------------------------------------------------
1305     //                          NATIVE CALLBACKS
1306     // ----------------------------------------------------------------------
1307 
1308     private void windowWillMiniaturize() {
1309         isIconifyAnimationActive = true;
1310     }
1311 
1312     private void windowDidBecomeMain() {
1313         lastBecomeMainTime = System.currentTimeMillis();
1314         if (checkBlockingAndOrder()) return;
1315         // If it's not blocked, make sure it's above its siblings
1316         orderAboveSiblings();
1317     }
1318 
1319     private void windowWillEnterFullScreen() {
1320         isFullScreenAnimationOn = true;
1321     }
1322 
1323     private void windowDidEnterFullScreen() {
   1 /*
   2  * Copyright (c) 2011, 2018, 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


 259     // In order to keep it up-to-date we will update them on
 260     // 1) setting native bounds via nativeSetBounds() call
 261     // 2) getting notification from the native level via deliverMoveResizeEvent()
 262     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 263     private volatile boolean isFullScreenMode;
 264     private boolean isFullScreenAnimationOn;
 265 
 266     private volatile boolean isInFullScreen;
 267     private volatile boolean isIconifyAnimationActive;
 268     private volatile boolean isZoomed;
 269 
 270     private Window target;
 271     private LWWindowPeer peer;
 272     protected CPlatformView contentView;
 273     protected CPlatformWindow owner;
 274     protected boolean visible = false; // visibility status from native perspective
 275     private boolean undecorated; // initialized in getInitialStyleBits()
 276     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 277     private CPlatformResponder responder;
 278     private long lastBecomeMainTime; // this is necessary to preserve right siblings order
 279     private boolean maximizedBothState = false;
 280     private boolean frameResizibilityChanged = false;
 281 
 282     public CPlatformWindow() {
 283         super(0, true);
 284     }
 285 
 286     /*
 287      * Delegate initialization (create native window and all the
 288      * related resources).
 289      */
 290     @Override // PlatformWindow
 291     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 292         initializeBase(_target, _peer, _owner, new CPlatformView());
 293 
 294         final int styleBits = getInitialStyleBits();
 295 
 296         responder = createPlatformResponder();
 297         contentView = createContentView();
 298         contentView.initialize(peer, responder);
 299 
 300         Rectangle bounds;


 363         if (isNativelyFocusableWindow()) {
 364             styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
 365             styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
 366         }
 367 
 368         final boolean isFrame = (target instanceof Frame);
 369         final boolean isDialog = (target instanceof Dialog);
 370         final boolean isPopup = (target.getType() == Window.Type.POPUP);
 371         if (isDialog) {
 372             styleBits = SET(styleBits, MINIMIZABLE, false);
 373         }
 374 
 375         // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
 376         {
 377             this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
 378             if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
 379         }
 380 
 381         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 382         {
 383             final boolean resizable = isTargetResizable();
 384             styleBits = SET(styleBits, RESIZABLE, resizable);
 385             if (!resizable) {
 386                 styleBits = SET(styleBits, ZOOMABLE, false);
 387             }
 388         }
 389 
 390         if (target.isAlwaysOnTop()) {
 391             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 392         }
 393 
 394         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 395             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 396         }
 397 
 398         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 399         if (isPopup) {
 400             styleBits = SET(styleBits, TEXTURED, false);
 401             // Popups in applets don't activate applet's process
 402             styleBits = SET(styleBits, NONACTIVATING, true);
 403             styleBits = SET(styleBits, IS_POPUP, true);


 565                 : isZoomed;
 566     }
 567 
 568     private void maximize() {
 569         if (peer == null || isMaximized()) {
 570             return;
 571         }
 572         if (!undecorated) {
 573             execute(CWrapper.NSWindow::zoom);
 574         } else {
 575             deliverZoom(true);
 576 
 577             // We need an up to date size of the peer, so we flush the native events
 578             // to be sure that there are no setBounds requests in the queue.
 579             LWCToolkit.flushNativeSelectors();
 580             this.normalBounds = peer.getBounds();
 581             Rectangle maximizedBounds = peer.getMaximizedBounds();
 582             setBounds(maximizedBounds.x, maximizedBounds.y,
 583                     maximizedBounds.width, maximizedBounds.height);
 584         }
 585         setFrameResizibilityChanged(true);
 586         updateResizableAndMaximizeState(true);
 587     }
 588 
 589     private void unmaximize() {
 590         if (!isMaximized()) {
 591             return;
 592         }
 593         if (!undecorated) {
 594             execute(CWrapper.NSWindow::zoom);
 595         } else {
 596             deliverZoom(false);
 597 
 598             Rectangle toBounds = this.normalBounds;
 599             this.normalBounds = null;
 600             setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
 601         }
 602     }
 603 
 604     public boolean isVisible() {
 605         return this.visible;
 606     }


 663                     CWrapper.NSWindow.close(ptr);
 664                 });
 665             }
 666         } else {
 667             // otherwise, put it in a proper z-order
 668             CPlatformWindow bw
 669                     = (CPlatformWindow) blocker.getPlatformWindow();
 670             bw.execute(blockerPtr -> {
 671                 execute(ptr -> {
 672                     CWrapper.NSWindow.orderWindow(ptr,
 673                                                   CWrapper.NSWindow.NSWindowBelow,
 674                                                   blockerPtr);
 675                 });
 676             });
 677         }
 678         this.visible = visible;
 679 
 680         // Manage the extended state when showing
 681         if (visible) {
 682             /* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
 683             Frame resizable and Frame state is not MAXIMIZED_BOTH or Dialog is resizable.
 684             **/
 685             if (isTargetResizable()) {


 686                 setCanFullscreen(true);
 687             }
 688 
 689             // Apply the extended state as expected in shared code
 690             if (target instanceof Frame) {
 691                 if (!wasMaximized && isMaximized()) {
 692                     // setVisible could have changed the native maximized state
 693                     deliverZoom(true);
 694                 } else {
 695                     int frameState = ((Frame)target).getExtendedState();
 696                     if ((frameState & Frame.ICONIFIED) != 0) {
 697                         // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 698                         frameState = Frame.ICONIFIED;
 699                     }
 700 
 701                     if (isFrameResizibilityChanged()) {
 702                         updateResizableAndMaximizeState(false);
 703                         setFrameResizibilityChanged(false);
 704                     }
 705 
 706                     switch (frameState) {
 707                         case Frame.ICONIFIED:
 708                             execute(CWrapper.NSWindow::miniaturize);
 709                             break;
 710                         case Frame.MAXIMIZED_BOTH:
 711                             maximize();
 712                             break;
 713                         default: // NORMAL
 714                             unmaximize(); // in case it was maximized, otherwise this is a no-op
 715                             break;
 716                     }
 717                 }
 718             }
 719         }
 720 
 721         nativeSynthesizeMouseEnteredExitedEvents();
 722 
 723         // Configure stuff #2
 724         updateFocusabilityForAutoRequestFocus(true);
 725 


 805         execute(CPlatformWindow::nativePushNSWindowToFront);
 806         updateFocusabilityForAutoRequestFocus(true);
 807     }
 808 
 809     private void setCanFullscreen(final boolean canFullScreen) {
 810         if (target instanceof RootPaneContainer
 811                 && getPeer().getPeerType() == PeerType.FRAME) {
 812 
 813             if (isInFullScreen && !canFullScreen) {
 814                 toggleFullScreen();
 815             }
 816 
 817             final RootPaneContainer rpc = (RootPaneContainer) target;
 818             rpc.getRootPane().putClientProperty(
 819                     CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen);
 820         }
 821     }
 822 
 823     @Override
 824     public void setResizable(final boolean resizable) {
 825         boolean windowResizable = resizable && !isMaximizedBoth();
 826         setCanFullscreen(windowResizable);
 827         setStyleBits(RESIZABLE, windowResizable);
 828         setStyleBits(ZOOMABLE, windowResizable);
 829     }
 830 
 831     @Override
 832     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
 833         execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
 834     }
 835 
 836     @Override
 837     public boolean rejectFocusRequest(FocusEvent.Cause cause) {
 838         // Cross-app activation requests are not allowed.
 839         if (cause != FocusEvent.Cause.MOUSE_EVENT &&
 840             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
 841         {
 842             focusLogger.fine("the app is inactive, so the request is rejected");
 843             return true;
 844         }
 845         return false;
 846     }
 847 
 848     @Override


 916 
 917     @Override
 918     public boolean isFullScreenMode() {
 919         return isFullScreenMode;
 920     }
 921 
 922     @Override
 923     public void setWindowState(int windowState) {
 924         if (peer == null || !peer.isVisible()) {
 925             // setVisible() applies the state
 926             return;
 927         }
 928 
 929         int prevWindowState = peer.getState();
 930         if (prevWindowState == windowState) return;
 931 
 932         if ((windowState & Frame.ICONIFIED) != 0) {
 933             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
 934             windowState = Frame.ICONIFIED;
 935         }
 936 
 937         if (isFrameResizibilityChanged()) {
 938             updateResizableAndMaximizeState(false);
 939             setFrameResizibilityChanged(false);
 940         }
 941 
 942         switch (windowState) {
 943             case Frame.ICONIFIED:
 944                 if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 945                     // let's return into the normal states first
 946                     // the zoom call toggles between the normal and the max states
 947                     unmaximize();
 948                 }
 949                 execute(CWrapper.NSWindow::miniaturize);
 950                 break;
 951             case Frame.MAXIMIZED_BOTH:
 952                 if (prevWindowState == Frame.ICONIFIED) {
 953                     // let's return into the normal states first
 954                     execute(CWrapper.NSWindow::deminiaturize);
 955                 }
 956                 maximize();
 957                 break;
 958             case Frame.NORMAL:
 959                 if (prevWindowState == Frame.ICONIFIED) {
 960                     execute(CWrapper.NSWindow::deminiaturize);
 961                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {


1125     }
1126 
1127     private void checkZoom() {
1128         if (peer != null) {
1129             int state = peer.getState();
1130             if (state != Frame.MAXIMIZED_BOTH && isMaximized()) {
1131                 deliverZoom(true);
1132             } else if (state == Frame.MAXIMIZED_BOTH && !isMaximized()) {
1133                 deliverZoom(false);
1134             }
1135         }
1136     }
1137 
1138     private void deliverNCMouseDown() {
1139         if (peer != null) {
1140             peer.notifyNCMouseDown();
1141         }
1142     }
1143 
1144     /*
1145      * Resizibility of frame with state MAXIMIZED_BOTH is set to true to zoom
1146      * the frame on double click on title bar and set to false later. This is
1147      * required as frame won't zoom if resizibility of frame is false.
1148      */
1149     private void deliverDoubleClickOnTitlebar() {
1150         if ((peer != null) && (target instanceof Frame)) {
1151             if (isMaximizedBoth()) {
1152                 updateResizableAndMaximizeState(false);
1153                 execute(CWrapper.NSWindow::zoom);
1154                 updateResizableAndMaximizeState(true);
1155             }
1156         }
1157     }
1158 
1159     /*
1160      * Our focus model is synthetic and only non-simple window
1161      * may become natively focusable window.
1162      */
1163     private boolean isNativelyFocusableWindow() {
1164         if (peer == null) {
1165             return false;
1166         }
1167 
1168         return !peer.isSimpleWindow() && target.getFocusableWindowState();
1169     }
1170 
1171     private boolean isBlocked() {
1172         LWWindowPeer blocker = (peer != null) ? peer.getBlocker() : null;
1173         return (blocker != null);
1174     }
1175 
1176     /*
1177      * An utility method for the support of the auto request focus.
1178      * Updates the focusable state of the window under certain
1179      * circumstances.


1314         } else if (target.getType() == Window.Type.POPUP) {
1315             execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel));
1316         }
1317     }
1318 
1319     private Window getOwnerFrameOrDialog(Window window) {
1320         Window owner = window.getOwner();
1321         while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
1322             owner = owner.getOwner();
1323         }
1324         return owner;
1325     }
1326 
1327     private boolean isSimpleWindowOwnedByEmbeddedFrame() {
1328         if (peer != null && peer.isSimpleWindow()) {
1329             return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
1330         }
1331         return false;
1332     }
1333 
1334     private boolean isTargetResizable() {
1335         if (target instanceof Frame) {
1336             return ((Frame)target).isResizable() && !isMaximizedBoth();
1337         } else if (target instanceof Dialog) {
1338             return ((Dialog)target).isResizable();
1339         }
1340         return false;
1341     }
1342 
1343     private void updateResizableAndMaximizeState(boolean maximizeState) {
1344         maximizedBothState = maximizeState;
1345         setResizable(!maximizeState);
1346     }
1347 
1348     private boolean isMaximizedBoth() {
1349         return maximizedBothState;
1350     }
1351 
1352     private void setFrameResizibilityChanged(boolean resize) {
1353         frameResizibilityChanged = resize;
1354     }
1355 
1356     private boolean isFrameResizibilityChanged() {
1357         return frameResizibilityChanged;
1358     }
1359 
1360     // ----------------------------------------------------------------------
1361     //                          NATIVE CALLBACKS
1362     // ----------------------------------------------------------------------
1363 
1364     private void windowWillMiniaturize() {
1365         isIconifyAnimationActive = true;
1366     }
1367 
1368     private void windowDidBecomeMain() {
1369         lastBecomeMainTime = System.currentTimeMillis();
1370         if (checkBlockingAndOrder()) return;
1371         // If it's not blocked, make sure it's above its siblings
1372         orderAboveSiblings();
1373     }
1374 
1375     private void windowWillEnterFullScreen() {
1376         isFullScreenAnimationOn = true;
1377     }
1378 
1379     private void windowDidEnterFullScreen() {
< prev index next >