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

Print this page




  34 
  35 import javax.swing.*;
  36 
  37 import sun.awt.*;
  38 import sun.awt.AWTAccessor.ComponentAccessor;
  39 import sun.java2d.SurfaceData;
  40 import sun.java2d.opengl.CGLSurfaceData;
  41 import sun.lwawt.*;
  42 import sun.util.logging.PlatformLogger;
  43 
  44 import com.apple.laf.*;
  45 import com.apple.laf.ClientPropertyApplicator.Property;
  46 import com.sun.awt.AWTUtilities;
  47 
  48 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  49     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
  50     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  51     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  52     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  53     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);


  54     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  55     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  56     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  57     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  58     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  59     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  60     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  61     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  62     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  63     private static native void nativeDispose(long nsWindowPtr);
  64     private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
  65     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
  66     private static native void nativeExitFullScreenMode(long nsWindowPtr);
  67 
  68     // Loger to report issues happened during execution but that do not affect functionality
  69     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  70     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
  71 
  72     // for client properties
  73     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";


 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();
 495 
 496             GraphicsConfiguration config = getPeer().getGraphicsConfiguration();


 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 
1011         return !peer.isSimpleWindow() && target.getFocusableWindowState();
1012     }
1013 
1014     /*




  34 
  35 import javax.swing.*;
  36 
  37 import sun.awt.*;
  38 import sun.awt.AWTAccessor.ComponentAccessor;
  39 import sun.java2d.SurfaceData;
  40 import sun.java2d.opengl.CGLSurfaceData;
  41 import sun.lwawt.*;
  42 import sun.util.logging.PlatformLogger;
  43 
  44 import com.apple.laf.*;
  45 import com.apple.laf.ClientPropertyApplicator.Property;
  46 import com.sun.awt.AWTUtilities;
  47 
  48 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  49     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
  50     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  51     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  52     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  53     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  54     private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
  55             double x, double y, double w, double h);
  56     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  57     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  58     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  59     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  60     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  61     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  62     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  63     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  64     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  65     private static native void nativeDispose(long nsWindowPtr);
  66     private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
  67     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
  68     private static native void nativeExitFullScreenMode(long nsWindowPtr);
  69 
  70     // Loger to report issues happened during execution but that do not affect functionality
  71     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  72     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
  73 
  74     // for client properties
  75     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";


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


 972 
 973     private void deliverWindowClosingEvent() {
 974         if (peer != null && peer.getBlocker() == null) {
 975             peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
 976         }
 977     }
 978 
 979     private void deliverIconify(final boolean iconify) {
 980         if (peer != null) {
 981             peer.notifyIconify(iconify);
 982         }
 983     }
 984 
 985     private void deliverZoom(final boolean isZoomed) {
 986         if (peer != null) {
 987             peer.notifyZoom(isZoomed);
 988         }
 989     }
 990 
 991     private void checkZoom() {
 992         int state = peer.getState();
 993         if (state != Frame.MAXIMIZED_BOTH && isMaximized()) {

 994             deliverZoom(true);
 995         } else if (state == Frame.MAXIMIZED_BOTH && !isMaximized()) {
 996             deliverZoom(false);
 997         }
 998     }

 999 
1000     private void deliverNCMouseDown() {
1001         if (peer != null) {
1002             peer.notifyNCMouseDown();
1003         }
1004     }
1005 
1006     /*
1007      * Our focus model is synthetic and only non-simple window
1008      * may become natively focusable window.
1009      */
1010     private boolean isNativelyFocusableWindow() {
1011         if (peer == null) {
1012             return false;
1013         }
1014 
1015         return !peer.isSimpleWindow() && target.getFocusableWindowState();
1016     }
1017 
1018     /*