< prev index next >

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

Print this page




  84     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  85     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  86     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  87     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  88     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  89     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  90     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  91     private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType);
  92     private static native void nativeDispose(long nsWindowPtr);
  93     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
  94     private static native void nativeExitFullScreenMode(long nsWindowPtr);
  95     static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
  96 
  97     // Loger to report issues happened during execution but that do not affect functionality
  98     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  99     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
 100 
 101     // for client properties
 102     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
 103     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
 104     public static final String WINDOW_DARK_APPEARANCE = "apple.awt.windowDarkAppearance";
 105 
 106     public static final String WINDOW_ALPHA = "Window.alpha";
 107     public static final String WINDOW_SHADOW = "Window.shadow";
 108 
 109     public static final String WINDOW_STYLE = "Window.style";
 110     public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
 111 
 112     public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
 113     public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
 114 
 115     public static final String WINDOW_CLOSEABLE = "Window.closeable";
 116     public static final String WINDOW_MINIMIZABLE = "Window.minimizable";
 117     public static final String WINDOW_ZOOMABLE = "Window.zoomable";
 118     public static final String WINDOW_HIDES_ON_DEACTIVATE="Window.hidesOnDeactivate";
 119 
 120     public static final String WINDOW_DOC_MODAL_SHEET = "apple.awt.documentModalSheet";
 121     public static final String WINDOW_FADE_DELEGATE = "apple.awt._windowFadeDelegate";
 122     public static final String WINDOW_FADE_IN = "apple.awt._windowFadeIn";
 123     public static final String WINDOW_FADE_OUT = "apple.awt._windowFadeOut";
 124     public static final String WINDOW_FULLSCREENABLE = "apple.awt.fullscreenable";


 132 
 133     // window style bits
 134     static final int _RESERVED_FOR_DATA = 1 << 0;
 135 
 136     // corresponds to native style mask bits
 137     static final int DECORATED = 1 << 1;
 138     static final int TEXTURED = 1 << 2;
 139     static final int UNIFIED = 1 << 3;
 140     static final int UTILITY = 1 << 4;
 141     static final int HUD = 1 << 5;
 142     static final int SHEET = 1 << 6;
 143 
 144     static final int CLOSEABLE = 1 << 7;
 145     static final int MINIMIZABLE = 1 << 8;
 146 
 147     static final int RESIZABLE = 1 << 9; // both a style bit and prop bit
 148     static final int NONACTIVATING = 1 << 24;
 149     static final int IS_DIALOG = 1 << 25;
 150     static final int IS_MODAL = 1 << 26;
 151     static final int IS_POPUP = 1 << 27;
 152     static final int DARK_TITLE_BAR = 1 << 28;
 153 
 154     static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE;
 155 
 156     // corresponds to method-based properties
 157     static final int HAS_SHADOW = 1 << 10;
 158     static final int ZOOMABLE = 1 << 11;
 159 
 160     static final int ALWAYS_ON_TOP = 1 << 15;
 161     static final int HIDES_ON_DEACTIVATE = 1 << 17;
 162     static final int DRAGGABLE_BACKGROUND = 1 << 19;
 163     static final int DOCUMENT_MODIFIED = 1 << 21;
 164     static final int FULLSCREENABLE = 1 << 23;
 165 
 166     static final int _METHOD_PROP_BITMASK = RESIZABLE | HAS_SHADOW | ZOOMABLE | ALWAYS_ON_TOP | HIDES_ON_DEACTIVATE | DRAGGABLE_BACKGROUND | DOCUMENT_MODIFIED | FULLSCREENABLE;
 167 
 168     // corresponds to callback-based properties
 169     static final int SHOULD_BECOME_KEY = 1 << 12;
 170     static final int SHOULD_BECOME_MAIN = 1 << 13;
 171     static final int MODAL_EXCLUDED = 1 << 16;
 172 


 215             boolean fullscrenable = Boolean.parseBoolean(value.toString());
 216             if (c.target instanceof RootPaneContainer
 217                     && c.getPeer().getPeerType() == PeerType.FRAME) {
 218                 if (c.isInFullScreen && !fullscrenable) {
 219                     c.toggleFullScreen();
 220                 }
 221             }
 222             c.setStyleBits(FULLSCREENABLE, fullscrenable);
 223         }},
 224         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 225             c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
 226         }},
 227         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 228             if (value == null || !(value instanceof java.io.File)) {
 229                 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null));
 230                 return;
 231             }
 232 
 233             final String filename = ((java.io.File)value).getAbsolutePath();
 234             c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
 235         }},
 236         new Property<CPlatformWindow>(WINDOW_DARK_APPEARANCE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 237             c.setStyleBits(DARK_TITLE_BAR, value == null ? true : Boolean.parseBoolean(value.toString()));
 238         }},
 239     }) {
 240         @SuppressWarnings("deprecation")
 241         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 242             Component root = SwingUtilities.getRoot(p);
 243             final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 244             if (root == null || acc.getPeer(root) == null) return null;
 245             return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
 246         }
 247     };
 248     private final Comparator<Window> siblingsComparator = (w1, w2) -> {
 249         if (w1 == w2) {
 250             return 0;
 251         }
 252         ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
 253         Object p1 = componentAccessor.getPeer(w1);
 254         Object p2 = componentAccessor.getPeer(w2);
 255         if (p1 instanceof LWWindowPeer && p2 instanceof LWWindowPeer) {
 256             return Long.compare(
 257                     ((CPlatformWindow) (((LWWindowPeer) p1).getPlatformWindow())).lastBecomeMainTime,
 258                     ((CPlatformWindow) (((LWWindowPeer) p2).getPlatformWindow())).lastBecomeMainTime);


 456 
 457             prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
 458             if (prop != null) {
 459                 styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
 460             }
 461 
 462             prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
 463             if (prop != null) {
 464                 styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
 465             }
 466 
 467             prop = rootpane.getClientProperty(WINDOW_SHADOW);
 468             if (prop != null) {
 469                 styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
 470             }
 471 
 472             prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
 473             if (prop != null) {
 474                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
 475             }
 476 
 477             prop = rootpane.getClientProperty(WINDOW_DARK_APPEARANCE);
 478             if (prop != null) {
 479                styleBits = SET(styleBits, DARK_TITLE_BAR, Boolean.parseBoolean(prop.toString()));
 480             }
 481         }
 482 
 483         if (isDialog) {
 484             styleBits = SET(styleBits, IS_DIALOG, true);
 485             if (((Dialog) target).isModal()) {
 486                 styleBits = SET(styleBits, IS_MODAL, true);
 487             }
 488         }
 489 
 490         peer.setTextured(IS(TEXTURED, styleBits));
 491 
 492         return styleBits;
 493     }
 494 
 495     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
 496     private void setStyleBits(final int mask, final boolean value) {
 497         execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
 498     }
 499 
 500     private native void _toggleFullScreenMode(final long model);




  84     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  85     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  86     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  87     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  88     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  89     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  90     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  91     private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType);
  92     private static native void nativeDispose(long nsWindowPtr);
  93     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
  94     private static native void nativeExitFullScreenMode(long nsWindowPtr);
  95     static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
  96 
  97     // Loger to report issues happened during execution but that do not affect functionality
  98     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  99     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
 100 
 101     // for client properties
 102     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
 103     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";

 104 
 105     public static final String WINDOW_ALPHA = "Window.alpha";
 106     public static final String WINDOW_SHADOW = "Window.shadow";
 107 
 108     public static final String WINDOW_STYLE = "Window.style";
 109     public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
 110 
 111     public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
 112     public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
 113 
 114     public static final String WINDOW_CLOSEABLE = "Window.closeable";
 115     public static final String WINDOW_MINIMIZABLE = "Window.minimizable";
 116     public static final String WINDOW_ZOOMABLE = "Window.zoomable";
 117     public static final String WINDOW_HIDES_ON_DEACTIVATE="Window.hidesOnDeactivate";
 118 
 119     public static final String WINDOW_DOC_MODAL_SHEET = "apple.awt.documentModalSheet";
 120     public static final String WINDOW_FADE_DELEGATE = "apple.awt._windowFadeDelegate";
 121     public static final String WINDOW_FADE_IN = "apple.awt._windowFadeIn";
 122     public static final String WINDOW_FADE_OUT = "apple.awt._windowFadeOut";
 123     public static final String WINDOW_FULLSCREENABLE = "apple.awt.fullscreenable";


 131 
 132     // window style bits
 133     static final int _RESERVED_FOR_DATA = 1 << 0;
 134 
 135     // corresponds to native style mask bits
 136     static final int DECORATED = 1 << 1;
 137     static final int TEXTURED = 1 << 2;
 138     static final int UNIFIED = 1 << 3;
 139     static final int UTILITY = 1 << 4;
 140     static final int HUD = 1 << 5;
 141     static final int SHEET = 1 << 6;
 142 
 143     static final int CLOSEABLE = 1 << 7;
 144     static final int MINIMIZABLE = 1 << 8;
 145 
 146     static final int RESIZABLE = 1 << 9; // both a style bit and prop bit
 147     static final int NONACTIVATING = 1 << 24;
 148     static final int IS_DIALOG = 1 << 25;
 149     static final int IS_MODAL = 1 << 26;
 150     static final int IS_POPUP = 1 << 27;

 151 
 152     static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE;
 153 
 154     // corresponds to method-based properties
 155     static final int HAS_SHADOW = 1 << 10;
 156     static final int ZOOMABLE = 1 << 11;
 157 
 158     static final int ALWAYS_ON_TOP = 1 << 15;
 159     static final int HIDES_ON_DEACTIVATE = 1 << 17;
 160     static final int DRAGGABLE_BACKGROUND = 1 << 19;
 161     static final int DOCUMENT_MODIFIED = 1 << 21;
 162     static final int FULLSCREENABLE = 1 << 23;
 163 
 164     static final int _METHOD_PROP_BITMASK = RESIZABLE | HAS_SHADOW | ZOOMABLE | ALWAYS_ON_TOP | HIDES_ON_DEACTIVATE | DRAGGABLE_BACKGROUND | DOCUMENT_MODIFIED | FULLSCREENABLE;
 165 
 166     // corresponds to callback-based properties
 167     static final int SHOULD_BECOME_KEY = 1 << 12;
 168     static final int SHOULD_BECOME_MAIN = 1 << 13;
 169     static final int MODAL_EXCLUDED = 1 << 16;
 170 


 213             boolean fullscrenable = Boolean.parseBoolean(value.toString());
 214             if (c.target instanceof RootPaneContainer
 215                     && c.getPeer().getPeerType() == PeerType.FRAME) {
 216                 if (c.isInFullScreen && !fullscrenable) {
 217                     c.toggleFullScreen();
 218                 }
 219             }
 220             c.setStyleBits(FULLSCREENABLE, fullscrenable);
 221         }},
 222         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 223             c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
 224         }},
 225         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 226             if (value == null || !(value instanceof java.io.File)) {
 227                 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null));
 228                 return;
 229             }
 230 
 231             final String filename = ((java.io.File)value).getAbsolutePath();
 232             c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
 233         }}



 234     }) {
 235         @SuppressWarnings("deprecation")
 236         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 237             Component root = SwingUtilities.getRoot(p);
 238             final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 239             if (root == null || acc.getPeer(root) == null) return null;
 240             return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
 241         }
 242     };
 243     private final Comparator<Window> siblingsComparator = (w1, w2) -> {
 244         if (w1 == w2) {
 245             return 0;
 246         }
 247         ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
 248         Object p1 = componentAccessor.getPeer(w1);
 249         Object p2 = componentAccessor.getPeer(w2);
 250         if (p1 instanceof LWWindowPeer && p2 instanceof LWWindowPeer) {
 251             return Long.compare(
 252                     ((CPlatformWindow) (((LWWindowPeer) p1).getPlatformWindow())).lastBecomeMainTime,
 253                     ((CPlatformWindow) (((LWWindowPeer) p2).getPlatformWindow())).lastBecomeMainTime);


 451 
 452             prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
 453             if (prop != null) {
 454                 styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
 455             }
 456 
 457             prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
 458             if (prop != null) {
 459                 styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
 460             }
 461 
 462             prop = rootpane.getClientProperty(WINDOW_SHADOW);
 463             if (prop != null) {
 464                 styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
 465             }
 466 
 467             prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
 468             if (prop != null) {
 469                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
 470             }





 471         }
 472 
 473         if (isDialog) {
 474             styleBits = SET(styleBits, IS_DIALOG, true);
 475             if (((Dialog) target).isModal()) {
 476                 styleBits = SET(styleBits, IS_MODAL, true);
 477             }
 478         }
 479 
 480         peer.setTextured(IS(TEXTURED, styleBits));
 481 
 482         return styleBits;
 483     }
 484 
 485     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
 486     private void setStyleBits(final int mask, final boolean value) {
 487         execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
 488     }
 489 
 490     private native void _toggleFullScreenMode(final long model);


< prev index next >