equal
deleted
inserted
replaced
293 protected boolean visible = false; // visibility status from native perspective |
293 protected boolean visible = false; // visibility status from native perspective |
294 private boolean undecorated; // initialized in getInitialStyleBits() |
294 private boolean undecorated; // initialized in getInitialStyleBits() |
295 private Rectangle normalBounds = null; // not-null only for undecorated maximized windows |
295 private Rectangle normalBounds = null; // not-null only for undecorated maximized windows |
296 private CPlatformResponder responder; |
296 private CPlatformResponder responder; |
297 private long lastBecomeMainTime; // this is necessary to preserve right siblings order |
297 private long lastBecomeMainTime; // this is necessary to preserve right siblings order |
|
298 private boolean maximizedBothState = false; |
|
299 private boolean frameResizibilityChanged = false; |
298 |
300 |
299 public CPlatformWindow() { |
301 public CPlatformWindow() { |
300 super(0, true); |
302 super(0, true); |
301 } |
303 } |
302 |
304 |
395 if (this.undecorated) styleBits = SET(styleBits, DECORATED, false); |
397 if (this.undecorated) styleBits = SET(styleBits, DECORATED, false); |
396 } |
398 } |
397 |
399 |
398 // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable |
400 // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable |
399 { |
401 { |
400 final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); |
402 final boolean resizable = isTargetResizable(); |
401 styleBits = SET(styleBits, RESIZABLE, resizable); |
403 styleBits = SET(styleBits, RESIZABLE, resizable); |
402 if (!resizable) { |
404 if (!resizable) { |
403 styleBits = SET(styleBits, ZOOMABLE, false); |
405 styleBits = SET(styleBits, ZOOMABLE, false); |
404 } |
406 } |
405 } |
407 } |
607 this.normalBounds = peer.getBounds(); |
609 this.normalBounds = peer.getBounds(); |
608 Rectangle maximizedBounds = peer.getMaximizedBounds(); |
610 Rectangle maximizedBounds = peer.getMaximizedBounds(); |
609 setBounds(maximizedBounds.x, maximizedBounds.y, |
611 setBounds(maximizedBounds.x, maximizedBounds.y, |
610 maximizedBounds.width, maximizedBounds.height); |
612 maximizedBounds.width, maximizedBounds.height); |
611 } |
613 } |
|
614 setFrameResizibilityChanged(true); |
|
615 updateResizableAndMaximizeState(true); |
612 } |
616 } |
613 |
617 |
614 private void unmaximize() { |
618 private void unmaximize() { |
615 if (!isMaximized()) { |
619 if (!isMaximized()) { |
616 return; |
620 return; |
703 this.visible = visible; |
707 this.visible = visible; |
704 |
708 |
705 // Manage the extended state when showing |
709 // Manage the extended state when showing |
706 if (visible) { |
710 if (visible) { |
707 /* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the |
711 /* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the |
708 Frame or Dialog is resizable. |
712 Frame resizable and Frame state is not MAXIMIZED_BOTH or Dialog is resizable. |
709 **/ |
713 **/ |
710 final boolean resizable = (target instanceof Frame) ? ((Frame)target).isResizable() : |
714 if (isTargetResizable()) { |
711 ((target instanceof Dialog) ? ((Dialog)target).isResizable() : false); |
|
712 if (resizable) { |
|
713 setCanFullscreen(true); |
715 setCanFullscreen(true); |
714 } |
716 } |
715 |
717 |
716 // Apply the extended state as expected in shared code |
718 // Apply the extended state as expected in shared code |
717 if (target instanceof Frame) { |
719 if (target instanceof Frame) { |
722 int frameState = ((Frame)target).getExtendedState(); |
724 int frameState = ((Frame)target).getExtendedState(); |
723 if ((frameState & Frame.ICONIFIED) != 0) { |
725 if ((frameState & Frame.ICONIFIED) != 0) { |
724 // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. |
726 // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. |
725 frameState = Frame.ICONIFIED; |
727 frameState = Frame.ICONIFIED; |
726 } |
728 } |
|
729 |
|
730 if (isFrameResizibilityChanged()) { |
|
731 updateResizableAndMaximizeState(false); |
|
732 setFrameResizibilityChanged(false); |
|
733 } |
|
734 |
727 switch (frameState) { |
735 switch (frameState) { |
728 case Frame.ICONIFIED: |
736 case Frame.ICONIFIED: |
729 execute(CWrapper.NSWindow::miniaturize); |
737 execute(CWrapper.NSWindow::miniaturize); |
730 break; |
738 break; |
731 case Frame.MAXIMIZED_BOTH: |
739 case Frame.MAXIMIZED_BOTH: |
841 } |
849 } |
842 } |
850 } |
843 |
851 |
844 @Override |
852 @Override |
845 public void setResizable(final boolean resizable) { |
853 public void setResizable(final boolean resizable) { |
846 setCanFullscreen(resizable); |
854 boolean windowResizable = resizable && !isMaximizedBoth(); |
847 setStyleBits(RESIZABLE, resizable); |
855 setCanFullscreen(windowResizable); |
848 setStyleBits(ZOOMABLE, resizable); |
856 setStyleBits(RESIZABLE, windowResizable); |
|
857 setStyleBits(ZOOMABLE, windowResizable); |
849 } |
858 } |
850 |
859 |
851 @Override |
860 @Override |
852 public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { |
861 public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { |
853 execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH)); |
862 execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH)); |
951 |
960 |
952 if ((windowState & Frame.ICONIFIED) != 0) { |
961 if ((windowState & Frame.ICONIFIED) != 0) { |
953 // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. |
962 // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. |
954 windowState = Frame.ICONIFIED; |
963 windowState = Frame.ICONIFIED; |
955 } |
964 } |
|
965 |
|
966 if (isFrameResizibilityChanged()) { |
|
967 updateResizableAndMaximizeState(false); |
|
968 setFrameResizibilityChanged(false); |
|
969 } |
|
970 |
956 switch (windowState) { |
971 switch (windowState) { |
957 case Frame.ICONIFIED: |
972 case Frame.ICONIFIED: |
958 if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
973 if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
959 // let's return into the normal states first |
974 // let's return into the normal states first |
960 // the zoom call toggles between the normal and the max states |
975 // the zoom call toggles between the normal and the max states |
1150 } |
1165 } |
1151 |
1166 |
1152 private void deliverNCMouseDown() { |
1167 private void deliverNCMouseDown() { |
1153 if (peer != null) { |
1168 if (peer != null) { |
1154 peer.notifyNCMouseDown(); |
1169 peer.notifyNCMouseDown(); |
|
1170 } |
|
1171 } |
|
1172 |
|
1173 /* |
|
1174 * Resizibility of frame with state MAXIMIZED_BOTH is set to true to zoom |
|
1175 * the frame on double click on title bar and set to false later. This is |
|
1176 * required as frame won't zoom if resizibility of frame is false. |
|
1177 */ |
|
1178 private void deliverDoubleClickOnTitlebar() { |
|
1179 if ((peer != null) && (target instanceof Frame)) { |
|
1180 if (isMaximizedBoth()) { |
|
1181 updateResizableAndMaximizeState(false); |
|
1182 execute(CWrapper.NSWindow::zoom); |
|
1183 updateResizableAndMaximizeState(true); |
|
1184 } |
1155 } |
1185 } |
1156 } |
1186 } |
1157 |
1187 |
1158 /* |
1188 /* |
1159 * Our focus model is synthetic and only non-simple window |
1189 * Our focus model is synthetic and only non-simple window |
1328 return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame); |
1358 return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame); |
1329 } |
1359 } |
1330 return false; |
1360 return false; |
1331 } |
1361 } |
1332 |
1362 |
|
1363 private boolean isTargetResizable() { |
|
1364 if (target instanceof Frame) { |
|
1365 return ((Frame)target).isResizable() && !isMaximizedBoth(); |
|
1366 } else if (target instanceof Dialog) { |
|
1367 return ((Dialog)target).isResizable(); |
|
1368 } |
|
1369 return false; |
|
1370 } |
|
1371 |
|
1372 private void updateResizableAndMaximizeState(boolean maximizeState) { |
|
1373 maximizedBothState = maximizeState; |
|
1374 setResizable(!maximizeState); |
|
1375 } |
|
1376 |
|
1377 private boolean isMaximizedBoth() { |
|
1378 return maximizedBothState; |
|
1379 } |
|
1380 |
|
1381 private void setFrameResizibilityChanged(boolean resize) { |
|
1382 frameResizibilityChanged = resize; |
|
1383 } |
|
1384 |
|
1385 private boolean isFrameResizibilityChanged() { |
|
1386 return frameResizibilityChanged; |
|
1387 } |
|
1388 |
1333 // ---------------------------------------------------------------------- |
1389 // ---------------------------------------------------------------------- |
1334 // NATIVE CALLBACKS |
1390 // NATIVE CALLBACKS |
1335 // ---------------------------------------------------------------------- |
1391 // ---------------------------------------------------------------------- |
1336 |
1392 |
1337 private void windowWillMiniaturize() { |
1393 private void windowWillMiniaturize() { |