173 }},
174 new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
175 c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
176 }},
177 new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
178 c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
179 }},
180 new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
181 nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
182 }},
183 new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
184 if (value == null || !(value instanceof java.io.File)) {
185 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
186 return;
187 }
188
189 final String filename = ((java.io.File)value).getAbsolutePath();
190 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
191 }}
192 }) {
193 public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
194 Component root = SwingUtilities.getRoot(p);
195 if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
196 return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
197 }
198 };
199
200 // Bounds of the native widget but in the Java coordinate system.
201 // In order to keep it up-to-date we will update them on
202 // 1) setting native bounds via nativeSetBounds() call
203 // 2) getting notification from the native level via deliverMoveResizeEvent()
204 private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
205 private volatile boolean isFullScreenMode;
206 private boolean isFullScreenAnimationOn;
207
208 private Window target;
209 private LWWindowPeer peer;
210 protected CPlatformView contentView;
211 protected CPlatformWindow owner;
212 protected boolean visible = false; // visibility status from native perspective
502 private void unmaximize() {
503 if (!isMaximized()) {
504 return;
505 }
506 if (!undecorated) {
507 CWrapper.NSWindow.zoom(getNSWindowPtr());
508 } else {
509 deliverZoom(false);
510
511 Rectangle toBounds = this.normalBounds;
512 this.normalBounds = null;
513 setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
514 }
515 }
516
517 public boolean isVisible() {
518 return this.visible;
519 }
520
521 @Override // PlatformWindow
522 public void setVisible(boolean visible) {
523 final long nsWindowPtr = getNSWindowPtr();
524
525 // Process parent-child relationship when hiding
526 if (!visible) {
527 // Unparent my children
528 for (Window w : target.getOwnedWindows()) {
529 WindowPeer p = (WindowPeer)w.getPeer();
530 if (p instanceof LWWindowPeer) {
531 CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
532 if (pw != null && pw.isVisible()) {
533 CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr());
534 }
535 }
536 }
537
538 // Unparent myself
539 if (owner != null && owner.isVisible()) {
540 CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr);
541 }
657 final long nsWindowPtr = ptr;
658 if (nsWindowPtr == 0L) {
659 if(logger.isLoggable(PlatformLogger.Level.FINE)) {
660 logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
661 }
662 }
663 return nsWindowPtr;
664 }
665
666 public SurfaceData getSurfaceData() {
667 return contentView.getSurfaceData();
668 }
669
670 @Override // PlatformWindow
671 public void toBack() {
672 final long nsWindowPtr = getNSWindowPtr();
673 nativePushNSWindowToBack(nsWindowPtr);
674 }
675
676 @Override // PlatformWindow
677 public void toFront() {
678 final long nsWindowPtr = getNSWindowPtr();
679 LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
680 Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
681 if( w != null && w.getPeer() != null
682 && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
683 && !lwcToolkit.isApplicationActive()) {
684 lwcToolkit.activateApplicationIgnoringOtherApps();
685 }
686 updateFocusabilityForAutoRequestFocus(false);
687 nativePushNSWindowToFront(nsWindowPtr);
688 updateFocusabilityForAutoRequestFocus(true);
689 }
690
691 @Override
692 public void setResizable(final boolean resizable) {
693 setStyleBits(RESIZABLE, resizable);
694 }
695
696 @Override
|
173 }},
174 new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
175 c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
176 }},
177 new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
178 c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
179 }},
180 new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
181 nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
182 }},
183 new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
184 if (value == null || !(value instanceof java.io.File)) {
185 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
186 return;
187 }
188
189 final String filename = ((java.io.File)value).getAbsolutePath();
190 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
191 }}
192 }) {
193 @SuppressWarnings("deprecation")
194 public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
195 Component root = SwingUtilities.getRoot(p);
196 if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
197 return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
198 }
199 };
200
201 // Bounds of the native widget but in the Java coordinate system.
202 // In order to keep it up-to-date we will update them on
203 // 1) setting native bounds via nativeSetBounds() call
204 // 2) getting notification from the native level via deliverMoveResizeEvent()
205 private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
206 private volatile boolean isFullScreenMode;
207 private boolean isFullScreenAnimationOn;
208
209 private Window target;
210 private LWWindowPeer peer;
211 protected CPlatformView contentView;
212 protected CPlatformWindow owner;
213 protected boolean visible = false; // visibility status from native perspective
503 private void unmaximize() {
504 if (!isMaximized()) {
505 return;
506 }
507 if (!undecorated) {
508 CWrapper.NSWindow.zoom(getNSWindowPtr());
509 } else {
510 deliverZoom(false);
511
512 Rectangle toBounds = this.normalBounds;
513 this.normalBounds = null;
514 setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
515 }
516 }
517
518 public boolean isVisible() {
519 return this.visible;
520 }
521
522 @Override // PlatformWindow
523 @SuppressWarnings("deprecation")
524 public void setVisible(boolean visible) {
525 final long nsWindowPtr = getNSWindowPtr();
526
527 // Process parent-child relationship when hiding
528 if (!visible) {
529 // Unparent my children
530 for (Window w : target.getOwnedWindows()) {
531 WindowPeer p = (WindowPeer)w.getPeer();
532 if (p instanceof LWWindowPeer) {
533 CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
534 if (pw != null && pw.isVisible()) {
535 CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr());
536 }
537 }
538 }
539
540 // Unparent myself
541 if (owner != null && owner.isVisible()) {
542 CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr);
543 }
659 final long nsWindowPtr = ptr;
660 if (nsWindowPtr == 0L) {
661 if(logger.isLoggable(PlatformLogger.Level.FINE)) {
662 logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
663 }
664 }
665 return nsWindowPtr;
666 }
667
668 public SurfaceData getSurfaceData() {
669 return contentView.getSurfaceData();
670 }
671
672 @Override // PlatformWindow
673 public void toBack() {
674 final long nsWindowPtr = getNSWindowPtr();
675 nativePushNSWindowToBack(nsWindowPtr);
676 }
677
678 @Override // PlatformWindow
679 @SuppressWarnings("deprecation")
680 public void toFront() {
681 final long nsWindowPtr = getNSWindowPtr();
682 LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
683 Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
684 if( w != null && w.getPeer() != null
685 && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
686 && !lwcToolkit.isApplicationActive()) {
687 lwcToolkit.activateApplicationIgnoringOtherApps();
688 }
689 updateFocusabilityForAutoRequestFocus(false);
690 nativePushNSWindowToFront(nsWindowPtr);
691 updateFocusabilityForAutoRequestFocus(true);
692 }
693
694 @Override
695 public void setResizable(final boolean resizable) {
696 setStyleBits(RESIZABLE, resizable);
697 }
698
699 @Override
|