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

Print this page




 455 
 456     @Override
 457     public GraphicsDevice getGraphicsDevice() {
 458         return contentView.getGraphicsDevice();
 459     }
 460 
 461     @Override // PlatformWindow
 462     public SurfaceData getScreenSurface() {
 463         // TODO: not implemented
 464         return null;
 465     }
 466 
 467     @Override // PlatformWindow
 468     public SurfaceData replaceSurfaceData() {
 469         return contentView.replaceSurfaceData();
 470     }
 471 
 472     @Override // PlatformWindow
 473     public void setBounds(int x, int y, int w, int h) {
 474         nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);

 475     }
 476 
 477     private boolean isMaximized() {
 478         return undecorated ? this.normalBounds != null
 479                 : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
 480     }
 481 
 482     private void maximize() {
 483         if (peer == null || isMaximized()) {
 484             return;
 485         }
 486         if (!undecorated) {
 487             CWrapper.NSWindow.zoom(getNSWindowPtr());
 488         } else {
 489             deliverZoom(true);
 490 
 491             // We need an up to date size of the peer, so we flush the native events
 492             // to be sure that there are no setBounds requests in the queue.
 493             LWCToolkit.flushNativeSelectors();
 494             this.normalBounds = peer.getBounds();


 933         }
 934         return nativePeer;
 935     }
 936 
 937     /*************************************************************
 938      * Callbacks from the AWTWindow and AWTView objc classes.
 939      *************************************************************/
 940     private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
 941         // Fix for 7150349: ingore "gained" notifications when the app is inactive.
 942         if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
 943             focusLogger.fine("the app is inactive, so the notification is ignored");
 944             return;
 945         }
 946 
 947         LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
 948         responder.handleWindowFocusEvent(gained, oppositePeer);
 949     }
 950 
 951     protected void deliverMoveResizeEvent(int x, int y, int width, int height,
 952                                         boolean byUser) {
 953         checkZoom();
 954 
 955         final Rectangle oldB = nativeBounds;
 956         nativeBounds = new Rectangle(x, y, width, height);
 957         if (peer != null) {
 958             peer.notifyReshape(x, y, width, height);
 959             // System-dependent appearance optimization.
 960             if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
 961                     || isFullScreenAnimationOn) {
 962                 flushBuffers();
 963             }
 964         }
 965     }
 966 
 967     private void deliverWindowClosingEvent() {
 968         if (peer != null && peer.getBlocker() == null) {
 969             peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
 970         }
 971     }
 972 
 973     private void deliverIconify(final boolean iconify) {
 974         if (peer != null) {
 975             peer.notifyIconify(iconify);
 976         }
 977     }
 978 
 979     private void deliverZoom(final boolean isZoomed) {
 980         if (peer != null) {
 981             peer.notifyZoom(isZoomed);
 982         }
 983     }
 984 
 985     private void checkZoom() {
 986         if (target instanceof Frame && isVisible()) {
 987             Frame targetFrame = (Frame)target;
 988             if (targetFrame.getExtendedState() != Frame.MAXIMIZED_BOTH && isMaximized()) {






 989                 deliverZoom(true);
 990             } else if (targetFrame.getExtendedState() == Frame.MAXIMIZED_BOTH && !isMaximized()) {
 991                 deliverZoom(false);
 992             }
 993         }
 994     }
 995 
 996     private void deliverNCMouseDown() {
 997         if (peer != null) {
 998             peer.notifyNCMouseDown();
 999         }
1000     }
1001 
1002     /*
1003      * Our focus model is synthetic and only non-simple window
1004      * may become natively focusable window.
1005      */
1006     private boolean isNativelyFocusableWindow() {
1007         if (peer == null) {
1008             return false;
1009         }
1010 




 455 
 456     @Override
 457     public GraphicsDevice getGraphicsDevice() {
 458         return contentView.getGraphicsDevice();
 459     }
 460 
 461     @Override // PlatformWindow
 462     public SurfaceData getScreenSurface() {
 463         // TODO: not implemented
 464         return null;
 465     }
 466 
 467     @Override // PlatformWindow
 468     public SurfaceData replaceSurfaceData() {
 469         return contentView.replaceSurfaceData();
 470     }
 471 
 472     @Override // PlatformWindow
 473     public void setBounds(int x, int y, int w, int h) {
 474         nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
 475         checkZoom(false);
 476     }
 477 
 478     private boolean isMaximized() {
 479         return undecorated ? this.normalBounds != null
 480                 : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
 481     }
 482 
 483     private void maximize() {
 484         if (peer == null || isMaximized()) {
 485             return;
 486         }
 487         if (!undecorated) {
 488             CWrapper.NSWindow.zoom(getNSWindowPtr());
 489         } else {
 490             deliverZoom(true);
 491 
 492             // We need an up to date size of the peer, so we flush the native events
 493             // to be sure that there are no setBounds requests in the queue.
 494             LWCToolkit.flushNativeSelectors();
 495             this.normalBounds = peer.getBounds();


 934         }
 935         return nativePeer;
 936     }
 937 
 938     /*************************************************************
 939      * Callbacks from the AWTWindow and AWTView objc classes.
 940      *************************************************************/
 941     private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
 942         // Fix for 7150349: ingore "gained" notifications when the app is inactive.
 943         if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
 944             focusLogger.fine("the app is inactive, so the notification is ignored");
 945             return;
 946         }
 947 
 948         LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
 949         responder.handleWindowFocusEvent(gained, oppositePeer);
 950     }
 951 
 952     protected void deliverMoveResizeEvent(int x, int y, int width, int height,
 953                                         boolean byUser) {
 954         checkZoom(true);
 955 
 956         final Rectangle oldB = nativeBounds;
 957         nativeBounds = new Rectangle(x, y, width, height);
 958         if (peer != null) {
 959             peer.notifyReshape(x, y, width, height);
 960             // System-dependent appearance optimization.
 961             if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
 962                     || isFullScreenAnimationOn) {
 963                 flushBuffers();
 964             }
 965         }
 966     }
 967 
 968     private void deliverWindowClosingEvent() {
 969         if (peer != null && peer.getBlocker() == null) {
 970             peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
 971         }
 972     }
 973 
 974     private void deliverIconify(final boolean iconify) {
 975         if (peer != null) {
 976             peer.notifyIconify(iconify);
 977         }
 978     }
 979 
 980     private void deliverZoom(final boolean isZoomed) {
 981         if (peer != null) {
 982             peer.notifyZoom(isZoomed);
 983         }
 984     }
 985 
 986     private void checkZoom(boolean mouseEvent) {
 987 
 988         if(mouseEvent && !isVisible()){
 989             return;
 990         }
 991 
 992         if (target instanceof Frame) {
 993             Frame targetFrame = (Frame) target;
 994             int state = targetFrame.getExtendedState();
 995             if (state != Frame.MAXIMIZED_BOTH && isMaximized()) {
 996                 deliverZoom(true);
 997             } else if (mouseEvent && state == Frame.MAXIMIZED_BOTH && !isMaximized()) {
 998                 deliverZoom(false);
 999             }
1000         }
1001     }
1002 
1003     private void deliverNCMouseDown() {
1004         if (peer != null) {
1005             peer.notifyNCMouseDown();
1006         }
1007     }
1008 
1009     /*
1010      * Our focus model is synthetic and only non-simple window
1011      * may become natively focusable window.
1012      */
1013     private boolean isNativelyFocusableWindow() {
1014         if (peer == null) {
1015             return false;
1016         }
1017