author | ant |
Fri, 22 Feb 2013 15:13:13 +0400 | |
changeset 15983 | 26a673dec5b2 |
parent 15331 | 410070becfef |
child 15985 | b9e25a486549 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|
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.*; |
33 |
import java.util.List; |
|
34 |
||
35 |
import javax.swing.*; |
|
36 |
||
37 |
import sun.awt.*; |
|
38 |
import sun.java2d.SurfaceData; |
|
39 |
import sun.java2d.opengl.CGLSurfaceData; |
|
40 |
import sun.lwawt.*; |
|
41 |
import sun.util.logging.PlatformLogger; |
|
42 |
||
43 |
import com.apple.laf.*; |
|
44 |
import com.apple.laf.ClientPropertyApplicator.Property; |
|
45 |
import com.sun.awt.AWTUtilities; |
|
46 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
47 |
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow { |
12047 | 48 |
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h); |
49 |
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data); |
|
50 |
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr); |
|
51 |
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr); |
|
52 |
private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h); |
|
53 |
private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH); |
|
54 |
private static native void nativePushNSWindowToBack(long nsWindowPtr); |
|
55 |
private static native void nativePushNSWindowToFront(long nsWindowPtr); |
|
56 |
private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title); |
|
57 |
private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr); |
|
58 |
private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage); |
|
59 |
private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename); |
|
12640 | 60 |
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
|
61 |
private static native void nativeSynthesizeMouseEnteredExitedEvents(); |
13009
f409e6ef0185
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents:
12816
diff
changeset
|
62 |
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
|
63 |
private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse(); |
12047 | 64 |
|
65 |
// Loger to report issues happened during execution but that do not affect functionality |
|
66 |
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow"); |
|
12176 | 67 |
private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow"); |
12047 | 68 |
|
69 |
// for client properties |
|
70 |
public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook"; |
|
71 |
public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground"; |
|
72 |
||
73 |
public static final String WINDOW_ALPHA = "Window.alpha"; |
|
74 |
public static final String WINDOW_SHADOW = "Window.shadow"; |
|
75 |
||
76 |
public static final String WINDOW_STYLE = "Window.style"; |
|
77 |
public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow"; |
|
78 |
||
79 |
public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified"; |
|
80 |
public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile"; |
|
81 |
||
82 |
public static final String WINDOW_CLOSEABLE = "Window.closeable"; |
|
83 |
public static final String WINDOW_MINIMIZABLE = "Window.minimizable"; |
|
84 |
public static final String WINDOW_ZOOMABLE = "Window.zoomable"; |
|
85 |
public static final String WINDOW_HIDES_ON_DEACTIVATE="Window.hidesOnDeactivate"; |
|
86 |
||
87 |
public static final String WINDOW_DOC_MODAL_SHEET = "apple.awt.documentModalSheet"; |
|
88 |
public static final String WINDOW_FADE_DELEGATE = "apple.awt._windowFadeDelegate"; |
|
89 |
public static final String WINDOW_FADE_IN = "apple.awt._windowFadeIn"; |
|
90 |
public static final String WINDOW_FADE_OUT = "apple.awt._windowFadeOut"; |
|
91 |
public static final String WINDOW_FULLSCREENABLE = "apple.awt.fullscreenable"; |
|
92 |
||
93 |
||
94 |
// Yeah, I know. But it's easier to deal with ints from JNI |
|
95 |
static final int MODELESS = 0; |
|
96 |
static final int DOCUMENT_MODAL = 1; |
|
97 |
static final int APPLICATION_MODAL = 2; |
|
98 |
static final int TOOLKIT_MODAL = 3; |
|
99 |
||
100 |
// window style bits |
|
101 |
static final int _RESERVED_FOR_DATA = 1 << 0; |
|
102 |
||
103 |
// corresponds to native style mask bits |
|
104 |
static final int DECORATED = 1 << 1; |
|
105 |
static final int TEXTURED = 1 << 2; |
|
106 |
static final int UNIFIED = 1 << 3; |
|
107 |
static final int UTILITY = 1 << 4; |
|
108 |
static final int HUD = 1 << 5; |
|
109 |
static final int SHEET = 1 << 6; |
|
110 |
||
111 |
static final int CLOSEABLE = 1 << 7; |
|
112 |
static final int MINIMIZABLE = 1 << 8; |
|
113 |
||
114 |
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
|
115 |
static final int NONACTIVATING = 1 << 24; |
12047 | 116 |
|
117 |
static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE; |
|
118 |
||
119 |
// corresponds to method-based properties |
|
120 |
static final int HAS_SHADOW = 1 << 10; |
|
121 |
static final int ZOOMABLE = 1 << 11; |
|
122 |
||
123 |
static final int ALWAYS_ON_TOP = 1 << 15; |
|
124 |
static final int HIDES_ON_DEACTIVATE = 1 << 17; |
|
125 |
static final int DRAGGABLE_BACKGROUND = 1 << 19; |
|
126 |
static final int DOCUMENT_MODIFIED = 1 << 21; |
|
127 |
static final int FULLSCREENABLE = 1 << 23; |
|
128 |
||
129 |
static final int _METHOD_PROP_BITMASK = RESIZABLE | HAS_SHADOW | ZOOMABLE | ALWAYS_ON_TOP | HIDES_ON_DEACTIVATE | DRAGGABLE_BACKGROUND | DOCUMENT_MODIFIED | FULLSCREENABLE; |
|
130 |
||
131 |
// corresponds to callback-based properties |
|
132 |
static final int SHOULD_BECOME_KEY = 1 << 12; |
|
133 |
static final int SHOULD_BECOME_MAIN = 1 << 13; |
|
134 |
static final int MODAL_EXCLUDED = 1 << 16; |
|
135 |
||
136 |
static final int _CALLBACK_PROP_BITMASK = SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN | MODAL_EXCLUDED; |
|
137 |
||
138 |
static int SET(final int bits, final int mask, final boolean value) { |
|
139 |
if (value) return (bits | mask); |
|
140 |
return bits & ~mask; |
|
141 |
} |
|
142 |
||
143 |
static boolean IS(final int bits, final int mask) { |
|
144 |
return (bits & mask) != 0; |
|
145 |
} |
|
146 |
||
147 |
@SuppressWarnings("unchecked") |
|
148 |
static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] { |
|
149 |
new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
150 |
c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString())); |
|
151 |
}}, |
|
152 |
new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
153 |
c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString())); |
|
154 |
}}, |
|
155 |
new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
156 |
AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString())); |
|
157 |
}}, |
|
158 |
new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
159 |
c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString())); |
|
160 |
}}, |
|
161 |
new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
162 |
c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString())); |
|
163 |
}}, |
|
164 |
new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
165 |
c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString())); |
|
166 |
}}, |
|
167 |
new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
168 |
c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString())); |
|
169 |
}}, |
|
170 |
new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
171 |
c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString())); |
|
172 |
}}, |
|
173 |
new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
174 |
nativeRevalidateNSWindowShadow(c.getNSWindowPtr()); |
|
175 |
}}, |
|
176 |
new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
|
177 |
if (value == null || !(value instanceof java.io.File)) { |
|
178 |
nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null); |
|
179 |
return; |
|
180 |
} |
|
181 |
||
182 |
final String filename = ((java.io.File)value).getAbsolutePath(); |
|
183 |
nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename); |
|
184 |
}} |
|
185 |
}) { |
|
186 |
public CPlatformWindow convertJComponentToTarget(final JRootPane p) { |
|
187 |
Component root = SwingUtilities.getRoot(p); |
|
188 |
if (root == null || (LWWindowPeer)root.getPeer() == null) return null; |
|
189 |
return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow(); |
|
190 |
} |
|
191 |
}; |
|
192 |
||
193 |
// Bounds of the native widget but in the Java coordinate system. |
|
194 |
// In order to keep it up-to-date we will update them on |
|
195 |
// 1) setting native bounds via nativeSetBounds() call |
|
196 |
// 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
|
197 |
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
|
198 |
private volatile boolean isFullScreenMode; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
199 |
private boolean isFullScreenAnimationOn; |
12047 | 200 |
|
201 |
private Window target; |
|
202 |
private LWWindowPeer peer; |
|
203 |
private CPlatformView contentView; |
|
204 |
private CPlatformWindow owner; |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
205 |
private 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
|
206 |
private boolean undecorated; // initialized in getInitialStyleBits() |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
207 |
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
|
208 |
private CPlatformResponder responder; |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
209 |
private volatile boolean zoomed = false; // from native perspective |
12047 | 210 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
211 |
public CPlatformWindow() { |
12047 | 212 |
super(0, true); |
213 |
} |
|
214 |
||
215 |
/* |
|
216 |
* Delegate initialization (create native window and all the |
|
217 |
* related resources). |
|
218 |
*/ |
|
219 |
@Override // PlatformWindow |
|
220 |
public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) { |
|
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
221 |
initializeBase(_target, _peer, _owner, new CPlatformView()); |
12047 | 222 |
|
223 |
final int styleBits = getInitialStyleBits(); |
|
224 |
||
225 |
// TODO: handle these misc properties |
|
226 |
final long parentNSWindowPtr = (owner != null ? owner.getNSWindowPtr() : 0); |
|
227 |
String warningString = target.getWarningString(); |
|
228 |
||
12664
91828a78446f
7156191: [macosx] Can't type into applet demos in Pivot
dcherepanov
parents:
12647
diff
changeset
|
229 |
responder = new CPlatformResponder(peer, false); |
91828a78446f
7156191: [macosx] Can't type into applet demos in Pivot
dcherepanov
parents:
12647
diff
changeset
|
230 |
contentView.initialize(peer, responder); |
12047 | 231 |
|
232 |
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0); |
|
233 |
setPtr(nativeWindowPtr); |
|
234 |
||
235 |
// TODO: implement on top of JObjC bridged class |
|
236 |
// NSWindow window = JObjC.getInstance().AppKit().NSWindow().getInstance(nativeWindowPtr, JObjCRuntime.getInstance()); |
|
237 |
||
238 |
if (target instanceof javax.swing.RootPaneContainer) { |
|
239 |
final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); |
|
240 |
if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() { |
|
241 |
public void propertyChange(final PropertyChangeEvent evt) { |
|
242 |
CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane); |
|
243 |
rootpane.removePropertyChangeListener("ancestor", this); |
|
244 |
} |
|
245 |
}); |
|
246 |
} |
|
247 |
||
248 |
validateSurface(); |
|
249 |
} |
|
250 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
251 |
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
|
252 |
this.peer = peer; |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
253 |
this.target = target; |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
254 |
if (owner instanceof CPlatformWindow) { |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
255 |
this.owner = (CPlatformWindow)owner; |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
256 |
} |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
257 |
this.contentView = view; |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
258 |
} |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
259 |
|
14648
2ef7c7edb4b0
7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents:
14647
diff
changeset
|
260 |
private int getInitialStyleBits() { |
12047 | 261 |
// defaults style bits |
262 |
int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; |
|
263 |
||
264 |
if (isNativelyFocusableWindow()) { |
|
265 |
styleBits = SET(styleBits, SHOULD_BECOME_KEY, true); |
|
266 |
styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true); |
|
267 |
} |
|
268 |
||
269 |
final boolean isFrame = (target instanceof Frame); |
|
270 |
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
|
271 |
final boolean isPopup = (target.getType() == Window.Type.POPUP); |
12047 | 272 |
if (isDialog) { |
273 |
styleBits = SET(styleBits, MINIMIZABLE, false); |
|
274 |
} |
|
275 |
||
276 |
// Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated. |
|
277 |
{ |
|
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
278 |
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
|
279 |
if (this.undecorated) styleBits = SET(styleBits, DECORATED, false); |
12047 | 280 |
} |
281 |
||
282 |
// Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable |
|
283 |
{ |
|
284 |
final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); |
|
285 |
styleBits = SET(styleBits, RESIZABLE, resizable); |
|
286 |
if (!resizable) { |
|
287 |
styleBits = SET(styleBits, ZOOMABLE, false); |
|
288 |
} |
|
289 |
} |
|
290 |
||
291 |
if (target.isAlwaysOnTop()) { |
|
292 |
styleBits = SET(styleBits, ALWAYS_ON_TOP, true); |
|
293 |
} |
|
294 |
||
295 |
if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) { |
|
296 |
styleBits = SET(styleBits, MODAL_EXCLUDED, true); |
|
297 |
} |
|
298 |
||
299 |
// 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
|
300 |
if (isPopup) { |
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
301 |
styleBits = SET(styleBits, TEXTURED, false); |
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
302 |
// 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
|
303 |
styleBits = SET(styleBits, NONACTIVATING, true); |
12047 | 304 |
} |
305 |
||
12647
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
306 |
if (Window.Type.UTILITY.equals(target.getType())) { |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
307 |
styleBits = SET(styleBits, UTILITY, true); |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
308 |
} |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
309 |
|
12047 | 310 |
if (target instanceof javax.swing.RootPaneContainer) { |
311 |
javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); |
|
312 |
Object prop = null; |
|
313 |
||
314 |
prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK); |
|
315 |
if (prop != null) { |
|
316 |
styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString())); |
|
317 |
} |
|
318 |
||
319 |
if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) { |
|
320 |
prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET); |
|
321 |
if (prop != null) { |
|
322 |
styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString())); |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
prop = rootpane.getClientProperty(WINDOW_STYLE); |
|
327 |
if (prop != null) { |
|
328 |
if ("small".equals(prop)) { |
|
329 |
styleBits = SET(styleBits, UTILITY, true); |
|
330 |
if (target.isAlwaysOnTop() && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) { |
|
331 |
styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true); |
|
332 |
} |
|
333 |
} |
|
334 |
if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true); |
|
335 |
if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true); |
|
336 |
if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true); |
|
337 |
} |
|
338 |
||
339 |
prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE); |
|
340 |
if (prop != null) { |
|
341 |
styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString())); |
|
342 |
} |
|
343 |
||
344 |
prop = rootpane.getClientProperty(WINDOW_CLOSEABLE); |
|
345 |
if (prop != null) { |
|
346 |
styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString())); |
|
347 |
} |
|
348 |
||
349 |
prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE); |
|
350 |
if (prop != null) { |
|
351 |
styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString())); |
|
352 |
} |
|
353 |
||
354 |
prop = rootpane.getClientProperty(WINDOW_ZOOMABLE); |
|
355 |
if (prop != null) { |
|
356 |
styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString())); |
|
357 |
} |
|
358 |
||
359 |
prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE); |
|
360 |
if (prop != null) { |
|
361 |
styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString())); |
|
362 |
} |
|
363 |
||
364 |
prop = rootpane.getClientProperty(WINDOW_SHADOW); |
|
365 |
if (prop != null) { |
|
366 |
styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString())); |
|
367 |
} |
|
368 |
||
369 |
prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND); |
|
370 |
if (prop != null) { |
|
371 |
styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString())); |
|
372 |
} |
|
373 |
} |
|
374 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
375 |
peer.setTextured(IS(TEXTURED, styleBits)); |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
376 |
|
12047 | 377 |
return styleBits; |
378 |
} |
|
379 |
||
380 |
// this is the counter-point to -[CWindow _nativeSetStyleBit:] |
|
14648
2ef7c7edb4b0
7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents:
14647
diff
changeset
|
381 |
private void setStyleBits(final int mask, final boolean value) { |
12047 | 382 |
nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0); |
383 |
} |
|
384 |
||
385 |
private native void _toggleFullScreenMode(final long model); |
|
386 |
||
387 |
public void toggleFullScreen() { |
|
388 |
_toggleFullScreenMode(getNSWindowPtr()); |
|
389 |
} |
|
390 |
||
391 |
@Override // PlatformWindow |
|
392 |
public void setMenuBar(MenuBar mb) { |
|
393 |
final long nsWindowPtr = getNSWindowPtr(); |
|
394 |
CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb); |
|
395 |
if (mbPeer != null) { |
|
396 |
nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel()); |
|
397 |
} else { |
|
398 |
nativeSetNSWindowMenuBar(nsWindowPtr, 0); |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
@Override // PlatformWindow |
|
403 |
public void dispose() { |
|
404 |
if (owner != null) { |
|
405 |
CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr()); |
|
406 |
} |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
407 |
contentView.dispose(); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
408 |
nativeDispose(getNSWindowPtr()); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
409 |
CPlatformWindow.super.dispose(); |
12047 | 410 |
} |
411 |
||
412 |
@Override // PlatformWindow |
|
413 |
public FontMetrics getFontMetrics(Font f) { |
|
414 |
// TODO: not implemented |
|
415 |
(new RuntimeException("unimplemented")).printStackTrace(); |
|
416 |
return null; |
|
417 |
} |
|
418 |
||
419 |
@Override // PlatformWindow |
|
420 |
public Insets getInsets() { |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
421 |
if (!isFullScreenMode) { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
422 |
return nativeGetNSWindowInsets(getNSWindowPtr()); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
423 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
424 |
return new Insets(0, 0, 0, 0); |
12047 | 425 |
} |
426 |
||
427 |
@Override // PlatformWindow |
|
428 |
public Point getLocationOnScreen() { |
|
429 |
return new Point(nativeBounds.x, nativeBounds.y); |
|
430 |
} |
|
431 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12664
diff
changeset
|
432 |
@Override |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12664
diff
changeset
|
433 |
public GraphicsDevice getGraphicsDevice() { |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
434 |
return contentView.getGraphicsDevice(); |
12047 | 435 |
} |
436 |
||
437 |
@Override // PlatformWindow |
|
438 |
public SurfaceData getScreenSurface() { |
|
439 |
// TODO: not implemented |
|
440 |
return null; |
|
441 |
} |
|
442 |
||
443 |
@Override // PlatformWindow |
|
444 |
public SurfaceData replaceSurfaceData() { |
|
445 |
return contentView.replaceSurfaceData(); |
|
446 |
} |
|
447 |
||
448 |
@Override // PlatformWindow |
|
449 |
public void setBounds(int x, int y, int w, int h) { |
|
450 |
// assert CThreading.assertEventQueue(); |
|
451 |
nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h); |
|
452 |
} |
|
453 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
454 |
private boolean isMaximized() { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
455 |
return undecorated ? this.normalBounds != null : zoomed; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
456 |
} |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
457 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
458 |
private void maximize() { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
459 |
if (isMaximized()) { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
460 |
return; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
461 |
} |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
462 |
if (!undecorated) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
463 |
zoomed = true; |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
464 |
CWrapper.NSWindow.zoom(getNSWindowPtr()); |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
465 |
} else { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
466 |
deliverZoom(true); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
467 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
468 |
this.normalBounds = peer.getBounds(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
469 |
long screen = CWrapper.NSWindow.screen(getNSWindowPtr()); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
470 |
Rectangle toBounds = CWrapper.NSScreen.visibleFrame(screen).getBounds(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
471 |
// Flip the y coordinate |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
472 |
Rectangle frame = CWrapper.NSScreen.frame(screen).getBounds(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
473 |
toBounds.y = frame.height - toBounds.y - toBounds.height; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
474 |
setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
475 |
} |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
476 |
} |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
477 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
478 |
private void unmaximize() { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
479 |
if (!isMaximized()) { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
480 |
return; |
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 |
if (!undecorated) { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
483 |
zoomed = false; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
484 |
CWrapper.NSWindow.zoom(getNSWindowPtr()); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
485 |
} else { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
486 |
deliverZoom(false); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
487 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
488 |
Rectangle toBounds = this.normalBounds; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
489 |
this.normalBounds = null; |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
490 |
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
|
491 |
} |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
492 |
} |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
493 |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
494 |
private boolean isVisible() { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
495 |
return this.visible; |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
496 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
497 |
|
12047 | 498 |
@Override // PlatformWindow |
499 |
public void setVisible(boolean visible) { |
|
500 |
final long nsWindowPtr = getNSWindowPtr(); |
|
501 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
502 |
// 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
|
503 |
if (!visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
504 |
// Unparent my children |
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
505 |
for (Window w : target.getOwnedWindows()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
506 |
WindowPeer p = (WindowPeer)w.getPeer(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
507 |
if (p instanceof LWWindowPeer) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
508 |
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
|
509 |
if (pw != null && pw.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
510 |
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
|
511 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
512 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
513 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
514 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
515 |
// Unparent myself |
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
516 |
if (owner != null && owner.isVisible()) { |
12047 | 517 |
CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr); |
518 |
} |
|
519 |
} |
|
520 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
521 |
// Configure stuff |
12047 | 522 |
updateIconImages(); |
523 |
updateFocusabilityForAutoRequestFocus(false); |
|
524 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
525 |
// Actually show or hide the window |
12047 | 526 |
LWWindowPeer blocker = peer.getBlocker(); |
527 |
if (blocker == null || !visible) { |
|
528 |
// If it ain't blocked, or is being hidden, go regular way |
|
529 |
if (visible) { |
|
530 |
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
|
531 |
|
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
532 |
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
|
533 |
if (isPopup) { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
534 |
// 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
|
535 |
CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
536 |
} else { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
537 |
CWrapper.NSWindow.orderFront(nsWindowPtr); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
538 |
} |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
539 |
|
12047 | 540 |
boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr); |
541 |
if (!isKeyWindow) { |
|
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
542 |
CWrapper.NSWindow.makeKeyWindow(nsWindowPtr); |
12047 | 543 |
} |
544 |
} else { |
|
545 |
CWrapper.NSWindow.orderOut(nsWindowPtr); |
|
546 |
} |
|
547 |
} else { |
|
548 |
// otherwise, put it in a proper z-order |
|
549 |
CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow, |
|
550 |
((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr()); |
|
551 |
} |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
552 |
this.visible = visible; |
12047 | 553 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
554 |
// Manage the extended state when showing |
12047 | 555 |
if (visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
556 |
// Apply the extended state as expected in shared code |
12047 | 557 |
if (target instanceof Frame) { |
558 |
switch (((Frame)target).getExtendedState()) { |
|
559 |
case Frame.ICONIFIED: |
|
560 |
CWrapper.NSWindow.miniaturize(nsWindowPtr); |
|
561 |
break; |
|
562 |
case Frame.MAXIMIZED_BOTH: |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
563 |
maximize(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
564 |
break; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
565 |
default: // NORMAL |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
566 |
unmaximize(); // in case it was maximized, otherwise this is a no-op |
12047 | 567 |
break; |
568 |
} |
|
569 |
} |
|
570 |
} |
|
571 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
572 |
nativeSynthesizeMouseEnteredExitedEvents(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12403
diff
changeset
|
573 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
574 |
// Configure stuff #2 |
12047 | 575 |
updateFocusabilityForAutoRequestFocus(true); |
576 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
577 |
// 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
|
578 |
if (visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
579 |
// 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
|
580 |
if (owner != null && owner.isVisible()) { |
12047 | 581 |
CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); |
582 |
if (target.isAlwaysOnTop()) { |
|
583 |
CWrapper.NSWindow.setLevel(nsWindowPtr, CWrapper.NSWindow.NSFloatingWindowLevel); |
|
584 |
} |
|
585 |
} |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
586 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
587 |
// 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
|
588 |
for (Window w : target.getOwnedWindows()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
589 |
WindowPeer p = (WindowPeer)w.getPeer(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
590 |
if (p instanceof LWWindowPeer) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
591 |
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
|
592 |
if (pw != null && pw.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
593 |
CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
594 |
if (w.isAlwaysOnTop()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
595 |
CWrapper.NSWindow.setLevel(pw.getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
596 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
597 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
598 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
599 |
} |
12047 | 600 |
} |
601 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
602 |
// Deal with the blocker of the window being shown |
12047 | 603 |
if (blocker != null && visible) { |
604 |
// Make sure the blocker is above its siblings |
|
605 |
((CPlatformWindow)blocker.getPlatformWindow()).orderAboveSiblings(); |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
@Override // PlatformWindow |
|
610 |
public void setTitle(String title) { |
|
611 |
nativeSetNSWindowTitle(getNSWindowPtr(), title); |
|
612 |
} |
|
613 |
||
614 |
// Should be called on every window key property change. |
|
615 |
@Override // PlatformWindow |
|
616 |
public void updateIconImages() { |
|
617 |
final long nsWindowPtr = getNSWindowPtr(); |
|
618 |
final CImage cImage = getImageForTarget(); |
|
619 |
nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr); |
|
620 |
} |
|
621 |
||
622 |
public long getNSWindowPtr() { |
|
623 |
final long nsWindowPtr = ptr; |
|
624 |
if (nsWindowPtr == 0L) { |
|
625 |
if(logger.isLoggable(PlatformLogger.FINE)) { |
|
626 |
logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid.")); |
|
627 |
} |
|
628 |
} |
|
629 |
return nsWindowPtr; |
|
630 |
} |
|
631 |
||
632 |
public SurfaceData getSurfaceData() { |
|
633 |
return contentView.getSurfaceData(); |
|
634 |
} |
|
635 |
||
636 |
@Override // PlatformWindow |
|
637 |
public void toBack() { |
|
638 |
final long nsWindowPtr = getNSWindowPtr(); |
|
639 |
nativePushNSWindowToBack(nsWindowPtr); |
|
640 |
} |
|
641 |
||
642 |
@Override // PlatformWindow |
|
643 |
public void toFront() { |
|
644 |
final long nsWindowPtr = getNSWindowPtr(); |
|
645 |
updateFocusabilityForAutoRequestFocus(false); |
|
646 |
nativePushNSWindowToFront(nsWindowPtr); |
|
647 |
updateFocusabilityForAutoRequestFocus(true); |
|
648 |
} |
|
649 |
||
650 |
@Override |
|
14648
2ef7c7edb4b0
7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents:
14647
diff
changeset
|
651 |
public void setResizable(final boolean resizable) { |
12047 | 652 |
setStyleBits(RESIZABLE, resizable); |
653 |
} |
|
654 |
||
655 |
@Override |
|
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13235
diff
changeset
|
656 |
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
|
657 |
nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH); |
12047 | 658 |
} |
659 |
||
660 |
@Override |
|
12176 | 661 |
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) { |
662 |
// Cross-app activation requests are not allowed. |
|
663 |
if (cause != CausedFocusEvent.Cause.MOUSE_EVENT && |
|
664 |
!((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) |
|
665 |
{ |
|
666 |
focusLogger.fine("the app is inactive, so the request is rejected"); |
|
667 |
return true; |
|
668 |
} |
|
669 |
return false; |
|
670 |
} |
|
671 |
||
672 |
@Override |
|
12047 | 673 |
public boolean requestWindowFocus() { |
12176 | 674 |
|
12047 | 675 |
long ptr = getNSWindowPtr(); |
676 |
if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) { |
|
677 |
CWrapper.NSWindow.makeMainWindow(ptr); |
|
678 |
} |
|
679 |
CWrapper.NSWindow.makeKeyAndOrderFront(ptr); |
|
680 |
return true; |
|
681 |
} |
|
682 |
||
683 |
@Override |
|
684 |
public boolean isActive() { |
|
685 |
long ptr = getNSWindowPtr(); |
|
686 |
return CWrapper.NSWindow.isKeyWindow(ptr); |
|
687 |
} |
|
688 |
||
689 |
@Override |
|
690 |
public void updateFocusableWindowState() { |
|
691 |
final boolean isFocusable = isNativelyFocusableWindow(); |
|
692 |
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once |
|
693 |
} |
|
694 |
||
695 |
@Override |
|
696 |
public Graphics transformGraphics(Graphics g) { |
|
697 |
// is this where we can inject a transform for HiDPI? |
|
698 |
return g; |
|
699 |
} |
|
700 |
||
701 |
@Override |
|
702 |
public void setAlwaysOnTop(boolean isAlwaysOnTop) { |
|
703 |
setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop); |
|
704 |
} |
|
705 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
706 |
public PlatformWindow getTopmostPlatformWindowUnderMouse(){ |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
707 |
return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse(); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
708 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
709 |
|
12047 | 710 |
@Override |
711 |
public void setOpacity(float opacity) { |
|
712 |
CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity); |
|
713 |
} |
|
714 |
||
715 |
@Override |
|
716 |
public void setOpaque(boolean isOpaque) { |
|
717 |
CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); |
|
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
718 |
if (!isOpaque && !peer.isTextured()) { |
12047 | 719 |
long clearColor = CWrapper.NSColor.clearColor(); |
720 |
CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor); |
|
721 |
} |
|
13233 | 722 |
|
723 |
//This is a temporary workaround. Looks like after 7124236 will be fixed |
|
724 |
//the correct place for invalidateShadow() is CGLayer.drawInCGLContext. |
|
725 |
SwingUtilities.invokeLater(new Runnable() { |
|
726 |
@Override |
|
727 |
public void run() { |
|
728 |
invalidateShadow(); |
|
729 |
} |
|
730 |
}); |
|
12047 | 731 |
} |
732 |
||
733 |
@Override |
|
734 |
public void enterFullScreenMode() { |
|
735 |
isFullScreenMode = true; |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
736 |
contentView.enterFullScreenMode(); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
737 |
// the move/size notification from the underlying system comes |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
738 |
// but it contains a bounds smaller than the whole screen |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
739 |
// and therefore we need to create the synthetic notifications |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
740 |
Rectangle screenBounds; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
741 |
final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr()); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
742 |
try { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
743 |
screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds(); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
744 |
} finally { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
745 |
CWrapper.NSObject.release(screenPtr); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
746 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
747 |
peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width, |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
748 |
screenBounds.height); |
12047 | 749 |
} |
750 |
||
751 |
@Override |
|
752 |
public void exitFullScreenMode() { |
|
753 |
contentView.exitFullScreenMode(); |
|
754 |
isFullScreenMode = false; |
|
755 |
} |
|
756 |
||
757 |
@Override |
|
758 |
public void setWindowState(int windowState) { |
|
759 |
if (!peer.isVisible()) { |
|
760 |
// setVisible() applies the state |
|
761 |
return; |
|
762 |
} |
|
763 |
||
764 |
int prevWindowState = peer.getState(); |
|
765 |
if (prevWindowState == windowState) return; |
|
766 |
||
767 |
final long nsWindowPtr = getNSWindowPtr(); |
|
768 |
switch (windowState) { |
|
769 |
case Frame.ICONIFIED: |
|
770 |
if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
|
771 |
// let's return into the normal states first |
|
772 |
// 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
|
773 |
unmaximize(); |
12047 | 774 |
} |
775 |
CWrapper.NSWindow.miniaturize(nsWindowPtr); |
|
776 |
break; |
|
777 |
case Frame.MAXIMIZED_BOTH: |
|
778 |
if (prevWindowState == Frame.ICONIFIED) { |
|
779 |
// let's return into the normal states first |
|
780 |
CWrapper.NSWindow.deminiaturize(nsWindowPtr); |
|
781 |
} |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
782 |
maximize(); |
12047 | 783 |
break; |
784 |
case Frame.NORMAL: |
|
785 |
if (prevWindowState == Frame.ICONIFIED) { |
|
786 |
CWrapper.NSWindow.deminiaturize(nsWindowPtr); |
|
787 |
} else if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
|
788 |
// 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
|
789 |
unmaximize(); |
12047 | 790 |
} |
791 |
break; |
|
792 |
default: |
|
793 |
throw new RuntimeException("Unknown window state: " + windowState); |
|
794 |
} |
|
795 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
796 |
nativeSynthesizeMouseEnteredExitedEvents(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12403
diff
changeset
|
797 |
|
12047 | 798 |
// NOTE: the SWP.windowState field gets updated to the newWindowState |
799 |
// value when the native notification comes to us |
|
800 |
} |
|
801 |
||
12640 | 802 |
@Override |
803 |
public void setModalBlocked(boolean blocked) { |
|
804 |
if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) { |
|
805 |
return; |
|
806 |
} |
|
807 |
||
808 |
nativeSetEnabled(getNSWindowPtr(), !blocked); |
|
809 |
} |
|
810 |
||
13233 | 811 |
public final void invalidateShadow(){ |
812 |
nativeRevalidateNSWindowShadow(getNSWindowPtr()); |
|
813 |
} |
|
814 |
||
12047 | 815 |
// ---------------------------------------------------------------------- |
816 |
// UTILITY METHODS |
|
817 |
// ---------------------------------------------------------------------- |
|
818 |
||
819 |
/* |
|
820 |
* Find image to install into Title or into Application icon. |
|
821 |
* First try icons installed for toplevel. If there is no icon |
|
822 |
* use default Duke image. |
|
823 |
* This method shouldn't return null. |
|
824 |
*/ |
|
825 |
private CImage getImageForTarget() { |
|
826 |
List<Image> icons = target.getIconImages(); |
|
827 |
if (icons == null || icons.size() == 0) { |
|
828 |
return null; |
|
829 |
} |
|
12403
50b3f2982b59
7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents:
12402
diff
changeset
|
830 |
return CImage.getCreator().createFromImages(icons); |
12047 | 831 |
} |
832 |
||
833 |
/* |
|
834 |
* Returns LWWindowPeer associated with this delegate. |
|
835 |
*/ |
|
836 |
@Override |
|
837 |
public LWWindowPeer getPeer() { |
|
838 |
return peer; |
|
839 |
} |
|
840 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
841 |
@Override |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
842 |
public boolean isUnderMouse() { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
843 |
return contentView.isUnderMouse(); |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
844 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
845 |
|
12047 | 846 |
public CPlatformView getContentView() { |
847 |
return contentView; |
|
848 |
} |
|
849 |
||
850 |
@Override |
|
851 |
public long getLayerPtr() { |
|
852 |
return contentView.getWindowLayerPtr(); |
|
853 |
} |
|
854 |
||
855 |
private void validateSurface() { |
|
856 |
SurfaceData surfaceData = getSurfaceData(); |
|
857 |
if (surfaceData instanceof CGLSurfaceData) { |
|
858 |
((CGLSurfaceData)surfaceData).validate(); |
|
859 |
} |
|
860 |
} |
|
861 |
||
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
862 |
private void flushBuffers() { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
863 |
if (isVisible() && !nativeBounds.isEmpty()) { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
864 |
LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
865 |
} |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
866 |
} |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
867 |
|
12047 | 868 |
/************************************************************* |
869 |
* Callbacks from the AWTWindow and AWTView objc classes. |
|
870 |
*************************************************************/ |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
871 |
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
|
872 |
// 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
|
873 |
if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
874 |
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
|
875 |
return; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
876 |
} |
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
877 |
|
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
878 |
LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
879 |
responder.handleWindowFocusEvent(gained, oppositePeer); |
12047 | 880 |
} |
881 |
||
14651
f032406c1e48
8002308: [macosx] 7198229 should be applied to the user action only
serb
parents:
14648
diff
changeset
|
882 |
private void deliverMoveResizeEvent(int x, int y, int width, int height, |
f032406c1e48
8002308: [macosx] 7198229 should be applied to the user action only
serb
parents:
14648
diff
changeset
|
883 |
boolean byUser) { |
12047 | 884 |
// when the content view enters the full-screen mode, the native |
885 |
// move/resize notifications contain a bounds smaller than |
|
886 |
// the whole screen and therefore we ignore the native notifications |
|
887 |
// and the content view itself creates correct synthetic notifications |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
888 |
if (isFullScreenMode) { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
889 |
return; |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
890 |
} |
12047 | 891 |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
892 |
final Rectangle oldB = nativeBounds; |
12047 | 893 |
nativeBounds = new Rectangle(x, y, width, height); |
894 |
peer.notifyReshape(x, y, width, height); |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
895 |
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
896 |
|| isFullScreenAnimationOn) { |
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
897 |
flushBuffers(); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
898 |
} |
12047 | 899 |
} |
900 |
||
901 |
private void deliverWindowClosingEvent() { |
|
902 |
if (peer.getBlocker() == null) { |
|
903 |
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING)); |
|
904 |
} |
|
905 |
} |
|
906 |
||
907 |
private void deliverIconify(final boolean iconify) { |
|
908 |
peer.notifyIconify(iconify); |
|
909 |
} |
|
910 |
||
911 |
private void deliverZoom(final boolean isZoomed) { |
|
912 |
peer.notifyZoom(isZoomed); |
|
913 |
} |
|
914 |
||
915 |
private void deliverNCMouseDown() { |
|
916 |
peer.notifyNCMouseDown(); |
|
917 |
} |
|
918 |
||
919 |
/* |
|
920 |
* Our focus model is synthetic and only non-simple window |
|
921 |
* may become natively focusable window. |
|
922 |
*/ |
|
923 |
private boolean isNativelyFocusableWindow() { |
|
924 |
return !peer.isSimpleWindow() && target.getFocusableWindowState(); |
|
925 |
} |
|
926 |
||
927 |
/* |
|
928 |
* An utility method for the support of the auto request focus. |
|
929 |
* Updates the focusable state of the window under certain |
|
930 |
* circumstances. |
|
931 |
*/ |
|
932 |
private void updateFocusabilityForAutoRequestFocus(boolean isFocusable) { |
|
933 |
if (target.isAutoRequestFocus() || !isNativelyFocusableWindow()) return; |
|
934 |
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once |
|
935 |
} |
|
936 |
||
937 |
private boolean checkBlocking() { |
|
938 |
LWWindowPeer blocker = peer.getBlocker(); |
|
939 |
if (blocker == null) { |
|
940 |
return false; |
|
941 |
} |
|
942 |
||
15328
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
943 |
if (blocker instanceof CPrinterDialogPeer) { |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
944 |
return true; |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
945 |
} |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
946 |
|
12047 | 947 |
CPlatformWindow pWindow = (CPlatformWindow)blocker.getPlatformWindow(); |
948 |
||
949 |
pWindow.orderAboveSiblings(); |
|
950 |
||
951 |
final long nsWindowPtr = pWindow.getNSWindowPtr(); |
|
952 |
CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); |
|
953 |
CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr); |
|
954 |
CWrapper.NSWindow.makeMainWindow(nsWindowPtr); |
|
955 |
||
956 |
return true; |
|
957 |
} |
|
958 |
||
959 |
private void orderAboveSiblings() { |
|
960 |
if (owner == null) { |
|
961 |
return; |
|
962 |
} |
|
963 |
||
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
964 |
// 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
|
965 |
// visible root owner |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
966 |
// invisible owner |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
967 |
// visible dialog |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
968 |
// 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
|
969 |
if (owner.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
970 |
// 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
|
971 |
// 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
|
972 |
owner.orderAboveSiblings(); |
12047 | 973 |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
974 |
// 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
|
975 |
final long nsWindowSelfPtr = getNSWindowPtr(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
976 |
final long nsWindowOwnerPtr = owner.getNSWindowPtr(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
977 |
CWrapper.NSWindow.removeChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
978 |
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
|
979 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
980 |
|
12047 | 981 |
if (target.isAlwaysOnTop()) { |
982 |
CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); |
|
983 |
} |
|
984 |
} |
|
985 |
||
986 |
// ---------------------------------------------------------------------- |
|
987 |
// NATIVE CALLBACKS |
|
988 |
// ---------------------------------------------------------------------- |
|
989 |
||
990 |
private void windowDidBecomeMain() { |
|
991 |
assert CThreading.assertAppKit(); |
|
992 |
||
993 |
if (checkBlocking()) return; |
|
994 |
// If it's not blocked, make sure it's above its siblings |
|
995 |
orderAboveSiblings(); |
|
996 |
} |
|
997 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
998 |
private void windowWillEnterFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
999 |
isFullScreenAnimationOn = true; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1000 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1001 |
|
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1002 |
private void windowDidEnterFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1003 |
isFullScreenAnimationOn = false; |
12047 | 1004 |
} |
1005 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1006 |
private void windowWillExitFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1007 |
isFullScreenAnimationOn = true; |
12047 | 1008 |
} |
1009 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1010 |
private void windowDidExitFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1011 |
isFullScreenAnimationOn = false; |
12047 | 1012 |
} |
1013 |
} |