jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
author serb
Tue, 23 Sep 2014 07:13:34 +0400
changeset 27052 0b783c32e5c2
parent 25859 3317bb8137f4
child 27272 cffe6690ee9d
permissions -rw-r--r--
8041734: JFrame in full screen mode leaves empty workspace after close Reviewed-by: azvegint, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
23309
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
     2
 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
package sun.lwawt.macosx;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
import java.awt.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
import java.awt.Dialog.ModalityType;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
import java.awt.event.*;
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
    31
import java.awt.peer.WindowPeer;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
import java.beans.*;
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
    33
import java.lang.reflect.InvocationTargetException;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
import java.util.List;
17151
9bfcf2a592fc 8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents: 16840
diff changeset
    35
import java.util.Objects;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
import javax.swing.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
import sun.awt.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
import sun.java2d.SurfaceData;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
import sun.java2d.opengl.CGLSurfaceData;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
import sun.lwawt.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
import sun.util.logging.PlatformLogger;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
import com.apple.laf.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
import com.apple.laf.ClientPropertyApplicator.Property;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
import com.sun.awt.AWTUtilities;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
    49
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
19021
8a5340b88ee5 8017189: [macosx] AWT program menu disabled on Mac
serb
parents: 18763
diff changeset
    50
    private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
    private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
    private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
    private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
    private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
    private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
    private static native void nativePushNSWindowToBack(long nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    57
    private static native void nativePushNSWindowToFront(long nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    58
    private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    59
    private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    60
    private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    61
    private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
    62
    private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
    63
    private static native void nativeSynthesizeMouseEnteredExitedEvents();
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
    64
    private static native void nativeDispose(long nsWindowPtr);
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
    65
    private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
21282
1bef38644939 8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
leonidr
parents: 21272
diff changeset
    66
    private static native void nativeEnterFullScreenMode(long nsWindowPtr);
1bef38644939 8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
leonidr
parents: 21272
diff changeset
    67
    private static native void nativeExitFullScreenMode(long nsWindowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
    // Loger to report issues happened during execution but that do not affect functionality
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
    private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
12176
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
    71
    private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
    // for client properties
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
    public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
    public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
    public static final String WINDOW_ALPHA = "Window.alpha";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
    public static final String WINDOW_SHADOW = "Window.shadow";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    79
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
    public static final String WINDOW_STYLE = "Window.style";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
    public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    82
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
    public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
    public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    86
    public static final String WINDOW_CLOSEABLE = "Window.closeable";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
    public static final String WINDOW_MINIMIZABLE = "Window.minimizable";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
    public static final String WINDOW_ZOOMABLE = "Window.zoomable";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
    public static final String WINDOW_HIDES_ON_DEACTIVATE="Window.hidesOnDeactivate";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
    public static final String WINDOW_DOC_MODAL_SHEET = "apple.awt.documentModalSheet";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
    public static final String WINDOW_FADE_DELEGATE = "apple.awt._windowFadeDelegate";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    93
    public static final String WINDOW_FADE_IN = "apple.awt._windowFadeIn";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    94
    public static final String WINDOW_FADE_OUT = "apple.awt._windowFadeOut";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
    public static final String WINDOW_FULLSCREENABLE = "apple.awt.fullscreenable";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    97
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    98
    // Yeah, I know. But it's easier to deal with ints from JNI
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    99
    static final int MODELESS = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   100
    static final int DOCUMENT_MODAL = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   101
    static final int APPLICATION_MODAL = 2;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   102
    static final int TOOLKIT_MODAL = 3;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
    // window style bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   105
    static final int _RESERVED_FOR_DATA = 1 << 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   106
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   107
    // corresponds to native style mask bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
    static final int DECORATED = 1 << 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
    static final int TEXTURED = 1 << 2;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   110
    static final int UNIFIED = 1 << 3;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   111
    static final int UTILITY = 1 << 4;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
    static final int HUD = 1 << 5;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
    static final int SHEET = 1 << 6;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
    static final int CLOSEABLE = 1 << 7;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   116
    static final int MINIMIZABLE = 1 << 8;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   117
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   118
    static final int RESIZABLE = 1 << 9; // both a style bit and prop bit
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   119
    static final int NONACTIVATING = 1 << 24;
17684
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   120
    static final int IS_DIALOG = 1 << 25;
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   121
    static final int IS_MODAL = 1 << 26;
25120
8b6a41c3752f 8042465: Applet menus not rendering when browser is full screen on Mac
dmarkov
parents: 23670
diff changeset
   122
    static final int IS_POPUP = 1 << 27;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   123
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   124
    static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   125
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   126
    // corresponds to method-based properties
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   127
    static final int HAS_SHADOW = 1 << 10;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   128
    static final int ZOOMABLE = 1 << 11;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   129
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   130
    static final int ALWAYS_ON_TOP = 1 << 15;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   131
    static final int HIDES_ON_DEACTIVATE = 1 << 17;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
    static final int DRAGGABLE_BACKGROUND = 1 << 19;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
    static final int DOCUMENT_MODIFIED = 1 << 21;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
    static final int FULLSCREENABLE = 1 << 23;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   136
    static final int _METHOD_PROP_BITMASK = RESIZABLE | HAS_SHADOW | ZOOMABLE | ALWAYS_ON_TOP | HIDES_ON_DEACTIVATE | DRAGGABLE_BACKGROUND | DOCUMENT_MODIFIED | FULLSCREENABLE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
    // corresponds to callback-based properties
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
    static final int SHOULD_BECOME_KEY = 1 << 12;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
    static final int SHOULD_BECOME_MAIN = 1 << 13;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
    static final int MODAL_EXCLUDED = 1 << 16;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   143
    static final int _CALLBACK_PROP_BITMASK = SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN | MODAL_EXCLUDED;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
    static int SET(final int bits, final int mask, final boolean value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
        if (value) return (bits | mask);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   147
        return bits & ~mask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   148
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   149
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   150
    static boolean IS(final int bits, final int mask) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   151
        return (bits & mask) != 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   152
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
25762
c4a3548120c6 8044862: Fix raw and unchecked lint warnings in macosx specific code
henryjen
parents: 25196
diff changeset
   154
    @SuppressWarnings({"unchecked", "rawtypes"})
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   155
    static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   156
        new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   157
            c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
        new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
            c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
        new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   163
            AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   164
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
        new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
            c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
        new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   169
            c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   170
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
        new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
            c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
        new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
            c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
        new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
            c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   179
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
        new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
            nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   182
        }},
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
        new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
            if (value == null || !(value instanceof java.io.File)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
                nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
                return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
            final String filename = ((java.io.File)value).getAbsolutePath();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
            nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
        }}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
    }) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
        public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
            Component root = SwingUtilities.getRoot(p);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
            if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
            return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
    };
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
    // Bounds of the native widget but in the Java coordinate system.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
    // In order to keep it up-to-date we will update them on
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
    // 1) setting native bounds via nativeSetBounds() call
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
    // 2) getting notification from the native level via deliverMoveResizeEvent()
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   204
    private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
15331
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
   205
    private volatile boolean isFullScreenMode;
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
   206
    private boolean isFullScreenAnimationOn;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
    private Window target;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
    private LWWindowPeer peer;
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   210
    protected CPlatformView contentView;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   211
    protected CPlatformWindow owner;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   212
    protected boolean visible = false; // visibility status from native perspective
12284
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   213
    private boolean undecorated; // initialized in getInitialStyleBits()
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   214
    private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
12664
91828a78446f 7156191: [macosx] Can't type into applet demos in Pivot
dcherepanov
parents: 12647
diff changeset
   215
    private CPlatformResponder responder;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   216
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   217
    public CPlatformWindow() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
        super(0, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   219
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   220
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   221
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
     * Delegate initialization (create native window and all the
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   223
     * related resources).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   224
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   225
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   226
    public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   227
        initializeBase(_target, _peer, _owner, new CPlatformView());
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   228
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   229
        final int styleBits = getInitialStyleBits();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   230
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   231
        responder = createPlatformResponder();
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   232
        contentView = createContentView();
12664
91828a78446f 7156191: [macosx] Can't type into applet demos in Pivot
dcherepanov
parents: 12647
diff changeset
   233
        contentView.initialize(peer, responder);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
19021
8a5340b88ee5 8017189: [macosx] AWT program menu disabled on Mac
serb
parents: 18763
diff changeset
   235
        final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
21272
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   236
        Rectangle bounds;
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   237
        if (!IS(DECORATED, styleBits)) {
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   238
            // For undecorated frames the move/resize event does not come if the frame is centered on the screen
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   239
            // so we need to set a stub location to force an initial move/resize. Real bounds would be set later.
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   240
            bounds = new Rectangle(0, 0, 1, 1);
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   241
        } else {
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   242
            bounds = _peer.constrainBounds(_target.getBounds());
aac4dd1cd15d 8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents: 21248
diff changeset
   243
        }
20457
ecb935d774a3 8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents: 20135
diff changeset
   244
        final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(),
ecb935d774a3 8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents: 20135
diff changeset
   245
                ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
        setPtr(nativeWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   247
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
        if (target instanceof javax.swing.RootPaneContainer) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
            final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
            if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
                public void propertyChange(final PropertyChangeEvent evt) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
                    CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
                    rootpane.removePropertyChangeListener("ancestor", this);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
            });
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
        validateSurface();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   261
    protected void initializeBase(Window target, LWWindowPeer peer, PlatformWindow owner, CPlatformView view) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   262
        this.peer = peer;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   263
        this.target = target;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   264
        if (owner instanceof CPlatformWindow) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   265
            this.owner = (CPlatformWindow)owner;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   266
        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   267
        this.contentView = view;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   268
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15331
diff changeset
   269
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   270
    protected CPlatformResponder createPlatformResponder() {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   271
        return new CPlatformResponder(peer, false);
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   272
    }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   273
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   274
    protected CPlatformView createContentView() {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   275
        return new CPlatformView();
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   276
    }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   277
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   278
    protected int getInitialStyleBits() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
        // defaults style bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
        int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
        if (isNativelyFocusableWindow()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
            styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
            styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   286
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
        final boolean isFrame = (target instanceof Frame);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   288
        final boolean isDialog = (target instanceof Dialog);
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   289
        final boolean isPopup = (target.getType() == Window.Type.POPUP);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
        if (isDialog) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
            styleBits = SET(styleBits, MINIMIZABLE, false);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   292
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   293
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
        // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   295
        {
12284
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   296
            this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   297
            if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   299
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
        // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
        {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
            final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
            styleBits = SET(styleBits, RESIZABLE, resizable);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
            if (!resizable) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
                styleBits = SET(styleBits, ZOOMABLE, false);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
        if (target.isAlwaysOnTop()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
            styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   313
        if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
            styleBits = SET(styleBits, MODAL_EXCLUDED, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   315
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
        // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   318
        if (isPopup) {
13234
9437e5985d73 7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents: 13233
diff changeset
   319
            styleBits = SET(styleBits, TEXTURED, false);
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   320
            // Popups in applets don't activate applet's process
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   321
            styleBits = SET(styleBits, NONACTIVATING, true);
25120
8b6a41c3752f 8042465: Applet menus not rendering when browser is full screen on Mac
dmarkov
parents: 23670
diff changeset
   322
            styleBits = SET(styleBits, IS_POPUP, true);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   323
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   324
12647
f9991bc4fdde 7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents: 12640
diff changeset
   325
        if (Window.Type.UTILITY.equals(target.getType())) {
f9991bc4fdde 7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents: 12640
diff changeset
   326
            styleBits = SET(styleBits, UTILITY, true);
f9991bc4fdde 7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents: 12640
diff changeset
   327
        }
f9991bc4fdde 7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents: 12640
diff changeset
   328
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
        if (target instanceof javax.swing.RootPaneContainer) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
            javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   331
            Object prop = null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
            prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
                styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
            if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   339
                prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   340
                if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
                    styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   342
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
            prop = rootpane.getClientProperty(WINDOW_STYLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   346
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
                if ("small".equals(prop))  {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
                    styleBits = SET(styleBits, UTILITY, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   349
                    if (target.isAlwaysOnTop() && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   350
                        styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   351
                    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
                if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
                if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
                if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   357
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
            prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   359
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
                styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   361
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   363
            prop = rootpane.getClientProperty(WINDOW_CLOSEABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
                styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
            prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
                styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
            prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
                styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
            prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
                styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
            prop = rootpane.getClientProperty(WINDOW_SHADOW);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
                styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   386
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   388
            prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   389
            if (prop != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   390
                styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
17684
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   394
        if (isDialog) {
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   395
            styleBits = SET(styleBits, IS_DIALOG, true);
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   396
            if (((Dialog) target).isModal()) {
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   397
                styleBits = SET(styleBits, IS_MODAL, true);
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   398
            }
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   399
        }
fc7f8dbe87b4 8010721: [macosx] In JDK7 the menu bar disappears when a Dialog is shown
vkarnauk
parents: 17151
diff changeset
   400
13234
9437e5985d73 7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents: 13233
diff changeset
   401
        peer.setTextured(IS(TEXTURED, styleBits));
9437e5985d73 7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents: 13233
diff changeset
   402
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
        return styleBits;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   404
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   406
    // this is the counter-point to -[CWindow _nativeSetStyleBit:]
14648
2ef7c7edb4b0 7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents: 14647
diff changeset
   407
    private void setStyleBits(final int mask, final boolean value) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   408
        nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   410
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   411
    private native void _toggleFullScreenMode(final long model);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   412
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
    public void toggleFullScreen() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
        _toggleFullScreenMode(getNSWindowPtr());
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   415
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
    public void setMenuBar(MenuBar mb) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
        final long nsWindowPtr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
        CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
        if (mbPeer != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
            nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel());
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
            nativeSetNSWindowMenuBar(nsWindowPtr, 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
    public void dispose() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
        if (owner != null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
            CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr());
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
        }
13143
31c70a66a053 7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents: 13009
diff changeset
   433
        contentView.dispose();
31c70a66a053 7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents: 13009
diff changeset
   434
        nativeDispose(getNSWindowPtr());
31c70a66a053 7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents: 13009
diff changeset
   435
        CPlatformWindow.super.dispose();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
    public FontMetrics getFontMetrics(Font f) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
        // TODO: not implemented
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
        (new RuntimeException("unimplemented")).printStackTrace();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
        return null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
    public Insets getInsets() {
21282
1bef38644939 8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
leonidr
parents: 21272
diff changeset
   447
        return nativeGetNSWindowInsets(getNSWindowPtr());
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
    public Point getLocationOnScreen() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
        return new Point(nativeBounds.x, nativeBounds.y);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
12816
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12664
diff changeset
   455
    @Override
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12664
diff changeset
   456
    public GraphicsDevice getGraphicsDevice() {
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   457
        return contentView.getGraphicsDevice();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
    public SurfaceData getScreenSurface() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
        // TODO: not implemented
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
        return null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
    public SurfaceData replaceSurfaceData() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
        return contentView.replaceSurfaceData();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
    public void setBounds(int x, int y, int w, int h) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
        nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   476
    private boolean isMaximized() {
20457
ecb935d774a3 8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents: 20135
diff changeset
   477
        return undecorated ? this.normalBounds != null
ecb935d774a3 8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents: 20135
diff changeset
   478
                : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   479
    }
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   480
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   481
    private void maximize() {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   482
        if (peer == null || isMaximized()) {
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   483
            return;
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   484
        }
12284
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   485
        if (!undecorated) {
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   486
            CWrapper.NSWindow.zoom(getNSWindowPtr());
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   487
        } else {
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   488
            deliverZoom(true);
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   489
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   490
            this.normalBounds = peer.getBounds();
18759
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   491
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   492
            GraphicsConfiguration config = getPeer().getGraphicsConfiguration();
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   493
            Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets();
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   494
            Rectangle toBounds = config.getBounds();
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   495
            setBounds(toBounds.x + i.left,
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   496
                      toBounds.y + i.top,
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   497
                      toBounds.width - i.left - i.right,
678de8e7eb93 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long)
pchelko
parents: 18295
diff changeset
   498
                      toBounds.height - i.top - i.bottom);
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   499
        }
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   500
    }
12284
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   501
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   502
    private void unmaximize() {
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   503
        if (!isMaximized()) {
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   504
            return;
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   505
        }
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   506
        if (!undecorated) {
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   507
            CWrapper.NSWindow.zoom(getNSWindowPtr());
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   508
        } else {
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   509
            deliverZoom(false);
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   510
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   511
            Rectangle toBounds = this.normalBounds;
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   512
            this.normalBounds = null;
12284
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   513
            setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   514
        }
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   515
    }
3f2477ebb708 7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents: 12177
diff changeset
   516
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   517
    public boolean isVisible() {
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   518
        return this.visible;
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   519
    }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   520
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   521
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   522
    public void setVisible(boolean visible) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   523
        final long nsWindowPtr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   524
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   525
        // Process parent-child relationship when hiding
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   526
        if (!visible) {
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   527
            // Unparent my children
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   528
            for (Window w : target.getOwnedWindows()) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   529
                WindowPeer p = (WindowPeer)w.getPeer();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   530
                if (p instanceof LWWindowPeer) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   531
                    CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   532
                    if (pw != null && pw.isVisible()) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   533
                        CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr());
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   534
                    }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   535
                }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   536
            }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   537
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   538
            // Unparent myself
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   539
            if (owner != null && owner.isVisible()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   540
                CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   541
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   542
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   543
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   544
        // Configure stuff
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   545
        updateIconImages();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   546
        updateFocusabilityForAutoRequestFocus(false);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   547
21248
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   548
        boolean wasMaximized = isMaximized();
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   549
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   550
        // Actually show or hide the window
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   551
        LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   552
        if (blocker == null || !visible) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   553
            // If it ain't blocked, or is being hidden, go regular way
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   554
            if (visible) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   555
                CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   556
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   557
                boolean isPopup = (target.getType() == Window.Type.POPUP);
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   558
                if (isPopup) {
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   559
                    // Popups in applets don't activate applet's process
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   560
                    CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   561
                } else {
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   562
                    CWrapper.NSWindow.orderFront(nsWindowPtr);
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   563
                }
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   564
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   565
                boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   566
                if (!isKeyWindow) {
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   567
                    CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   568
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   569
            } else {
27052
0b783c32e5c2 8041734: JFrame in full screen mode leaves empty workspace after close
serb
parents: 25859
diff changeset
   570
                // immediately hide the window
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   571
                CWrapper.NSWindow.orderOut(nsWindowPtr);
27052
0b783c32e5c2 8041734: JFrame in full screen mode leaves empty workspace after close
serb
parents: 25859
diff changeset
   572
                // process the close
0b783c32e5c2 8041734: JFrame in full screen mode leaves empty workspace after close
serb
parents: 25859
diff changeset
   573
                CWrapper.NSWindow.close(nsWindowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   574
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   575
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   576
            // otherwise, put it in a proper z-order
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   577
            CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   578
                    ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   579
        }
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   580
        this.visible = visible;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   581
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   582
        // Manage the extended state when showing
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   583
        if (visible) {
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   584
            // Apply the extended state as expected in shared code
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   585
            if (target instanceof Frame) {
21248
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   586
                if (!wasMaximized && isMaximized()) {
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   587
                    // setVisible could have changed the native maximized state
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   588
                    deliverZoom(true);
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   589
                } else {
23309
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   590
                    int frameState = ((Frame)target).getExtendedState();
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   591
                    if ((frameState & Frame.ICONIFIED) != 0) {
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   592
                        // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   593
                        frameState = Frame.ICONIFIED;
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   594
                    }
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   595
                    switch (frameState) {
21248
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   596
                        case Frame.ICONIFIED:
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   597
                            CWrapper.NSWindow.miniaturize(nsWindowPtr);
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   598
                            break;
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   599
                        case Frame.MAXIMIZED_BOTH:
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   600
                            maximize();
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   601
                            break;
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   602
                        default: // NORMAL
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   603
                            unmaximize(); // in case it was maximized, otherwise this is a no-op
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   604
                            break;
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   605
                    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   606
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   607
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   608
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   609
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
   610
        nativeSynthesizeMouseEnteredExitedEvents();
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12403
diff changeset
   611
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   612
        // Configure stuff #2
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   613
        updateFocusabilityForAutoRequestFocus(true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   614
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   615
        // Manage parent-child relationship when showing
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   616
        if (visible) {
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   617
            // Add myself as a child
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   618
            if (owner != null && owner.isVisible()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   619
                CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
23253
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
   620
                applyWindowLevel(target);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   621
            }
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   622
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   623
            // Add my own children to myself
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   624
            for (Window w : target.getOwnedWindows()) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   625
                WindowPeer p = (WindowPeer)w.getPeer();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   626
                if (p instanceof LWWindowPeer) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   627
                    CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   628
                    if (pw != null && pw.isVisible()) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   629
                        CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove);
23253
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
   630
                        pw.applyWindowLevel(w);
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   631
                    }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   632
                }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
   633
            }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   634
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   635
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   636
        // Deal with the blocker of the window being shown
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   637
        if (blocker != null && visible) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   638
            // Make sure the blocker is above its siblings
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   639
            ((CPlatformWindow)blocker.getPlatformWindow()).orderAboveSiblings();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   640
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   641
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   642
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   643
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   644
    public void setTitle(String title) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   645
        nativeSetNSWindowTitle(getNSWindowPtr(), title);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   646
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   647
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   648
    // Should be called on every window key property change.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   649
    @Override // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   650
    public void updateIconImages() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   651
        final long nsWindowPtr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   652
        final CImage cImage = getImageForTarget();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   653
        nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   654
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   655
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   656
    public long getNSWindowPtr() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   657
        final long nsWindowPtr = ptr;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   658
        if (nsWindowPtr == 0L) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 17684
diff changeset
   659
            if(logger.isLoggable(PlatformLogger.Level.FINE)) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   660
                logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   661
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   662
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   663
        return nsWindowPtr;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   664
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   665
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   666
    public SurfaceData getSurfaceData() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   667
        return contentView.getSurfaceData();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   668
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   669
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   670
    @Override  // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   671
    public void toBack() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   672
        final long nsWindowPtr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   673
        nativePushNSWindowToBack(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   674
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   675
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   676
    @Override  // PlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   677
    public void toFront() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   678
        final long nsWindowPtr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   679
        updateFocusabilityForAutoRequestFocus(false);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   680
        nativePushNSWindowToFront(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   681
        updateFocusabilityForAutoRequestFocus(true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   682
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   683
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   684
    @Override
14648
2ef7c7edb4b0 7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents: 14647
diff changeset
   685
    public void setResizable(final boolean resizable) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   686
        setStyleBits(RESIZABLE, resizable);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   687
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   688
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   689
    @Override
13550
648dd6fa0dee 7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents: 13235
diff changeset
   690
    public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
648dd6fa0dee 7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents: 13235
diff changeset
   691
        nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   692
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   693
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   694
    @Override
12176
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   695
    public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   696
        // Cross-app activation requests are not allowed.
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   697
        if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   698
            !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   699
        {
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   700
            focusLogger.fine("the app is inactive, so the request is rejected");
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   701
            return true;
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   702
        }
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   703
        return false;
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   704
    }
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   705
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   706
    @Override
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   707
    public boolean requestWindowFocus() {
12176
fc690f855620 7150345: [macosx] Can't type into applets
dcherepanov
parents: 12047
diff changeset
   708
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   709
        long ptr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   710
        if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   711
            CWrapper.NSWindow.makeMainWindow(ptr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   712
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   713
        CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   714
        return true;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   715
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   716
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   717
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   718
    public boolean isActive() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   719
        long ptr = getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   720
        return CWrapper.NSWindow.isKeyWindow(ptr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   721
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   722
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   723
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   724
    public void updateFocusableWindowState() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   725
        final boolean isFocusable = isNativelyFocusableWindow();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   726
        setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   727
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   728
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   729
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   730
    public Graphics transformGraphics(Graphics g) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   731
        // is this where we can inject a transform for HiDPI?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   732
        return g;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   733
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   734
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   735
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   736
    public void setAlwaysOnTop(boolean isAlwaysOnTop) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   737
        setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   738
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   739
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
   740
    public PlatformWindow getTopmostPlatformWindowUnderMouse(){
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
   741
        return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
   742
    }
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13550
diff changeset
   743
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   744
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   745
    public void setOpacity(float opacity) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   746
        CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   747
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   748
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   749
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   750
    public void setOpaque(boolean isOpaque) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   751
        CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
25196
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   752
        boolean isTextured = (peer == null) ? false : peer.isTextured();
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   753
        if (!isTextured) {
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   754
            if (!isOpaque) {
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   755
                CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0);
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   756
            } else if (peer != null) {
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   757
                Color color = peer.getBackground();
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   758
                if (color != null) {
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   759
                    int rgb = color.getRGB();
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   760
                    CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb);
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   761
                }
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   762
            }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   763
        }
13233
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   764
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   765
        //This is a temporary workaround. Looks like after 7124236 will be fixed
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   766
        //the correct place for invalidateShadow() is CGLayer.drawInCGLContext.
25196
48d9cfe3f138 8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents: 25120
diff changeset
   767
        SwingUtilities.invokeLater(this::invalidateShadow);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   768
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   769
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   770
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   771
    public void enterFullScreenMode() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   772
        isFullScreenMode = true;
21282
1bef38644939 8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
leonidr
parents: 21272
diff changeset
   773
        nativeEnterFullScreenMode(getNSWindowPtr());
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   774
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   775
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   776
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   777
    public void exitFullScreenMode() {
21282
1bef38644939 8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
leonidr
parents: 21272
diff changeset
   778
        nativeExitFullScreenMode(getNSWindowPtr());
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   779
        isFullScreenMode = false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   780
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   781
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   782
    @Override
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   783
    public boolean isFullScreenMode() {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   784
        return isFullScreenMode;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   785
    }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   786
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   787
    @Override
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   788
    public void setWindowState(int windowState) {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   789
        if (peer == null || !peer.isVisible()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   790
            // setVisible() applies the state
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   791
            return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   792
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   793
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   794
        int prevWindowState = peer.getState();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   795
        if (prevWindowState == windowState) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   796
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   797
        final long nsWindowPtr = getNSWindowPtr();
23309
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   798
        if ((windowState & Frame.ICONIFIED) != 0) {
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   799
            // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   800
            windowState = Frame.ICONIFIED;
f5604dd7b274 8032078: [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED|MAXIMIZED_BOTH
alitvinov
parents: 23253
diff changeset
   801
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   802
        switch (windowState) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   803
            case Frame.ICONIFIED:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   804
                if (prevWindowState == Frame.MAXIMIZED_BOTH) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   805
                    // let's return into the normal states first
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   806
                    // the zoom call toggles between the normal and the max states
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   807
                    unmaximize();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   808
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   809
                CWrapper.NSWindow.miniaturize(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   810
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   811
            case Frame.MAXIMIZED_BOTH:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   812
                if (prevWindowState == Frame.ICONIFIED) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   813
                    // let's return into the normal states first
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   814
                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   815
                }
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   816
                maximize();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   817
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   818
            case Frame.NORMAL:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   819
                if (prevWindowState == Frame.ICONIFIED) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   820
                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   821
                } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   822
                    // the zoom call toggles between the normal and the max states
13235
d51095485728 7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents: 13234
diff changeset
   823
                    unmaximize();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   824
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   825
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   826
            default:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   827
                throw new RuntimeException("Unknown window state: " + windowState);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   828
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   829
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   830
        // NOTE: the SWP.windowState field gets updated to the newWindowState
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   831
        //       value when the native notification comes to us
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   832
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   833
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   834
    @Override
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   835
    public void setModalBlocked(boolean blocked) {
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   836
        if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   837
            return;
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   838
        }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   839
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   840
        nativeSetEnabled(getNSWindowPtr(), !blocked);
20135
f6edca5afe49 8008728: [macosx] Swing. JDialog. Modal dialog goes to background
alexsch
parents: 19179
diff changeset
   841
        checkBlockingAndOrder();
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   842
    }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   843
13233
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   844
    public final void invalidateShadow(){
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   845
        nativeRevalidateNSWindowShadow(getNSWindowPtr());
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   846
    }
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
   847
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   848
    // ----------------------------------------------------------------------
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   849
    //                          UTILITY METHODS
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   850
    // ----------------------------------------------------------------------
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   851
19179
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   852
    /**
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   853
     * Find image to install into Title or into Application icon. First try
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   854
     * icons installed for toplevel. Null is returned, if there is no icon and
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   855
     * default Duke image should be used.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   856
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   857
    private CImage getImageForTarget() {
19179
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   858
        CImage icon = null;
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   859
        try {
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   860
            icon = CImage.getCreator().createFromImages(target.getIconImages());
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   861
        } catch (Exception ignored) {
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   862
            // Perhaps the icon passed into Java is broken. Skipping this icon.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   863
        }
19179
b59142223aac 7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
serb
parents: 19021
diff changeset
   864
        return icon;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   865
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   866
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   867
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   868
     * Returns LWWindowPeer associated with this delegate.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   869
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   870
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   871
    public LWWindowPeer getPeer() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   872
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   873
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   874
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   875
    @Override
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   876
    public boolean isUnderMouse() {
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   877
        return contentView.isUnderMouse();
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   878
    }
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14651
diff changeset
   879
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   880
    public CPlatformView getContentView() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   881
        return contentView;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   882
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   883
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   884
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   885
    public long getLayerPtr() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   886
        return contentView.getWindowLayerPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   887
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   888
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   889
    private void validateSurface() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   890
        SurfaceData surfaceData = getSurfaceData();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   891
        if (surfaceData instanceof CGLSurfaceData) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   892
            ((CGLSurfaceData)surfaceData).validate();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   893
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   894
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   895
16840
64446d4710c4 8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents: 16710
diff changeset
   896
    void flushBuffers() {
64446d4710c4 8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents: 16710
diff changeset
   897
        if (isVisible() && !nativeBounds.isEmpty() && !isFullScreenMode) {
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   898
            try {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   899
                LWCToolkit.invokeAndWait(new Runnable() {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   900
                    @Override
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   901
                    public void run() {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   902
                        //Posting an empty to flush the EventQueue without blocking the main thread
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   903
                    }
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   904
                }, target);
21246
9d1752954b0e 8025588: [macosx] Frozen AppKit thread in 7u40
pchelko
parents: 20457
diff changeset
   905
            } catch (InvocationTargetException e) {
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   906
                e.printStackTrace();
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15983
diff changeset
   907
            }
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   908
        }
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   909
    }
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   910
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   911
    /**
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   912
     * Helper method to get a pointer to the native view from the PlatformWindow.
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   913
     */
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   914
    static long getNativeViewPtr(PlatformWindow platformWindow) {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   915
        long nativePeer = 0L;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   916
        if (platformWindow instanceof CPlatformWindow) {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   917
            nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   918
        } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   919
            nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   920
        }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   921
        return nativePeer;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   922
    }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents: 15985
diff changeset
   923
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   924
    /*************************************************************
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   925
     * Callbacks from the AWTWindow and AWTView objc classes.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   926
     *************************************************************/
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14306
diff changeset
   927
    private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   928
        // Fix for 7150349: ingore "gained" notifications when the app is inactive.
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   929
        if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   930
            focusLogger.fine("the app is inactive, so the notification is ignored");
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   931
            return;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12176
diff changeset
   932
        }
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14306
diff changeset
   933
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14306
diff changeset
   934
        LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14306
diff changeset
   935
        responder.handleWindowFocusEvent(gained, oppositePeer);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   936
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   937
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   938
    protected void deliverMoveResizeEvent(int x, int y, int width, int height,
14651
f032406c1e48 8002308: [macosx] 7198229 should be applied to the user action only
serb
parents: 14648
diff changeset
   939
                                        boolean byUser) {
21248
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   940
        checkZoom();
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   941
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   942
        final Rectangle oldB = nativeBounds;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   943
        nativeBounds = new Rectangle(x, y, width, height);
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   944
        if (peer != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   945
            peer.notifyReshape(x, y, width, height);
18762
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   946
            // System-dependent appearance optimization.
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   947
            if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   948
                    || isFullScreenAnimationOn) {
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   949
                flushBuffers();
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   950
            }
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 14165
diff changeset
   951
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   952
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   953
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   954
    private void deliverWindowClosingEvent() {
18762
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   955
        if (peer != null && peer.getBlocker() == null) {
eb4a26b2cd7f 8020298: [macosx] Incorrect merge in the lwawt code
serb
parents: 18759
diff changeset
   956
            peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   957
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   958
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   959
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   960
    private void deliverIconify(final boolean iconify) {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   961
        if (peer != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   962
            peer.notifyIconify(iconify);
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   963
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   964
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   965
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   966
    private void deliverZoom(final boolean isZoomed) {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   967
        if (peer != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   968
            peer.notifyZoom(isZoomed);
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   969
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   970
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   971
21248
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   972
    private void checkZoom() {
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   973
        if (target instanceof Frame && isVisible()) {
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   974
            Frame targetFrame = (Frame)target;
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   975
            if (targetFrame.getExtendedState() != Frame.MAXIMIZED_BOTH && isMaximized()) {
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   976
                deliverZoom(true);
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   977
            } else if (targetFrame.getExtendedState() == Frame.MAXIMIZED_BOTH && !isMaximized()) {
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   978
                deliverZoom(false);
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   979
            }
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   980
        }
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   981
    }
aa402f9056a5 8026143: [macosx] Maximized state could be inconsistent between peer and frame
pchelko
parents: 21246
diff changeset
   982
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   983
    private void deliverNCMouseDown() {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   984
        if (peer != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   985
            peer.notifyNCMouseDown();
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   986
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   987
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   988
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   989
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   990
     * Our focus model is synthetic and only non-simple window
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   991
     * may become natively focusable window.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   992
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   993
    private boolean isNativelyFocusableWindow() {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   994
        if (peer == null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   995
            return false;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   996
        }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
   997
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   998
        return !peer.isSimpleWindow() && target.getFocusableWindowState();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   999
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1000
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1001
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1002
     * An utility method for the support of the auto request focus.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1003
     * Updates the focusable state of the window under certain
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1004
     * circumstances.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1005
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1006
    private void updateFocusabilityForAutoRequestFocus(boolean isFocusable) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1007
        if (target.isAutoRequestFocus() || !isNativelyFocusableWindow()) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1008
        setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1009
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1010
20135
f6edca5afe49 8008728: [macosx] Swing. JDialog. Modal dialog goes to background
alexsch
parents: 19179
diff changeset
  1011
    private boolean checkBlockingAndOrder() {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15331
diff changeset
  1012
        LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1013
        if (blocker == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1014
            return false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1015
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1016
15328
65d946035fa9 8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents: 15322
diff changeset
  1017
        if (blocker instanceof CPrinterDialogPeer) {
65d946035fa9 8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents: 15322
diff changeset
  1018
            return true;
65d946035fa9 8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents: 15322
diff changeset
  1019
        }
65d946035fa9 8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents: 15322
diff changeset
  1020
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1021
        CPlatformWindow pWindow = (CPlatformWindow)blocker.getPlatformWindow();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1022
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1023
        pWindow.orderAboveSiblings();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1024
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1025
        final long nsWindowPtr = pWindow.getNSWindowPtr();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1026
        CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1027
        CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1028
        CWrapper.NSWindow.makeMainWindow(nsWindowPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1029
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1030
        return true;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1031
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1032
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1033
    private void orderAboveSiblings() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1034
        if (owner == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1035
            return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1036
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1037
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1038
        // NOTE: the logic will fail if we have a hierarchy like:
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1039
        //       visible root owner
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1040
        //          invisible owner
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1041
        //              visible dialog
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1042
        // However, this is an unlikely scenario for real life apps
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1043
        if (owner.isVisible()) {
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1044
            // Recursively pop up the windows from the very bottom so that only
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1045
            // the very top-most one becomes the main window
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1046
            owner.orderAboveSiblings();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1047
12286
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1048
            // Order the window to front of the stack of child windows
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1049
            final long nsWindowSelfPtr = getNSWindowPtr();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1050
            final long nsWindowOwnerPtr = owner.getNSWindowPtr();
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1051
            CWrapper.NSWindow.removeChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr);
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1052
            CWrapper.NSWindow.addChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove);
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1053
        }
9e40486e227e 7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents: 12284
diff changeset
  1054
23253
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1055
        applyWindowLevel(target);
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1056
    }
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1057
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1058
    protected void applyWindowLevel(Window target) {
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1059
        if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1060
            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
23253
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1061
        } else if (target.getType() == Window.Type.POPUP) {
55425a62017f 7154841: [macosx] Popups appear behind taskbar
pchelko
parents: 21282
diff changeset
  1062
            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1063
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1064
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1065
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1066
    // ----------------------------------------------------------------------
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1067
    //                          NATIVE CALLBACKS
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1068
    // ----------------------------------------------------------------------
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1069
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1070
    private void windowDidBecomeMain() {
20135
f6edca5afe49 8008728: [macosx] Swing. JDialog. Modal dialog goes to background
alexsch
parents: 19179
diff changeset
  1071
        if (checkBlockingAndOrder()) return;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1072
        // If it's not blocked, make sure it's above its siblings
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1073
        orderAboveSiblings();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1074
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1075
15331
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1076
    private void windowWillEnterFullScreen() {
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1077
        isFullScreenAnimationOn = true;
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1078
    }
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1079
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1080
    private void windowDidEnterFullScreen() {
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1081
        isFullScreenAnimationOn = false;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1082
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1083
15331
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1084
    private void windowWillExitFullScreen() {
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1085
        isFullScreenAnimationOn = true;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1086
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1087
15331
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1088
    private void windowDidExitFullScreen() {
410070becfef 8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents: 15328
diff changeset
  1089
        isFullScreenAnimationOn = false;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1090
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1091
}