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