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

Print this page




  28 import java.awt.*;
  29 import java.awt.Dialog.ModalityType;
  30 import java.awt.event.*;
  31 import java.awt.peer.WindowPeer;
  32 import java.beans.*;
  33 import java.util.List;
  34 
  35 import javax.swing.*;
  36 
  37 import sun.awt.*;
  38 import sun.java2d.SurfaceData;
  39 import sun.java2d.opengl.CGLSurfaceData;
  40 import sun.lwawt.*;
  41 import sun.lwawt.LWWindowPeer.PeerType;
  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 final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  49     private native long nativeCreateNSWindow(long nsViewPtr, 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 
  66     // Loger to report issues happened during execution but that do not affect functionality
  67     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  68     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");


 181             }
 182 
 183             final String filename = ((java.io.File)value).getAbsolutePath();
 184             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
 185         }}
 186     }) {
 187         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 188             Component root = SwingUtilities.getRoot(p);
 189             if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
 190             return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
 191         }
 192     };
 193 
 194     // Bounds of the native widget but in the Java coordinate system.
 195     // In order to keep it up-to-date we will update them on
 196     // 1) setting native bounds via nativeSetBounds() call
 197     // 2) getting notification from the native level via deliverMoveResizeEvent()
 198     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 199     private volatile boolean isFullScreenMode = false;
 200 
 201     private Window target;
 202     private LWWindowPeer peer;
 203     private CPlatformView contentView;
 204     private CPlatformWindow owner;
 205     private boolean visible = false; // visibility status from native perspective
 206     private boolean undecorated; // initialized in getInitialStyleBits()
 207     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 208     private CPlatformResponder responder;
 209     private volatile boolean zoomed = false; // from native perspective
 210 
 211     public CPlatformWindow() {
 212         super(0, true);
 213     }
 214 
 215     /*
 216      * Delegate initialization (create native window and all the
 217      * related resources).
 218      */
 219     @Override // PlatformWindow
 220     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 221         this.peer = _peer;
 222         this.target = _target;
 223         if (_owner instanceof CPlatformWindow) {
 224             this.owner = (CPlatformWindow)_owner;




  28 import java.awt.*;
  29 import java.awt.Dialog.ModalityType;
  30 import java.awt.event.*;
  31 import java.awt.peer.WindowPeer;
  32 import java.beans.*;
  33 import java.util.List;
  34 
  35 import javax.swing.*;
  36 
  37 import sun.awt.*;
  38 import sun.java2d.SurfaceData;
  39 import sun.java2d.opengl.CGLSurfaceData;
  40 import sun.lwawt.*;
  41 import sun.lwawt.LWWindowPeer.PeerType;
  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 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 
  66     // Loger to report issues happened during execution but that do not affect functionality
  67     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  68     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");


 181             }
 182 
 183             final String filename = ((java.io.File)value).getAbsolutePath();
 184             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
 185         }}
 186     }) {
 187         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 188             Component root = SwingUtilities.getRoot(p);
 189             if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
 190             return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
 191         }
 192     };
 193 
 194     // Bounds of the native widget but in the Java coordinate system.
 195     // In order to keep it up-to-date we will update them on
 196     // 1) setting native bounds via nativeSetBounds() call
 197     // 2) getting notification from the native level via deliverMoveResizeEvent()
 198     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 199     private volatile boolean isFullScreenMode = false;
 200 
 201     protected Window target;
 202     protected LWWindowPeer peer;
 203     protected CPlatformView contentView;
 204     protected CPlatformWindow owner;
 205     private boolean visible = false; // visibility status from native perspective
 206     private boolean undecorated; // initialized in getInitialStyleBits()
 207     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 208     private CPlatformResponder responder;
 209     private volatile boolean zoomed = false; // from native perspective
 210 
 211     public CPlatformWindow() {
 212         super(0, true);
 213     }
 214 
 215     /*
 216      * Delegate initialization (create native window and all the
 217      * related resources).
 218      */
 219     @Override // PlatformWindow
 220     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 221         this.peer = _peer;
 222         this.target = _target;
 223         if (_owner instanceof CPlatformWindow) {
 224             this.owner = (CPlatformWindow)_owner;