author | leonidr |
Wed, 27 Mar 2013 16:37:00 +0400 | |
changeset 18241 | 3e009b5be123 |
parent 15331 | 410070becfef |
child 18242 | a68c4765f8f2 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
18241 | 2 |
* Copyright (c) 2011, 2013, 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.*; |
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 |
||
18241 | 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; |
|
18241 | 203 |
protected CPlatformView contentView; |
204 |
protected CPlatformWindow owner; |
|
205 |
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
|
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) { |
|
221 |
this.peer = _peer; |
|
222 |
this.target = _target; |
|
223 |
if (_owner instanceof CPlatformWindow) { |
|
224 |
this.owner = (CPlatformWindow)_owner; |
|
225 |
} |
|
226 |
||
227 |
final int styleBits = getInitialStyleBits(); |
|
228 |
||
18241 | 229 |
responder = createPlatformResponder(); |
230 |
contentView = createContentView(); |
|
12664
91828a78446f
7156191: [macosx] Can't type into applet demos in Pivot
dcherepanov
parents:
12647
diff
changeset
|
231 |
contentView.initialize(peer, responder); |
12047 | 232 |
|
233 |
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0); |
|
234 |
setPtr(nativeWindowPtr); |
|
235 |
||
236 |
if (target instanceof javax.swing.RootPaneContainer) { |
|
237 |
final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); |
|
238 |
if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() { |
|
239 |
public void propertyChange(final PropertyChangeEvent evt) { |
|
240 |
CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane); |
|
241 |
rootpane.removePropertyChangeListener("ancestor", this); |
|
242 |
} |
|
243 |
}); |
|
244 |
} |
|
245 |
||
246 |
validateSurface(); |
|
247 |
} |
|
248 |
||
18241 | 249 |
protected CPlatformResponder createPlatformResponder() { |
250 |
return new CPlatformResponder(peer, false); |
|
251 |
} |
|
252 |
||
253 |
protected CPlatformView createContentView() { |
|
254 |
return new CPlatformView(); |
|
255 |
} |
|
256 |
||
257 |
protected int getInitialStyleBits() { |
|
12047 | 258 |
// defaults style bits |
259 |
int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; |
|
260 |
||
261 |
if (isNativelyFocusableWindow()) { |
|
262 |
styleBits = SET(styleBits, SHOULD_BECOME_KEY, true); |
|
263 |
styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true); |
|
264 |
} |
|
265 |
||
266 |
final boolean isFrame = (target instanceof Frame); |
|
267 |
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
|
268 |
final boolean isPopup = (target.getType() == Window.Type.POPUP); |
12047 | 269 |
if (isDialog) { |
270 |
styleBits = SET(styleBits, MINIMIZABLE, false); |
|
271 |
} |
|
272 |
||
273 |
// Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated. |
|
274 |
{ |
|
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
275 |
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
|
276 |
if (this.undecorated) styleBits = SET(styleBits, DECORATED, false); |
12047 | 277 |
} |
278 |
||
279 |
// Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable |
|
280 |
{ |
|
281 |
final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); |
|
282 |
styleBits = SET(styleBits, RESIZABLE, resizable); |
|
283 |
if (!resizable) { |
|
284 |
styleBits = SET(styleBits, ZOOMABLE, false); |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
if (target.isAlwaysOnTop()) { |
|
289 |
styleBits = SET(styleBits, ALWAYS_ON_TOP, true); |
|
290 |
} |
|
291 |
||
292 |
if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) { |
|
293 |
styleBits = SET(styleBits, MODAL_EXCLUDED, true); |
|
294 |
} |
|
295 |
||
296 |
// 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
|
297 |
if (isPopup) { |
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
298 |
styleBits = SET(styleBits, TEXTURED, false); |
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
299 |
// 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
|
300 |
styleBits = SET(styleBits, NONACTIVATING, true); |
12047 | 301 |
} |
302 |
||
12647
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
303 |
if (Window.Type.UTILITY.equals(target.getType())) { |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
304 |
styleBits = SET(styleBits, UTILITY, true); |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
305 |
} |
f9991bc4fdde
7166437: [macosx] Support for Window.Type.UTILITY on the Mac
anthony
parents:
12640
diff
changeset
|
306 |
|
12047 | 307 |
if (target instanceof javax.swing.RootPaneContainer) { |
308 |
javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); |
|
309 |
Object prop = null; |
|
310 |
||
311 |
prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK); |
|
312 |
if (prop != null) { |
|
313 |
styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString())); |
|
314 |
} |
|
315 |
||
316 |
if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) { |
|
317 |
prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET); |
|
318 |
if (prop != null) { |
|
319 |
styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString())); |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
prop = rootpane.getClientProperty(WINDOW_STYLE); |
|
324 |
if (prop != null) { |
|
325 |
if ("small".equals(prop)) { |
|
326 |
styleBits = SET(styleBits, UTILITY, true); |
|
327 |
if (target.isAlwaysOnTop() && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) { |
|
328 |
styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true); |
|
329 |
} |
|
330 |
} |
|
331 |
if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true); |
|
332 |
if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true); |
|
333 |
if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true); |
|
334 |
} |
|
335 |
||
336 |
prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE); |
|
337 |
if (prop != null) { |
|
338 |
styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString())); |
|
339 |
} |
|
340 |
||
341 |
prop = rootpane.getClientProperty(WINDOW_CLOSEABLE); |
|
342 |
if (prop != null) { |
|
343 |
styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString())); |
|
344 |
} |
|
345 |
||
346 |
prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE); |
|
347 |
if (prop != null) { |
|
348 |
styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString())); |
|
349 |
} |
|
350 |
||
351 |
prop = rootpane.getClientProperty(WINDOW_ZOOMABLE); |
|
352 |
if (prop != null) { |
|
353 |
styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString())); |
|
354 |
} |
|
355 |
||
356 |
prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE); |
|
357 |
if (prop != null) { |
|
358 |
styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString())); |
|
359 |
} |
|
360 |
||
361 |
prop = rootpane.getClientProperty(WINDOW_SHADOW); |
|
362 |
if (prop != null) { |
|
363 |
styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString())); |
|
364 |
} |
|
365 |
||
366 |
prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND); |
|
367 |
if (prop != null) { |
|
368 |
styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString())); |
|
369 |
} |
|
370 |
} |
|
371 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
372 |
peer.setTextured(IS(TEXTURED, styleBits)); |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
373 |
|
12047 | 374 |
return styleBits; |
375 |
} |
|
376 |
||
377 |
// this is the counter-point to -[CWindow _nativeSetStyleBit:] |
|
14648
2ef7c7edb4b0
7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents:
14647
diff
changeset
|
378 |
private void setStyleBits(final int mask, final boolean value) { |
12047 | 379 |
nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0); |
380 |
} |
|
381 |
||
382 |
private native void _toggleFullScreenMode(final long model); |
|
383 |
||
384 |
public void toggleFullScreen() { |
|
385 |
_toggleFullScreenMode(getNSWindowPtr()); |
|
386 |
} |
|
387 |
||
388 |
@Override // PlatformWindow |
|
389 |
public void setMenuBar(MenuBar mb) { |
|
390 |
final long nsWindowPtr = getNSWindowPtr(); |
|
391 |
CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb); |
|
392 |
if (mbPeer != null) { |
|
393 |
nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel()); |
|
394 |
} else { |
|
395 |
nativeSetNSWindowMenuBar(nsWindowPtr, 0); |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
@Override // PlatformWindow |
|
400 |
public void dispose() { |
|
401 |
if (owner != null) { |
|
402 |
CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr()); |
|
403 |
} |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
404 |
contentView.dispose(); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
405 |
nativeDispose(getNSWindowPtr()); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
13009
diff
changeset
|
406 |
CPlatformWindow.super.dispose(); |
12047 | 407 |
} |
408 |
||
409 |
@Override // PlatformWindow |
|
410 |
public FontMetrics getFontMetrics(Font f) { |
|
411 |
// TODO: not implemented |
|
412 |
(new RuntimeException("unimplemented")).printStackTrace(); |
|
413 |
return null; |
|
414 |
} |
|
415 |
||
416 |
@Override // PlatformWindow |
|
417 |
public Insets getInsets() { |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
418 |
if (!isFullScreenMode) { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
419 |
return nativeGetNSWindowInsets(getNSWindowPtr()); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
420 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
421 |
return new Insets(0, 0, 0, 0); |
12047 | 422 |
} |
423 |
||
424 |
@Override // PlatformWindow |
|
425 |
public Point getLocationOnScreen() { |
|
426 |
return new Point(nativeBounds.x, nativeBounds.y); |
|
427 |
} |
|
428 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12664
diff
changeset
|
429 |
@Override |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12664
diff
changeset
|
430 |
public GraphicsDevice getGraphicsDevice() { |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
431 |
return contentView.getGraphicsDevice(); |
12047 | 432 |
} |
433 |
||
434 |
@Override // PlatformWindow |
|
435 |
public SurfaceData getScreenSurface() { |
|
436 |
// TODO: not implemented |
|
437 |
return null; |
|
438 |
} |
|
439 |
||
440 |
@Override // PlatformWindow |
|
441 |
public SurfaceData replaceSurfaceData() { |
|
442 |
return contentView.replaceSurfaceData(); |
|
443 |
} |
|
444 |
||
445 |
@Override // PlatformWindow |
|
446 |
public void setBounds(int x, int y, int w, int h) { |
|
447 |
// assert CThreading.assertEventQueue(); |
|
448 |
nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h); |
|
449 |
} |
|
450 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
451 |
private boolean isMaximized() { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
452 |
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
|
453 |
} |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
454 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
455 |
private void maximize() { |
18241 | 456 |
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
|
457 |
return; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
458 |
} |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
459 |
if (!undecorated) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
460 |
zoomed = true; |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
461 |
CWrapper.NSWindow.zoom(getNSWindowPtr()); |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
462 |
} else { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
463 |
deliverZoom(true); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
464 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
465 |
this.normalBounds = peer.getBounds(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
466 |
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
|
467 |
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
|
468 |
// Flip the y coordinate |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
469 |
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
|
470 |
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
|
471 |
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
|
472 |
} |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
473 |
} |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
474 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
475 |
private void unmaximize() { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
476 |
if (!isMaximized()) { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
477 |
return; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
478 |
} |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
479 |
if (!undecorated) { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
480 |
zoomed = false; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
481 |
CWrapper.NSWindow.zoom(getNSWindowPtr()); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
482 |
} else { |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
483 |
deliverZoom(false); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
484 |
|
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
485 |
Rectangle toBounds = this.normalBounds; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
486 |
this.normalBounds = null; |
12284
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
487 |
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
|
488 |
} |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
489 |
} |
3f2477ebb708
7124428: [macosx] Frame.setExtendedState() doesn't work for undecorated windows
anthony
parents:
12177
diff
changeset
|
490 |
|
18241 | 491 |
public boolean isVisible() { |
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
492 |
return this.visible; |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
493 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
494 |
|
12047 | 495 |
@Override // PlatformWindow |
496 |
public void setVisible(boolean visible) { |
|
497 |
final long nsWindowPtr = getNSWindowPtr(); |
|
498 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
499 |
// 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
|
500 |
if (!visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
501 |
// Unparent my children |
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
502 |
for (Window w : target.getOwnedWindows()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
503 |
WindowPeer p = (WindowPeer)w.getPeer(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
504 |
if (p instanceof LWWindowPeer) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
505 |
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
|
506 |
if (pw != null && pw.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
507 |
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
|
508 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
509 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
510 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
511 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
512 |
// Unparent myself |
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
513 |
if (owner != null && owner.isVisible()) { |
12047 | 514 |
CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr); |
515 |
} |
|
516 |
} |
|
517 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
518 |
// Configure stuff |
12047 | 519 |
updateIconImages(); |
520 |
updateFocusabilityForAutoRequestFocus(false); |
|
521 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
522 |
// Actually show or hide the window |
18241 | 523 |
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker(); |
12047 | 524 |
if (blocker == null || !visible) { |
525 |
// If it ain't blocked, or is being hidden, go regular way |
|
526 |
if (visible) { |
|
527 |
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
|
528 |
|
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
529 |
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
|
530 |
if (isPopup) { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
531 |
// 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
|
532 |
CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
533 |
} else { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
534 |
CWrapper.NSWindow.orderFront(nsWindowPtr); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
535 |
} |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
536 |
|
12047 | 537 |
boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr); |
538 |
if (!isKeyWindow) { |
|
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
539 |
CWrapper.NSWindow.makeKeyWindow(nsWindowPtr); |
12047 | 540 |
} |
541 |
} else { |
|
542 |
CWrapper.NSWindow.orderOut(nsWindowPtr); |
|
543 |
} |
|
544 |
} else { |
|
545 |
// otherwise, put it in a proper z-order |
|
546 |
CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow, |
|
547 |
((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr()); |
|
548 |
} |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
549 |
this.visible = visible; |
12047 | 550 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
551 |
// Manage the extended state when showing |
12047 | 552 |
if (visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
553 |
// Apply the extended state as expected in shared code |
12047 | 554 |
if (target instanceof Frame) { |
555 |
switch (((Frame)target).getExtendedState()) { |
|
556 |
case Frame.ICONIFIED: |
|
557 |
CWrapper.NSWindow.miniaturize(nsWindowPtr); |
|
558 |
break; |
|
559 |
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
|
560 |
maximize(); |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
561 |
break; |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
562 |
default: // NORMAL |
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
563 |
unmaximize(); // in case it was maximized, otherwise this is a no-op |
12047 | 564 |
break; |
565 |
} |
|
566 |
} |
|
567 |
} |
|
568 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
569 |
nativeSynthesizeMouseEnteredExitedEvents(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12403
diff
changeset
|
570 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
571 |
// Configure stuff #2 |
12047 | 572 |
updateFocusabilityForAutoRequestFocus(true); |
573 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
574 |
// 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
|
575 |
if (visible) { |
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
576 |
// 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
|
577 |
if (owner != null && owner.isVisible()) { |
12047 | 578 |
CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); |
579 |
if (target.isAlwaysOnTop()) { |
|
580 |
CWrapper.NSWindow.setLevel(nsWindowPtr, CWrapper.NSWindow.NSFloatingWindowLevel); |
|
581 |
} |
|
582 |
} |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
583 |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
584 |
// 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
|
585 |
for (Window w : target.getOwnedWindows()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
586 |
WindowPeer p = (WindowPeer)w.getPeer(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
587 |
if (p instanceof LWWindowPeer) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
588 |
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
|
589 |
if (pw != null && pw.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
590 |
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
|
591 |
if (w.isAlwaysOnTop()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
592 |
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
|
593 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
594 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
595 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
596 |
} |
12047 | 597 |
} |
598 |
||
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
599 |
// Deal with the blocker of the window being shown |
12047 | 600 |
if (blocker != null && visible) { |
601 |
// Make sure the blocker is above its siblings |
|
602 |
((CPlatformWindow)blocker.getPlatformWindow()).orderAboveSiblings(); |
|
603 |
} |
|
604 |
} |
|
605 |
||
606 |
@Override // PlatformWindow |
|
607 |
public void setTitle(String title) { |
|
608 |
nativeSetNSWindowTitle(getNSWindowPtr(), title); |
|
609 |
} |
|
610 |
||
611 |
// Should be called on every window key property change. |
|
612 |
@Override // PlatformWindow |
|
613 |
public void updateIconImages() { |
|
614 |
final long nsWindowPtr = getNSWindowPtr(); |
|
615 |
final CImage cImage = getImageForTarget(); |
|
616 |
nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr); |
|
617 |
} |
|
618 |
||
619 |
public long getNSWindowPtr() { |
|
620 |
final long nsWindowPtr = ptr; |
|
621 |
if (nsWindowPtr == 0L) { |
|
622 |
if(logger.isLoggable(PlatformLogger.FINE)) { |
|
623 |
logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid.")); |
|
624 |
} |
|
625 |
} |
|
626 |
return nsWindowPtr; |
|
627 |
} |
|
628 |
||
629 |
public SurfaceData getSurfaceData() { |
|
630 |
return contentView.getSurfaceData(); |
|
631 |
} |
|
632 |
||
633 |
@Override // PlatformWindow |
|
634 |
public void toBack() { |
|
635 |
final long nsWindowPtr = getNSWindowPtr(); |
|
636 |
nativePushNSWindowToBack(nsWindowPtr); |
|
637 |
} |
|
638 |
||
639 |
@Override // PlatformWindow |
|
640 |
public void toFront() { |
|
641 |
final long nsWindowPtr = getNSWindowPtr(); |
|
642 |
updateFocusabilityForAutoRequestFocus(false); |
|
643 |
nativePushNSWindowToFront(nsWindowPtr); |
|
644 |
updateFocusabilityForAutoRequestFocus(true); |
|
645 |
} |
|
646 |
||
647 |
@Override |
|
14648
2ef7c7edb4b0
7193214: Consider simplifying CPlatformWindow.setResizable()
serb
parents:
14647
diff
changeset
|
648 |
public void setResizable(final boolean resizable) { |
12047 | 649 |
setStyleBits(RESIZABLE, resizable); |
650 |
} |
|
651 |
||
652 |
@Override |
|
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13235
diff
changeset
|
653 |
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
|
654 |
nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH); |
12047 | 655 |
} |
656 |
||
657 |
@Override |
|
12176 | 658 |
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) { |
659 |
// Cross-app activation requests are not allowed. |
|
660 |
if (cause != CausedFocusEvent.Cause.MOUSE_EVENT && |
|
661 |
!((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) |
|
662 |
{ |
|
663 |
focusLogger.fine("the app is inactive, so the request is rejected"); |
|
664 |
return true; |
|
665 |
} |
|
666 |
return false; |
|
667 |
} |
|
668 |
||
669 |
@Override |
|
12047 | 670 |
public boolean requestWindowFocus() { |
12176 | 671 |
|
12047 | 672 |
long ptr = getNSWindowPtr(); |
673 |
if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) { |
|
674 |
CWrapper.NSWindow.makeMainWindow(ptr); |
|
675 |
} |
|
676 |
CWrapper.NSWindow.makeKeyAndOrderFront(ptr); |
|
677 |
return true; |
|
678 |
} |
|
679 |
||
680 |
@Override |
|
681 |
public boolean isActive() { |
|
682 |
long ptr = getNSWindowPtr(); |
|
683 |
return CWrapper.NSWindow.isKeyWindow(ptr); |
|
684 |
} |
|
685 |
||
686 |
@Override |
|
687 |
public void updateFocusableWindowState() { |
|
688 |
final boolean isFocusable = isNativelyFocusableWindow(); |
|
689 |
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once |
|
690 |
} |
|
691 |
||
692 |
@Override |
|
693 |
public Graphics transformGraphics(Graphics g) { |
|
694 |
// is this where we can inject a transform for HiDPI? |
|
695 |
return g; |
|
696 |
} |
|
697 |
||
698 |
@Override |
|
699 |
public void setAlwaysOnTop(boolean isAlwaysOnTop) { |
|
700 |
setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop); |
|
701 |
} |
|
702 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
703 |
public PlatformWindow getTopmostPlatformWindowUnderMouse(){ |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
704 |
return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse(); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
705 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
706 |
|
12047 | 707 |
@Override |
708 |
public void setOpacity(float opacity) { |
|
709 |
CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity); |
|
710 |
} |
|
711 |
||
712 |
@Override |
|
713 |
public void setOpaque(boolean isOpaque) { |
|
714 |
CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); |
|
18241 | 715 |
boolean isTextured = (peer == null)? false : peer.isTextured(); |
716 |
if (!isOpaque && !isTextured) { |
|
12047 | 717 |
long clearColor = CWrapper.NSColor.clearColor(); |
718 |
CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor); |
|
719 |
} |
|
13233 | 720 |
|
721 |
//This is a temporary workaround. Looks like after 7124236 will be fixed |
|
722 |
//the correct place for invalidateShadow() is CGLayer.drawInCGLContext. |
|
723 |
SwingUtilities.invokeLater(new Runnable() { |
|
724 |
@Override |
|
725 |
public void run() { |
|
726 |
invalidateShadow(); |
|
727 |
} |
|
728 |
}); |
|
12047 | 729 |
} |
730 |
||
731 |
@Override |
|
732 |
public void enterFullScreenMode() { |
|
733 |
isFullScreenMode = true; |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
734 |
contentView.enterFullScreenMode(); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
735 |
// the move/size notification from the underlying system comes |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
736 |
// 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
|
737 |
// and therefore we need to create the synthetic notifications |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
738 |
Rectangle screenBounds; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
739 |
final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr()); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
740 |
try { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
741 |
screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds(); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
742 |
} finally { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
743 |
CWrapper.NSObject.release(screenPtr); |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
744 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
745 |
peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width, |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
746 |
screenBounds.height); |
12047 | 747 |
} |
748 |
||
749 |
@Override |
|
750 |
public void exitFullScreenMode() { |
|
751 |
contentView.exitFullScreenMode(); |
|
752 |
isFullScreenMode = false; |
|
753 |
} |
|
754 |
||
755 |
@Override |
|
18241 | 756 |
public boolean isFullScreenMode() { |
757 |
return isFullScreenMode; |
|
758 |
} |
|
759 |
||
760 |
@Override |
|
12047 | 761 |
public void setWindowState(int windowState) { |
18241 | 762 |
if (peer == null || !peer.isVisible()) { |
12047 | 763 |
// setVisible() applies the state |
764 |
return; |
|
765 |
} |
|
766 |
||
767 |
int prevWindowState = peer.getState(); |
|
768 |
if (prevWindowState == windowState) return; |
|
769 |
||
770 |
final long nsWindowPtr = getNSWindowPtr(); |
|
771 |
switch (windowState) { |
|
772 |
case Frame.ICONIFIED: |
|
773 |
if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
|
774 |
// let's return into the normal states first |
|
775 |
// 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
|
776 |
unmaximize(); |
12047 | 777 |
} |
778 |
CWrapper.NSWindow.miniaturize(nsWindowPtr); |
|
779 |
break; |
|
780 |
case Frame.MAXIMIZED_BOTH: |
|
781 |
if (prevWindowState == Frame.ICONIFIED) { |
|
782 |
// let's return into the normal states first |
|
783 |
CWrapper.NSWindow.deminiaturize(nsWindowPtr); |
|
784 |
} |
|
13235
d51095485728
7177173: [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
anthony
parents:
13234
diff
changeset
|
785 |
maximize(); |
12047 | 786 |
break; |
787 |
case Frame.NORMAL: |
|
788 |
if (prevWindowState == Frame.ICONIFIED) { |
|
789 |
CWrapper.NSWindow.deminiaturize(nsWindowPtr); |
|
790 |
} else if (prevWindowState == Frame.MAXIMIZED_BOTH) { |
|
791 |
// 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
|
792 |
unmaximize(); |
12047 | 793 |
} |
794 |
break; |
|
795 |
default: |
|
796 |
throw new RuntimeException("Unknown window state: " + windowState); |
|
797 |
} |
|
798 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
799 |
nativeSynthesizeMouseEnteredExitedEvents(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
12403
diff
changeset
|
800 |
|
12047 | 801 |
// NOTE: the SWP.windowState field gets updated to the newWindowState |
802 |
// value when the native notification comes to us |
|
803 |
} |
|
804 |
||
12640 | 805 |
@Override |
806 |
public void setModalBlocked(boolean blocked) { |
|
807 |
if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) { |
|
808 |
return; |
|
809 |
} |
|
810 |
||
811 |
nativeSetEnabled(getNSWindowPtr(), !blocked); |
|
812 |
} |
|
813 |
||
13233 | 814 |
public final void invalidateShadow(){ |
815 |
nativeRevalidateNSWindowShadow(getNSWindowPtr()); |
|
816 |
} |
|
817 |
||
12047 | 818 |
// ---------------------------------------------------------------------- |
819 |
// UTILITY METHODS |
|
820 |
// ---------------------------------------------------------------------- |
|
821 |
||
822 |
/* |
|
823 |
* Find image to install into Title or into Application icon. |
|
824 |
* First try icons installed for toplevel. If there is no icon |
|
825 |
* use default Duke image. |
|
826 |
* This method shouldn't return null. |
|
827 |
*/ |
|
828 |
private CImage getImageForTarget() { |
|
829 |
List<Image> icons = target.getIconImages(); |
|
830 |
if (icons == null || icons.size() == 0) { |
|
831 |
return null; |
|
832 |
} |
|
12403
50b3f2982b59
7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents:
12402
diff
changeset
|
833 |
return CImage.getCreator().createFromImages(icons); |
12047 | 834 |
} |
835 |
||
836 |
/* |
|
837 |
* Returns LWWindowPeer associated with this delegate. |
|
838 |
*/ |
|
839 |
@Override |
|
840 |
public LWWindowPeer getPeer() { |
|
841 |
return peer; |
|
842 |
} |
|
843 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
844 |
@Override |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
845 |
public boolean isUnderMouse() { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
846 |
return contentView.isUnderMouse(); |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
847 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14651
diff
changeset
|
848 |
|
12047 | 849 |
public CPlatformView getContentView() { |
850 |
return contentView; |
|
851 |
} |
|
852 |
||
853 |
@Override |
|
854 |
public long getLayerPtr() { |
|
855 |
return contentView.getWindowLayerPtr(); |
|
856 |
} |
|
857 |
||
858 |
private void validateSurface() { |
|
859 |
SurfaceData surfaceData = getSurfaceData(); |
|
860 |
if (surfaceData instanceof CGLSurfaceData) { |
|
861 |
((CGLSurfaceData)surfaceData).validate(); |
|
862 |
} |
|
863 |
} |
|
864 |
||
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
865 |
private void flushBuffers() { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
866 |
if (isVisible() && !nativeBounds.isEmpty()) { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
867 |
LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
868 |
} |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
869 |
} |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
870 |
|
12047 | 871 |
/************************************************************* |
872 |
* Callbacks from the AWTWindow and AWTView objc classes. |
|
873 |
*************************************************************/ |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
874 |
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
|
875 |
// 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
|
876 |
if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) { |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
877 |
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
|
878 |
return; |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12176
diff
changeset
|
879 |
} |
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
880 |
|
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
881 |
LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
882 |
responder.handleWindowFocusEvent(gained, oppositePeer); |
12047 | 883 |
} |
884 |
||
18241 | 885 |
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
|
886 |
boolean byUser) { |
12047 | 887 |
// when the content view enters the full-screen mode, the native |
888 |
// move/resize notifications contain a bounds smaller than |
|
889 |
// the whole screen and therefore we ignore the native notifications |
|
890 |
// 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
|
891 |
if (isFullScreenMode) { |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
892 |
return; |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
893 |
} |
12047 | 894 |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
895 |
final Rectangle oldB = nativeBounds; |
12047 | 896 |
nativeBounds = new Rectangle(x, y, width, height); |
18241 | 897 |
|
898 |
if (peer != null) { |
|
899 |
peer.notifyReshape(x, y, width, height); |
|
900 |
} |
|
901 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
902 |
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
903 |
|| isFullScreenAnimationOn) { |
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
904 |
flushBuffers(); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
14165
diff
changeset
|
905 |
} |
12047 | 906 |
} |
907 |
||
908 |
private void deliverWindowClosingEvent() { |
|
18241 | 909 |
if (peer != null) { |
910 |
if (peer.getBlocker() == null) { |
|
911 |
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING)); |
|
912 |
} |
|
12047 | 913 |
} |
914 |
} |
|
915 |
||
916 |
private void deliverIconify(final boolean iconify) { |
|
18241 | 917 |
if (peer != null) { |
918 |
peer.notifyIconify(iconify); |
|
919 |
} |
|
12047 | 920 |
} |
921 |
||
922 |
private void deliverZoom(final boolean isZoomed) { |
|
18241 | 923 |
if (peer != null) { |
924 |
peer.notifyZoom(isZoomed); |
|
925 |
} |
|
12047 | 926 |
} |
927 |
||
928 |
private void deliverNCMouseDown() { |
|
18241 | 929 |
if (peer != null) { |
930 |
peer.notifyNCMouseDown(); |
|
931 |
} |
|
12047 | 932 |
} |
933 |
||
934 |
/* |
|
935 |
* Our focus model is synthetic and only non-simple window |
|
936 |
* may become natively focusable window. |
|
937 |
*/ |
|
938 |
private boolean isNativelyFocusableWindow() { |
|
18241 | 939 |
if (peer == null) { |
940 |
return false; |
|
941 |
} |
|
942 |
||
12047 | 943 |
return !peer.isSimpleWindow() && target.getFocusableWindowState(); |
944 |
} |
|
945 |
||
946 |
/* |
|
947 |
* An utility method for the support of the auto request focus. |
|
948 |
* Updates the focusable state of the window under certain |
|
949 |
* circumstances. |
|
950 |
*/ |
|
951 |
private void updateFocusabilityForAutoRequestFocus(boolean isFocusable) { |
|
952 |
if (target.isAutoRequestFocus() || !isNativelyFocusableWindow()) return; |
|
953 |
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once |
|
954 |
} |
|
955 |
||
956 |
private boolean checkBlocking() { |
|
18241 | 957 |
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker(); |
12047 | 958 |
if (blocker == null) { |
959 |
return false; |
|
960 |
} |
|
961 |
||
15328
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
962 |
if (blocker instanceof CPrinterDialogPeer) { |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
963 |
return true; |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
964 |
} |
65d946035fa9
8005997: [macosx] Printer Dialog opens an additional title bar
serb
parents:
15322
diff
changeset
|
965 |
|
12047 | 966 |
CPlatformWindow pWindow = (CPlatformWindow)blocker.getPlatformWindow(); |
967 |
||
968 |
pWindow.orderAboveSiblings(); |
|
969 |
||
970 |
final long nsWindowPtr = pWindow.getNSWindowPtr(); |
|
971 |
CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); |
|
972 |
CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr); |
|
973 |
CWrapper.NSWindow.makeMainWindow(nsWindowPtr); |
|
974 |
||
975 |
return true; |
|
976 |
} |
|
977 |
||
978 |
private void orderAboveSiblings() { |
|
979 |
if (owner == null) { |
|
980 |
return; |
|
981 |
} |
|
982 |
||
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
983 |
// 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
|
984 |
// visible root owner |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
985 |
// invisible owner |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
986 |
// visible dialog |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
987 |
// 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
|
988 |
if (owner.isVisible()) { |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
989 |
// 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
|
990 |
// 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
|
991 |
owner.orderAboveSiblings(); |
12047 | 992 |
|
12286
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
993 |
// 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
|
994 |
final long nsWindowSelfPtr = getNSWindowPtr(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
995 |
final long nsWindowOwnerPtr = owner.getNSWindowPtr(); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
996 |
CWrapper.NSWindow.removeChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr); |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
997 |
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
|
998 |
} |
9e40486e227e
7154177: [macosx] An invisible owner frame becomes visible upon clicking a child window
anthony
parents:
12284
diff
changeset
|
999 |
|
12047 | 1000 |
if (target.isAlwaysOnTop()) { |
1001 |
CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); |
|
1002 |
} |
|
1003 |
} |
|
1004 |
||
1005 |
// ---------------------------------------------------------------------- |
|
1006 |
// NATIVE CALLBACKS |
|
1007 |
// ---------------------------------------------------------------------- |
|
1008 |
||
1009 |
private void windowDidBecomeMain() { |
|
1010 |
assert CThreading.assertAppKit(); |
|
1011 |
||
1012 |
if (checkBlocking()) return; |
|
1013 |
// If it's not blocked, make sure it's above its siblings |
|
1014 |
orderAboveSiblings(); |
|
1015 |
} |
|
1016 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1017 |
private void windowWillEnterFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1018 |
isFullScreenAnimationOn = true; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1019 |
} |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1020 |
|
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1021 |
private void windowDidEnterFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1022 |
isFullScreenAnimationOn = false; |
12047 | 1023 |
} |
1024 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1025 |
private void windowWillExitFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1026 |
isFullScreenAnimationOn = true; |
12047 | 1027 |
} |
1028 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1029 |
private void windowDidExitFullScreen() { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15328
diff
changeset
|
1030 |
isFullScreenAnimationOn = false; |
12047 | 1031 |
} |
1032 |
} |