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) {
1109 }
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
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;
826 if (resizable && isMaximizedBoth()) {
827 windowResizable = false;
828 }
829 setCanFullscreen(windowResizable);
830 setStyleBits(RESIZABLE, windowResizable);
831 setStyleBits(ZOOMABLE, windowResizable);
832 }
833
834 @Override
835 public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
836 execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
837 }
838
839 @Override
840 public boolean rejectFocusRequest(FocusEvent.Cause cause) {
841 // Cross-app activation requests are not allowed.
842 if (cause != FocusEvent.Cause.MOUSE_EVENT &&
843 !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
844 {
845 focusLogger.fine("the app is inactive, so the request is rejected");
846 return true;
847 }
848 return false;
849 }
850
851 @Override
919
920 @Override
921 public boolean isFullScreenMode() {
922 return isFullScreenMode;
923 }
924
925 @Override
926 public void setWindowState(int windowState) {
927 if (peer == null || !peer.isVisible()) {
928 // setVisible() applies the state
929 return;
930 }
931
932 int prevWindowState = peer.getState();
933 if (prevWindowState == windowState) return;
934
935 if ((windowState & Frame.ICONIFIED) != 0) {
936 // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
937 windowState = Frame.ICONIFIED;
938 }
939
940 if (isFrameResizibilityChanged()) {
941 updateResizableAndMaximizeState(false);
942 setFrameResizibilityChanged(false);
943 }
944
945 switch (windowState) {
946 case Frame.ICONIFIED:
947 if (prevWindowState == Frame.MAXIMIZED_BOTH) {
948 // let's return into the normal states first
949 // the zoom call toggles between the normal and the max states
950 unmaximize();
951 }
952 execute(CWrapper.NSWindow::miniaturize);
953 break;
954 case Frame.MAXIMIZED_BOTH:
955 if (prevWindowState == Frame.ICONIFIED) {
956 // let's return into the normal states first
957 execute(CWrapper.NSWindow::deminiaturize);
958 }
959 maximize();
960 break;
961 case Frame.NORMAL:
962 if (prevWindowState == Frame.ICONIFIED) {
963 execute(CWrapper.NSWindow::deminiaturize);
964 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
1127 }
1128 }
1129
1130 private void checkZoom() {
1131 if (peer != null) {
1132 int state = peer.getState();
1133 if (state != Frame.MAXIMIZED_BOTH && isMaximized()) {
1134 deliverZoom(true);
1135 } else if (state == Frame.MAXIMIZED_BOTH && !isMaximized()) {
1136 deliverZoom(false);
1137 }
1138 }
1139 }
1140
1141 private void deliverNCMouseDown() {
1142 if (peer != null) {
1143 peer.notifyNCMouseDown();
1144 }
1145 }
1146
1147 private void deliverDoubleClickOnTitlebar() {
1148 if ((peer != null) && (target instanceof Frame)) {
1149 if (isMaximizedBoth()) {
1150 updateResizableAndMaximizeState(false);
1151 execute(CWrapper.NSWindow::zoom);
1152 updateResizableAndMaximizeState(true);
1153 }
1154 }
1155 }
1156
1157 /*
1158 * Our focus model is synthetic and only non-simple window
1159 * may become natively focusable window.
1160 */
1161 private boolean isNativelyFocusableWindow() {
1162 if (peer == null) {
1163 return false;
1164 }
1165
1166 return !peer.isSimpleWindow() && target.getFocusableWindowState();
1167 }
1168
1169 private boolean isBlocked() {
1170 LWWindowPeer blocker = (peer != null) ? peer.getBlocker() : null;
1171 return (blocker != null);
1172 }
1173
1174 /*
1175 * An utility method for the support of the auto request focus.
1176 * Updates the focusable state of the window under certain
1312 } else if (target.getType() == Window.Type.POPUP) {
1313 execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel));
1314 }
1315 }
1316
1317 private Window getOwnerFrameOrDialog(Window window) {
1318 Window owner = window.getOwner();
1319 while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
1320 owner = owner.getOwner();
1321 }
1322 return owner;
1323 }
1324
1325 private boolean isSimpleWindowOwnedByEmbeddedFrame() {
1326 if (peer != null && peer.isSimpleWindow()) {
1327 return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
1328 }
1329 return false;
1330 }
1331
1332 private boolean isTargetResizable() {
1333 if (target instanceof Frame) {
1334 return ((Frame)target).isResizable() && !isMaximizedBoth();
1335 } else if (target instanceof Dialog) {
1336 return ((Dialog)target).isResizable();
1337 }
1338 return false;
1339 }
1340
1341 private void updateResizableAndMaximizeState(boolean maximizeState) {
1342 maximizedBothState = maximizeState;
1343 setResizable(!maximizeState);
1344 }
1345
1346 private boolean isMaximizedBoth() {
1347 return maximizedBothState;
1348 }
1349
1350 private void setFrameResizibilityChanged(boolean resize) {
1351 frameResizibilityChanged = resize;
1352 }
1353
1354 private boolean isFrameResizibilityChanged() {
1355 return frameResizibilityChanged;
1356 }
1357
1358 // ----------------------------------------------------------------------
1359 // NATIVE CALLBACKS
1360 // ----------------------------------------------------------------------
1361
1362 private void windowWillMiniaturize() {
1363 isIconifyAnimationActive = true;
1364 }
1365
1366 private void windowDidBecomeMain() {
1367 lastBecomeMainTime = System.currentTimeMillis();
1368 if (checkBlockingAndOrder()) return;
1369 // If it's not blocked, make sure it's above its siblings
1370 orderAboveSiblings();
1371 }
1372
1373 private void windowWillEnterFullScreen() {
1374 isFullScreenAnimationOn = true;
1375 }
1376
1377 private void windowDidEnterFullScreen() {
|