45 import java.beans.PropertyChangeEvent;
46 import java.beans.PropertyChangeListener;
47 import java.lang.reflect.InvocationTargetException;
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.Comparator;
51 import java.util.concurrent.atomic.AtomicBoolean;
52 import java.util.concurrent.atomic.AtomicLong;
53 import java.util.concurrent.atomic.AtomicReference;
54
55 import javax.swing.JRootPane;
56 import javax.swing.RootPaneContainer;
57 import javax.swing.SwingUtilities;
58
59 import com.apple.laf.ClientPropertyApplicator;
60 import com.apple.laf.ClientPropertyApplicator.Property;
61 import sun.awt.AWTAccessor;
62 import sun.awt.AWTAccessor.ComponentAccessor;
63 import sun.awt.AWTAccessor.WindowAccessor;
64 import sun.java2d.SurfaceData;
65 import sun.java2d.opengl.CGLSurfaceData;
66 import sun.lwawt.LWLightweightFramePeer;
67 import sun.lwawt.LWToolkit;
68 import sun.lwawt.LWWindowPeer;
69 import sun.lwawt.LWWindowPeer.PeerType;
70 import sun.lwawt.PlatformWindow;
71 import sun.util.logging.PlatformLogger;
72
73 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
74 private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
75 private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
76 private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
77 private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
78 private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
79 private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr);
80 private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
81 double x, double y, double w, double h);
82 private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
83 private static native void nativePushNSWindowToBack(long nsWindowPtr);
84 private static native void nativePushNSWindowToFront(long nsWindowPtr);
1039 }
1040
1041 @Override
1042 public boolean isUnderMouse() {
1043 return contentView.isUnderMouse();
1044 }
1045
1046 public CPlatformView getContentView() {
1047 return contentView;
1048 }
1049
1050 @Override
1051 public long getLayerPtr() {
1052 return contentView.getWindowLayerPtr();
1053 }
1054
1055 private void validateSurface() {
1056 SurfaceData surfaceData = getSurfaceData();
1057 if (surfaceData instanceof CGLSurfaceData) {
1058 ((CGLSurfaceData)surfaceData).validate();
1059 }
1060 }
1061
1062 void flushBuffers() {
1063 if (isVisible() && !nativeBounds.isEmpty() && !isFullScreenMode) {
1064 try {
1065 LWCToolkit.invokeAndWait(new Runnable() {
1066 @Override
1067 public void run() {
1068 //Posting an empty to flush the EventQueue without blocking the main thread
1069 }
1070 }, target);
1071 } catch (InvocationTargetException e) {
1072 e.printStackTrace();
1073 }
1074 }
1075 }
1076
1077 /**
1078 * Helper method to get a pointer to the native view from the PlatformWindow.
|
45 import java.beans.PropertyChangeEvent;
46 import java.beans.PropertyChangeListener;
47 import java.lang.reflect.InvocationTargetException;
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.Comparator;
51 import java.util.concurrent.atomic.AtomicBoolean;
52 import java.util.concurrent.atomic.AtomicLong;
53 import java.util.concurrent.atomic.AtomicReference;
54
55 import javax.swing.JRootPane;
56 import javax.swing.RootPaneContainer;
57 import javax.swing.SwingUtilities;
58
59 import com.apple.laf.ClientPropertyApplicator;
60 import com.apple.laf.ClientPropertyApplicator.Property;
61 import sun.awt.AWTAccessor;
62 import sun.awt.AWTAccessor.ComponentAccessor;
63 import sun.awt.AWTAccessor.WindowAccessor;
64 import sun.java2d.SurfaceData;
65 import sun.java2d.metal.MTLSurfaceData;
66 import sun.java2d.opengl.CGLSurfaceData;
67 import sun.lwawt.LWLightweightFramePeer;
68 import sun.lwawt.LWToolkit;
69 import sun.lwawt.LWWindowPeer;
70 import sun.lwawt.LWWindowPeer.PeerType;
71 import sun.lwawt.PlatformWindow;
72 import sun.util.logging.PlatformLogger;
73
74 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
75 private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
76 private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
77 private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
78 private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
79 private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
80 private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr);
81 private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
82 double x, double y, double w, double h);
83 private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
84 private static native void nativePushNSWindowToBack(long nsWindowPtr);
85 private static native void nativePushNSWindowToFront(long nsWindowPtr);
1040 }
1041
1042 @Override
1043 public boolean isUnderMouse() {
1044 return contentView.isUnderMouse();
1045 }
1046
1047 public CPlatformView getContentView() {
1048 return contentView;
1049 }
1050
1051 @Override
1052 public long getLayerPtr() {
1053 return contentView.getWindowLayerPtr();
1054 }
1055
1056 private void validateSurface() {
1057 SurfaceData surfaceData = getSurfaceData();
1058 if (surfaceData instanceof CGLSurfaceData) {
1059 ((CGLSurfaceData)surfaceData).validate();
1060 } else if (surfaceData instanceof MTLSurfaceData) {
1061 ((MTLSurfaceData)surfaceData).validate();
1062 }
1063 }
1064
1065 void flushBuffers() {
1066 if (isVisible() && !nativeBounds.isEmpty() && !isFullScreenMode) {
1067 try {
1068 LWCToolkit.invokeAndWait(new Runnable() {
1069 @Override
1070 public void run() {
1071 //Posting an empty to flush the EventQueue without blocking the main thread
1072 }
1073 }, target);
1074 } catch (InvocationTargetException e) {
1075 e.printStackTrace();
1076 }
1077 }
1078 }
1079
1080 /**
1081 * Helper method to get a pointer to the native view from the PlatformWindow.
|