13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.lwawt.macosx;
27
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.util.logging.PlatformLogger;
42
43 import com.apple.laf.*;
44 import com.apple.laf.ClientPropertyApplicator.Property;
45 import com.sun.awt.AWTUtilities;
46
47 public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
48 private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
49 private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
50 private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
51 private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
52 private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
840 }
841
842 public CPlatformView getContentView() {
843 return contentView;
844 }
845
846 @Override
847 public long getLayerPtr() {
848 return contentView.getWindowLayerPtr();
849 }
850
851 private void validateSurface() {
852 SurfaceData surfaceData = getSurfaceData();
853 if (surfaceData instanceof CGLSurfaceData) {
854 ((CGLSurfaceData)surfaceData).validate();
855 }
856 }
857
858 private void flushBuffers() {
859 if (isVisible() && !nativeBounds.isEmpty()) {
860 LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target);
861 }
862 }
863
864 /*************************************************************
865 * Callbacks from the AWTWindow and AWTView objc classes.
866 *************************************************************/
867 private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
868 // Fix for 7150349: ingore "gained" notifications when the app is inactive.
869 if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
870 focusLogger.fine("the app is inactive, so the notification is ignored");
871 return;
872 }
873
874 LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
875 responder.handleWindowFocusEvent(gained, oppositePeer);
876 }
877
878 private void deliverMoveResizeEvent(int x, int y, int width, int height,
879 boolean byUser) {
880 // when the content view enters the full-screen mode, the native
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.lwawt.macosx;
27
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.lang.reflect.InvocationTargetException;
34 import java.util.List;
35
36 import javax.swing.*;
37
38 import sun.awt.*;
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 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);
841 }
842
843 public CPlatformView getContentView() {
844 return contentView;
845 }
846
847 @Override
848 public long getLayerPtr() {
849 return contentView.getWindowLayerPtr();
850 }
851
852 private void validateSurface() {
853 SurfaceData surfaceData = getSurfaceData();
854 if (surfaceData instanceof CGLSurfaceData) {
855 ((CGLSurfaceData)surfaceData).validate();
856 }
857 }
858
859 private void flushBuffers() {
860 if (isVisible() && !nativeBounds.isEmpty()) {
861 try {
862 LWCToolkit.invokeAndWait(new Runnable() {
863 @Override
864 public void run() {
865 //Posting an empty to flush the EventQueue without blocking the main thread
866 }
867 }, target);
868 } catch (InterruptedException | InvocationTargetException e) {
869 e.printStackTrace();
870 }
871 }
872 }
873
874 /*************************************************************
875 * Callbacks from the AWTWindow and AWTView objc classes.
876 *************************************************************/
877 private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
878 // Fix for 7150349: ingore "gained" notifications when the app is inactive.
879 if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
880 focusLogger.fine("the app is inactive, so the notification is ignored");
881 return;
882 }
883
884 LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
885 responder.handleWindowFocusEvent(gained, oppositePeer);
886 }
887
888 private void deliverMoveResizeEvent(int x, int y, int width, int height,
889 boolean byUser) {
890 // when the content view enters the full-screen mode, the native
|