author | anashaty |
Mon, 30 Mar 2015 17:46:58 +0300 | |
changeset 29884 | 013dd351eb8a |
parent 28235 | 0dfebfcb9f8a |
child 30469 | bac0a7ff7e1e |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.lwawt; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.event.*; |
|
30 |
import java.awt.peer.*; |
|
31 |
import java.util.List; |
|
32 |
||
33 |
import javax.swing.*; |
|
34 |
||
35 |
import sun.awt.*; |
|
36 |
import sun.java2d.*; |
|
37 |
import sun.java2d.loops.Blit; |
|
38 |
import sun.java2d.loops.CompositeType; |
|
13233 | 39 |
import sun.java2d.pipe.Region; |
12047 | 40 |
import sun.util.logging.PlatformLogger; |
41 |
||
42 |
public class LWWindowPeer |
|
43 |
extends LWContainerPeer<Window, JComponent> |
|
18249 | 44 |
implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener, PlatformEventNotifier |
12047 | 45 |
{ |
20153 | 46 |
public enum PeerType { |
12047 | 47 |
SIMPLEWINDOW, |
48 |
FRAME, |
|
49 |
DIALOG, |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
50 |
EMBEDDED_FRAME, |
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
51 |
VIEW_EMBEDDED_FRAME, |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
52 |
LW_FRAME |
12047 | 53 |
} |
54 |
||
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
55 |
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer"); |
12047 | 56 |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
57 |
private final PlatformWindow platformWindow; |
12047 | 58 |
|
59 |
private static final int MINIMUM_WIDTH = 1; |
|
60 |
private static final int MINIMUM_HEIGHT = 1; |
|
61 |
||
62 |
private Insets insets = new Insets(0, 0, 0, 0); |
|
63 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
64 |
private GraphicsDevice graphicsDevice; |
12047 | 65 |
private GraphicsConfiguration graphicsConfig; |
66 |
||
67 |
private SurfaceData surfaceData; |
|
68 |
private final Object surfaceDataLock = new Object(); |
|
69 |
||
70 |
private volatile int windowState = Frame.NORMAL; |
|
71 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
72 |
// check that the mouse is over the window |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
73 |
private volatile boolean isMouseOver = false; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
74 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
75 |
// A peer where the last mouse event came to. Used by cursor manager to |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
76 |
// find the component under cursor |
20153 | 77 |
private static volatile LWComponentPeer<?, ?> lastCommonMouseEventPeer; |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
78 |
|
12047 | 79 |
// A peer where the last mouse event came to. Used to generate |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
80 |
// MOUSE_ENTERED/EXITED notifications |
20153 | 81 |
private volatile LWComponentPeer<?, ?> lastMouseEventPeer; |
12047 | 82 |
|
83 |
// Peers where all dragged/released events should come to, |
|
84 |
// depending on what mouse button is being dragged according to Cocoa |
|
20153 | 85 |
private static final LWComponentPeer<?, ?>[] mouseDownTarget = new LWComponentPeer<?, ?>[3]; |
12047 | 86 |
|
87 |
// A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events |
|
88 |
// on MOUSE_RELEASE. Click events are only generated if there were no drag |
|
89 |
// events between MOUSE_PRESSED and MOUSE_RELEASED for particular button |
|
90 |
private static int mouseClickButtons = 0; |
|
91 |
||
92 |
private volatile boolean isOpaque = true; |
|
93 |
||
94 |
private static final Font DEFAULT_FONT = new Font("Lucida Grande", Font.PLAIN, 13); |
|
95 |
||
96 |
private static LWWindowPeer grabbingWindow; |
|
97 |
||
98 |
private volatile boolean skipNextFocusChange; |
|
99 |
||
13233 | 100 |
private static final Color nonOpaqueBackground = new Color(0, 0, 0, 0); |
101 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
102 |
private volatile boolean textured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
103 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
104 |
private final PeerType peerType; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
105 |
|
18241 | 106 |
private final SecurityWarningWindow warningWindow; |
107 |
||
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
108 |
private volatile boolean targetFocusable; |
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
109 |
|
12047 | 110 |
/** |
111 |
* Current modal blocker or null. |
|
112 |
* |
|
113 |
* Synchronization: peerTreeLock. |
|
114 |
*/ |
|
115 |
private LWWindowPeer blocker; |
|
116 |
||
117 |
public LWWindowPeer(Window target, PlatformComponent platformComponent, |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
118 |
PlatformWindow platformWindow, PeerType peerType) |
12047 | 119 |
{ |
120 |
super(target, platformComponent); |
|
121 |
this.platformWindow = platformWindow; |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
122 |
this.peerType = peerType; |
12047 | 123 |
|
124 |
Window owner = target.getOwner(); |
|
20153 | 125 |
LWWindowPeer ownerPeer = owner == null ? null : |
126 |
(LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner); |
|
12047 | 127 |
PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null; |
128 |
||
129 |
// The delegate.initialize() needs a non-null GC on X11. |
|
130 |
GraphicsConfiguration gc = getTarget().getGraphicsConfiguration(); |
|
131 |
synchronized (getStateLock()) { |
|
132 |
// graphicsConfig should be updated according to the real window |
|
133 |
// bounds when the window is shown, see 4868278 |
|
134 |
this.graphicsConfig = gc; |
|
135 |
} |
|
136 |
||
137 |
if (!target.isFontSet()) { |
|
138 |
target.setFont(DEFAULT_FONT); |
|
139 |
} |
|
140 |
||
141 |
if (!target.isBackgroundSet()) { |
|
142 |
target.setBackground(SystemColor.window); |
|
143 |
} else { |
|
144 |
// first we check if user provided alpha for background. This is |
|
145 |
// similar to what Apple's Java do. |
|
146 |
// Since JDK7 we should rely on setOpacity() only. |
|
147 |
// this.opacity = c.getAlpha(); |
|
148 |
} |
|
149 |
||
150 |
if (!target.isForegroundSet()) { |
|
151 |
target.setForeground(SystemColor.windowText); |
|
152 |
// we should not call setForeground because it will call a repaint |
|
153 |
// which the peer may not be ready to do yet. |
|
154 |
} |
|
155 |
||
156 |
platformWindow.initialize(target, this, ownerDelegate); |
|
18241 | 157 |
|
158 |
// Init warning window(for applets) |
|
159 |
SecurityWarningWindow warn = null; |
|
20153 | 160 |
if (target.getWarningString() != null) { |
18241 | 161 |
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip |
162 |
// and TrayIcon balloon windows without a warning window. |
|
20153 | 163 |
if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) { |
18241 | 164 |
LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit(); |
165 |
warn = toolkit.createSecurityWarning(target, this); |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
warningWindow = warn; |
|
12047 | 170 |
} |
171 |
||
172 |
@Override |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
173 |
void initializeImpl() { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
174 |
super.initializeImpl(); |
18241 | 175 |
|
176 |
||
12047 | 177 |
if (getTarget() instanceof Frame) { |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
178 |
setTitle(((Frame) getTarget()).getTitle()); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
179 |
setState(((Frame) getTarget()).getExtendedState()); |
12047 | 180 |
} else if (getTarget() instanceof Dialog) { |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
181 |
setTitle(((Dialog) getTarget()).getTitle()); |
12047 | 182 |
} |
183 |
||
16892 | 184 |
updateAlwaysOnTopState(); |
12047 | 185 |
updateMinimumSize(); |
186 |
||
13233 | 187 |
final Shape shape = getTarget().getShape(); |
188 |
if (shape != null) { |
|
189 |
applyShape(Region.getInstance(shape, null)); |
|
190 |
} |
|
191 |
||
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
192 |
final float opacity = getTarget().getOpacity(); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
193 |
if (opacity < 1.0f) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
194 |
setOpacity(opacity); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
195 |
} |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
196 |
|
12047 | 197 |
setOpaque(getTarget().isOpaque()); |
198 |
||
199 |
updateInsets(platformWindow.getInsets()); |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
200 |
if (getSurfaceData() == null) { |
13233 | 201 |
replaceSurfaceData(false); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
202 |
} |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
203 |
activateDisplayListener(); |
12047 | 204 |
} |
205 |
||
206 |
// Just a helper method |
|
20153 | 207 |
@Override |
12047 | 208 |
public PlatformWindow getPlatformWindow() { |
209 |
return platformWindow; |
|
210 |
} |
|
211 |
||
212 |
@Override |
|
213 |
protected LWWindowPeer getWindowPeerOrSelf() { |
|
214 |
return this; |
|
215 |
} |
|
216 |
||
217 |
// ---- PEER METHODS ---- // |
|
218 |
||
219 |
@Override |
|
220 |
protected void disposeImpl() { |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
221 |
deactivateDisplayListener(); |
12047 | 222 |
SurfaceData oldData = getSurfaceData(); |
223 |
synchronized (surfaceDataLock){ |
|
224 |
surfaceData = null; |
|
225 |
} |
|
226 |
if (oldData != null) { |
|
227 |
oldData.invalidate(); |
|
228 |
} |
|
229 |
if (isGrabbing()) { |
|
230 |
ungrab(); |
|
231 |
} |
|
18241 | 232 |
if (warningWindow != null) { |
233 |
warningWindow.dispose(); |
|
234 |
} |
|
235 |
||
12047 | 236 |
platformWindow.dispose(); |
237 |
super.disposeImpl(); |
|
238 |
} |
|
239 |
||
240 |
@Override |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
241 |
protected void setVisibleImpl(final boolean visible) { |
18241 | 242 |
if (!visible && warningWindow != null) { |
243 |
warningWindow.setVisible(false, false); |
|
244 |
} |
|
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
245 |
updateFocusableWindowState(); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
246 |
super.setVisibleImpl(visible); |
12047 | 247 |
// TODO: update graphicsConfig, see 4868278 |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
248 |
platformWindow.setVisible(visible); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
249 |
if (isSimpleWindow()) { |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
250 |
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
251 |
if (visible) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
252 |
if (!getTarget().isAutoRequestFocus()) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
253 |
return; |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
254 |
} else { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
255 |
requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
256 |
} |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
257 |
// Focus the owner in case this window is focused. |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
258 |
} else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) { |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
259 |
// Transfer focus to the owner. |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
260 |
LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
261 |
if (owner != null) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
262 |
owner.requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION); |
12047 | 263 |
} |
264 |
} |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
265 |
} |
12047 | 266 |
} |
267 |
||
268 |
@Override |
|
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
269 |
public final GraphicsConfiguration getGraphicsConfiguration() { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
270 |
synchronized (getStateLock()) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
271 |
return graphicsConfig; |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
272 |
} |
12047 | 273 |
} |
274 |
||
275 |
@Override |
|
276 |
public boolean updateGraphicsData(GraphicsConfiguration gc) { |
|
277 |
setGraphicsConfig(gc); |
|
278 |
return false; |
|
279 |
} |
|
280 |
||
281 |
protected final Graphics getOnscreenGraphics(Color fg, Color bg, Font f) { |
|
282 |
if (getSurfaceData() == null) { |
|
283 |
return null; |
|
284 |
} |
|
285 |
if (fg == null) { |
|
286 |
fg = SystemColor.windowText; |
|
287 |
} |
|
288 |
if (bg == null) { |
|
289 |
bg = SystemColor.window; |
|
290 |
} |
|
291 |
if (f == null) { |
|
292 |
f = DEFAULT_FONT; |
|
293 |
} |
|
294 |
return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f)); |
|
295 |
} |
|
296 |
||
297 |
@Override |
|
298 |
public void setBounds(int x, int y, int w, int h, int op) { |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
299 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
300 |
if((op & NO_EMBEDDED_CHECK) == 0 && getPeerType() == PeerType.VIEW_EMBEDDED_FRAME) { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
301 |
return; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
302 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
303 |
|
12047 | 304 |
if ((op & SET_CLIENT_SIZE) != 0) { |
305 |
// SET_CLIENT_SIZE is only applicable to window peers, so handle it here |
|
306 |
// instead of pulling 'insets' field up to LWComponentPeer |
|
307 |
// no need to add insets since Window's notion of width and height includes insets. |
|
308 |
op &= ~SET_CLIENT_SIZE; |
|
309 |
op |= SET_SIZE; |
|
310 |
} |
|
311 |
||
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
312 |
// Don't post ComponentMoved/Resized and Paint events |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
313 |
// until we've got a notification from the delegate |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
314 |
Rectangle cb = constrainBounds(x, y, w, h); |
21247
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
315 |
|
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
316 |
Rectangle newBounds = new Rectangle(getBounds()); |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
317 |
if ((op & (SET_LOCATION | SET_BOUNDS)) != 0) { |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
318 |
newBounds.x = cb.x; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
319 |
newBounds.y = cb.y; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
320 |
} |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
321 |
if ((op & (SET_SIZE | SET_BOUNDS)) != 0) { |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
322 |
newBounds.width = cb.width; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
323 |
newBounds.height = cb.height; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
324 |
} |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
325 |
// Native system could constraint bounds, so the peer wold be updated in the callback |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
326 |
platformWindow.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height); |
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
327 |
} |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
328 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
329 |
public Rectangle constrainBounds(Rectangle bounds) { |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
330 |
return constrainBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
331 |
} |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
332 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
333 |
public Rectangle constrainBounds(int x, int y, int w, int h) { |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
334 |
|
12047 | 335 |
if (w < MINIMUM_WIDTH) { |
336 |
w = MINIMUM_WIDTH; |
|
337 |
} |
|
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
338 |
|
12047 | 339 |
if (h < MINIMUM_HEIGHT) { |
340 |
h = MINIMUM_HEIGHT; |
|
341 |
} |
|
342 |
||
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
343 |
final int maxW = getLWGC().getMaxTextureWidth(); |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
344 |
final int maxH = getLWGC().getMaxTextureHeight(); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
345 |
|
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
346 |
if (w > maxW) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
347 |
w = maxW; |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
348 |
} |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
349 |
if (h > maxH) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
350 |
h = maxH; |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
351 |
} |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
352 |
|
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
353 |
return new Rectangle(x, y, w, h); |
12047 | 354 |
} |
355 |
||
356 |
@Override |
|
357 |
public Point getLocationOnScreen() { |
|
358 |
return platformWindow.getLocationOnScreen(); |
|
359 |
} |
|
360 |
||
361 |
/** |
|
362 |
* Overridden from LWContainerPeer to return the correct insets. |
|
363 |
* Insets are queried from the delegate and are kept up to date by |
|
364 |
* requiering when needed (i.e. when the window geometry is changed). |
|
365 |
*/ |
|
366 |
@Override |
|
367 |
public Insets getInsets() { |
|
368 |
synchronized (getStateLock()) { |
|
369 |
return insets; |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
@Override |
|
374 |
public FontMetrics getFontMetrics(Font f) { |
|
375 |
// TODO: check for "use platform metrics" settings |
|
376 |
return platformWindow.getFontMetrics(f); |
|
377 |
} |
|
378 |
||
379 |
@Override |
|
380 |
public void toFront() { |
|
381 |
platformWindow.toFront(); |
|
382 |
} |
|
383 |
||
384 |
@Override |
|
385 |
public void toBack() { |
|
386 |
platformWindow.toBack(); |
|
387 |
} |
|
388 |
||
389 |
@Override |
|
390 |
public void setZOrder(ComponentPeer above) { |
|
391 |
throw new RuntimeException("not implemented"); |
|
392 |
} |
|
393 |
||
394 |
@Override |
|
16892 | 395 |
public void updateAlwaysOnTopState() { |
396 |
platformWindow.setAlwaysOnTop(getTarget().isAlwaysOnTop()); |
|
12047 | 397 |
} |
398 |
||
399 |
@Override |
|
400 |
public void updateFocusableWindowState() { |
|
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
401 |
targetFocusable = getTarget().isFocusableWindow(); |
12047 | 402 |
platformWindow.updateFocusableWindowState(); |
403 |
} |
|
404 |
||
405 |
@Override |
|
406 |
public void setModalBlocked(Dialog blocker, boolean blocked) { |
|
407 |
synchronized (getPeerTreeLock()) { |
|
20445
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
408 |
ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(blocker); |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
409 |
if (blocked && (peer instanceof LWWindowPeer)) { |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
410 |
this.blocker = (LWWindowPeer) peer; |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
411 |
} else { |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
412 |
this.blocker = null; |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
413 |
} |
12047 | 414 |
} |
12640 | 415 |
|
416 |
platformWindow.setModalBlocked(blocked); |
|
12047 | 417 |
} |
418 |
||
419 |
@Override |
|
420 |
public void updateMinimumSize() { |
|
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
421 |
final Dimension min; |
12047 | 422 |
if (getTarget().isMinimumSizeSet()) { |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
423 |
min = getTarget().getMinimumSize(); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
424 |
min.width = Math.max(min.width, MINIMUM_WIDTH); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
425 |
min.height = Math.max(min.height, MINIMUM_HEIGHT); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
426 |
} else { |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
427 |
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT); |
12047 | 428 |
} |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
429 |
|
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
430 |
final Dimension max; |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
431 |
if (getTarget().isMaximumSizeSet()) { |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
432 |
max = getTarget().getMaximumSize(); |
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
433 |
max.width = Math.min(max.width, getLWGC().getMaxTextureWidth()); |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
434 |
max.height = Math.min(max.height, getLWGC().getMaxTextureHeight()); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
435 |
} else { |
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
436 |
max = new Dimension(getLWGC().getMaxTextureWidth(), |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
437 |
getLWGC().getMaxTextureHeight()); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
438 |
} |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
439 |
|
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
440 |
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height); |
12047 | 441 |
} |
442 |
||
443 |
@Override |
|
444 |
public void updateIconImages() { |
|
445 |
getPlatformWindow().updateIconImages(); |
|
446 |
} |
|
447 |
||
448 |
@Override |
|
25196
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
449 |
public void setBackground(final Color c) { |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
450 |
super.setBackground(c); |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
451 |
updateOpaque(); |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
452 |
} |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
453 |
|
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
454 |
@Override |
12047 | 455 |
public void setOpacity(float opacity) { |
456 |
getPlatformWindow().setOpacity(opacity); |
|
457 |
repaintPeer(); |
|
458 |
} |
|
459 |
||
460 |
@Override |
|
461 |
public final void setOpaque(final boolean isOpaque) { |
|
462 |
if (this.isOpaque != isOpaque) { |
|
463 |
this.isOpaque = isOpaque; |
|
13233 | 464 |
updateOpaque(); |
12047 | 465 |
} |
466 |
} |
|
467 |
||
13233 | 468 |
private void updateOpaque() { |
469 |
getPlatformWindow().setOpaque(!isTranslucent()); |
|
470 |
replaceSurfaceData(false); |
|
471 |
repaintPeer(); |
|
12047 | 472 |
} |
473 |
||
474 |
@Override |
|
475 |
public void updateWindow() { |
|
13233 | 476 |
} |
477 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
478 |
public final boolean isTextured() { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
479 |
return textured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
480 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
481 |
|
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
482 |
public final void setTextured(final boolean isTextured) { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
483 |
textured = isTextured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
484 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
485 |
|
20153 | 486 |
@Override |
13233 | 487 |
public final boolean isTranslucent() { |
488 |
synchronized (getStateLock()) { |
|
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
489 |
/* |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
490 |
* Textured window is a special case of translucent window. |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
491 |
* The difference is only in nswindow background. So when we set |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
492 |
* texture property our peer became fully translucent. It doesn't |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
493 |
* fill background, create non opaque backbuffers and layer etc. |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
494 |
*/ |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
495 |
return !isOpaque || isShaped() || isTextured(); |
13233 | 496 |
} |
497 |
} |
|
498 |
||
499 |
@Override |
|
500 |
final void applyShapeImpl(final Region shape) { |
|
501 |
super.applyShapeImpl(shape); |
|
502 |
updateOpaque(); |
|
12047 | 503 |
} |
504 |
||
505 |
@Override |
|
506 |
public void repositionSecurityWarning() { |
|
18241 | 507 |
if (warningWindow != null) { |
508 |
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
|
509 |
Window target = getTarget(); |
|
510 |
int x = compAccessor.getX(target); |
|
511 |
int y = compAccessor.getY(target); |
|
512 |
int width = compAccessor.getWidth(target); |
|
513 |
int height = compAccessor.getHeight(target); |
|
514 |
warningWindow.reposition(x, y, width, height); |
|
515 |
} |
|
12047 | 516 |
} |
517 |
||
518 |
// ---- FRAME PEER METHODS ---- // |
|
519 |
||
520 |
@Override // FramePeer and DialogPeer |
|
521 |
public void setTitle(String title) { |
|
522 |
platformWindow.setTitle(title == null ? "" : title); |
|
523 |
} |
|
524 |
||
525 |
@Override |
|
526 |
public void setMenuBar(MenuBar mb) { |
|
527 |
platformWindow.setMenuBar(mb); |
|
528 |
} |
|
529 |
||
530 |
@Override // FramePeer and DialogPeer |
|
531 |
public void setResizable(boolean resizable) { |
|
532 |
platformWindow.setResizable(resizable); |
|
533 |
} |
|
534 |
||
535 |
@Override |
|
536 |
public void setState(int state) { |
|
537 |
platformWindow.setWindowState(state); |
|
538 |
} |
|
539 |
||
540 |
@Override |
|
541 |
public int getState() { |
|
542 |
return windowState; |
|
543 |
} |
|
544 |
||
545 |
@Override |
|
546 |
public void setMaximizedBounds(Rectangle bounds) { |
|
547 |
// TODO: not implemented |
|
548 |
} |
|
549 |
||
550 |
@Override |
|
551 |
public void setBoundsPrivate(int x, int y, int width, int height) { |
|
552 |
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK); |
|
553 |
} |
|
554 |
||
555 |
@Override |
|
556 |
public Rectangle getBoundsPrivate() { |
|
557 |
throw new RuntimeException("not implemented"); |
|
558 |
} |
|
559 |
||
560 |
// ---- DIALOG PEER METHODS ---- // |
|
561 |
||
562 |
@Override |
|
563 |
public void blockWindows(List<Window> windows) { |
|
564 |
//TODO: LWX will probably need some collectJavaToplevels to speed this up |
|
565 |
for (Window w : windows) { |
|
20153 | 566 |
WindowPeer wp = |
567 |
(WindowPeer) AWTAccessor.getComponentAccessor().getPeer(w); |
|
12047 | 568 |
if (wp != null) { |
569 |
wp.setModalBlocked((Dialog)getTarget(), true); |
|
570 |
} |
|
571 |
} |
|
572 |
} |
|
573 |
||
574 |
// ---- PEER NOTIFICATIONS ---- // |
|
575 |
||
18241 | 576 |
@Override |
12047 | 577 |
public void notifyIconify(boolean iconify) { |
578 |
//The toplevel target is Frame and states are applicable to it. |
|
579 |
//Otherwise, the target is Window and it don't have state property. |
|
580 |
//Hopefully, no such events are posted in the queue so consider the |
|
581 |
//target as Frame in all cases. |
|
582 |
||
583 |
// REMIND: should we send it anyway if the state not changed since last |
|
584 |
// time? |
|
585 |
WindowEvent iconifyEvent = new WindowEvent(getTarget(), |
|
586 |
iconify ? WindowEvent.WINDOW_ICONIFIED |
|
587 |
: WindowEvent.WINDOW_DEICONIFIED); |
|
588 |
postEvent(iconifyEvent); |
|
589 |
||
590 |
int newWindowState = iconify ? Frame.ICONIFIED : Frame.NORMAL; |
|
591 |
postWindowStateChangedEvent(newWindowState); |
|
592 |
||
593 |
// REMIND: RepaintManager doesn't repaint iconified windows and |
|
594 |
// hence ignores any repaint request during deiconification. |
|
595 |
// So, we need to repaint window explicitly when it becomes normal. |
|
596 |
if (!iconify) { |
|
597 |
repaintPeer(); |
|
598 |
} |
|
599 |
} |
|
600 |
||
18241 | 601 |
@Override |
12047 | 602 |
public void notifyZoom(boolean isZoomed) { |
603 |
int newWindowState = isZoomed ? Frame.MAXIMIZED_BOTH : Frame.NORMAL; |
|
604 |
postWindowStateChangedEvent(newWindowState); |
|
605 |
} |
|
606 |
||
607 |
/** |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
608 |
* Called by the {@code PlatformWindow} when any part of the window should |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
609 |
* be repainted. |
12047 | 610 |
*/ |
18241 | 611 |
@Override |
612 |
public void notifyExpose(final Rectangle r) { |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
613 |
repaintPeer(r); |
12047 | 614 |
} |
615 |
||
616 |
/** |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
617 |
* Called by the {@code PlatformWindow} when this window is moved/resized by |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
618 |
* user or window insets are changed. There's no notifyReshape() in |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
619 |
* LWComponentPeer as the only components which could be resized by user are |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
620 |
* top-level windows. |
12047 | 621 |
*/ |
18241 | 622 |
@Override |
623 |
public void notifyReshape(int x, int y, int w, int h) { |
|
21247
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
624 |
Rectangle oldBounds = getBounds(); |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
625 |
final boolean invalid = updateInsets(platformWindow.getInsets()); |
21247
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
626 |
final boolean moved = (x != oldBounds.x) || (y != oldBounds.y); |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
627 |
final boolean resized = (w != oldBounds.width) || (h != oldBounds.height); |
12047 | 628 |
|
629 |
// Check if anything changed |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
630 |
if (!moved && !resized && !invalid) { |
12047 | 631 |
return; |
632 |
} |
|
633 |
// First, update peer's bounds |
|
634 |
setBounds(x, y, w, h, SET_BOUNDS, false, false); |
|
635 |
||
636 |
// Second, update the graphics config and surface data |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
637 |
final boolean isNewDevice = updateGraphicsDevice(); |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
638 |
if (resized || isNewDevice) { |
12047 | 639 |
replaceSurfaceData(); |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
640 |
updateMinimumSize(); |
12047 | 641 |
} |
642 |
||
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
643 |
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
644 |
if (moved || invalid) { |
12047 | 645 |
handleMove(x, y, true); |
646 |
} |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
647 |
if (resized || invalid || isNewDevice) { |
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
648 |
handleResize(w, h, true); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
649 |
repaintPeer(); |
12047 | 650 |
} |
18241 | 651 |
|
652 |
repositionSecurityWarning(); |
|
12047 | 653 |
} |
654 |
||
655 |
private void clearBackground(final int w, final int h) { |
|
656 |
final Graphics g = getOnscreenGraphics(getForeground(), getBackground(), |
|
657 |
getFont()); |
|
658 |
if (g != null) { |
|
659 |
try { |
|
13233 | 660 |
if (g instanceof Graphics2D) { |
661 |
((Graphics2D) g).setComposite(AlphaComposite.Src); |
|
662 |
} |
|
663 |
if (isTranslucent()) { |
|
664 |
g.setColor(nonOpaqueBackground); |
|
665 |
g.fillRect(0, 0, w, h); |
|
666 |
} |
|
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
667 |
if (!isTextured()) { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
668 |
if (g instanceof SunGraphics2D) { |
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
669 |
((SunGraphics2D) g).constrain(0, 0, w, h, getRegion()); |
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
670 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
671 |
g.setColor(getBackground()); |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
672 |
g.fillRect(0, 0, w, h); |
13233 | 673 |
} |
12047 | 674 |
} finally { |
675 |
g.dispose(); |
|
676 |
} |
|
677 |
} |
|
678 |
} |
|
679 |
||
18241 | 680 |
@Override |
12047 | 681 |
public void notifyUpdateCursor() { |
682 |
getLWToolkit().getCursorManager().updateCursorLater(this); |
|
683 |
} |
|
684 |
||
18241 | 685 |
@Override |
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
686 |
public void notifyActivation(boolean activation, LWWindowPeer opposite) { |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
687 |
Window oppositeWindow = (opposite == null)? null : opposite.getTarget(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
688 |
changeFocusedWindow(activation, oppositeWindow); |
12047 | 689 |
} |
690 |
||
691 |
// MouseDown in non-client area |
|
18241 | 692 |
@Override |
12047 | 693 |
public void notifyNCMouseDown() { |
694 |
// Ungrab except for a click on a Dialog with the grabbing owner |
|
695 |
if (grabbingWindow != null && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
696 |
!grabbingWindow.isOneOfOwnersOf(this)) |
12047 | 697 |
{ |
698 |
grabbingWindow.ungrab(); |
|
699 |
} |
|
700 |
} |
|
701 |
||
702 |
// ---- EVENTS ---- // |
|
703 |
||
704 |
/* |
|
705 |
* Called by the delegate to dispatch the event to Java. Event |
|
706 |
* coordinates are relative to non-client window are, i.e. the top-left |
|
707 |
* point of the client area is (insets.top, insets.left). |
|
708 |
*/ |
|
18241 | 709 |
@Override |
710 |
public void notifyMouseEvent(int id, long when, int button, |
|
711 |
int x, int y, int screenX, int screenY, |
|
712 |
int modifiers, int clickCount, boolean popupTrigger, |
|
713 |
byte[] bdata) |
|
12047 | 714 |
{ |
715 |
// TODO: fill "bdata" member of AWTEvent |
|
716 |
Rectangle r = getBounds(); |
|
717 |
// findPeerAt() expects parent coordinates |
|
20153 | 718 |
LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y); |
12047 | 719 |
|
720 |
if (id == MouseEvent.MOUSE_EXITED) { |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
721 |
isMouseOver = false; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
722 |
if (lastMouseEventPeer != null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
723 |
if (lastMouseEventPeer.isEnabled()) { |
12047 | 724 |
Point lp = lastMouseEventPeer.windowToLocal(x, y, |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
725 |
this); |
18241 | 726 |
Component target = lastMouseEventPeer.getTarget(); |
727 |
postMouseExitedEvent(target, when, modifiers, lp, |
|
728 |
screenX, screenY, clickCount, popupTrigger, button); |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
729 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
730 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
731 |
// Sometimes we may get MOUSE_EXITED after lastCommonMouseEventPeer is switched |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
732 |
// to a peer from another window. So we must first check if this peer is |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
733 |
// the same as lastWindowPeer |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
734 |
if (lastCommonMouseEventPeer != null && lastCommonMouseEventPeer.getWindowPeerOrSelf() == this) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
735 |
lastCommonMouseEventPeer = null; |
12047 | 736 |
} |
737 |
lastMouseEventPeer = null; |
|
738 |
} |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
739 |
} else if(id == MouseEvent.MOUSE_ENTERED) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
740 |
isMouseOver = true; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
741 |
if (targetPeer != null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
742 |
if (targetPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
743 |
Point lp = targetPeer.windowToLocal(x, y, this); |
18241 | 744 |
Component target = targetPeer.getTarget(); |
745 |
postMouseEnteredEvent(target, when, modifiers, lp, |
|
746 |
screenX, screenY, clickCount, popupTrigger, button); |
|
12047 | 747 |
} |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
748 |
lastCommonMouseEventPeer = targetPeer; |
12047 | 749 |
lastMouseEventPeer = targetPeer; |
750 |
} |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
751 |
} else { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
752 |
PlatformWindow topmostPlatforWindow = |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
753 |
platformWindow.getTopmostPlatformWindowUnderMouse(); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
754 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
755 |
LWWindowPeer topmostWindowPeer = |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
756 |
topmostPlatforWindow != null ? topmostPlatforWindow.getPeer() : null; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
757 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
758 |
// topmostWindowPeer == null condition is added for the backward |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
759 |
// compatibility with applets. It can be removed when the |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
760 |
// getTopmostPlatformWindowUnderMouse() method will be properly |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
761 |
// implemented in CPlatformEmbeddedFrame class |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
762 |
if (topmostWindowPeer == this || topmostWindowPeer == null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
763 |
generateMouseEnterExitEventsForComponents(when, button, x, y, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
764 |
screenX, screenY, modifiers, clickCount, popupTrigger, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
765 |
targetPeer); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
766 |
} else { |
20153 | 767 |
LWComponentPeer<?, ?> topmostTargetPeer = |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
768 |
topmostWindowPeer != null ? topmostWindowPeer.findPeerAt(r.x + x, r.y + y) : null; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
769 |
topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
770 |
screenX, screenY, modifiers, clickCount, popupTrigger, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
771 |
topmostTargetPeer); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
772 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
773 |
|
12047 | 774 |
// TODO: fill "bdata" member of AWTEvent |
775 |
||
776 |
int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0; |
|
777 |
int otherButtonsPressed = modifiers & ~eventButtonMask; |
|
778 |
||
779 |
// For pressed/dragged/released events OS X treats other |
|
780 |
// mouse buttons as if they were BUTTON2, so we do the same |
|
781 |
int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1; |
|
782 |
||
783 |
// MOUSE_ENTERED/EXITED are generated for the components strictly under |
|
784 |
// mouse even when dragging. That's why we first update lastMouseEventPeer |
|
785 |
// based on initial targetPeer value and only then recalculate targetPeer |
|
786 |
// for MOUSE_DRAGGED/RELEASED events |
|
787 |
if (id == MouseEvent.MOUSE_PRESSED) { |
|
788 |
||
789 |
// Ungrab only if this window is not an owned window of the grabbing one. |
|
790 |
if (!isGrabbing() && grabbingWindow != null && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
791 |
!grabbingWindow.isOneOfOwnersOf(this)) |
12047 | 792 |
{ |
793 |
grabbingWindow.ungrab(); |
|
794 |
} |
|
795 |
if (otherButtonsPressed == 0) { |
|
796 |
mouseClickButtons = eventButtonMask; |
|
797 |
} else { |
|
798 |
mouseClickButtons |= eventButtonMask; |
|
799 |
} |
|
800 |
||
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
801 |
// The window should be focused on mouse click. If it gets activated by the native platform, |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
802 |
// this request will be no op. It will take effect when: |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
803 |
// 1. A simple not focused window is clicked. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
804 |
// 2. An active but not focused owner frame/dialog is clicked. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
805 |
// The mouse event then will trigger a focus request "in window" to the component, so the window |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
806 |
// should gain focus before. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
807 |
requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
808 |
|
12047 | 809 |
mouseDownTarget[targetIdx] = targetPeer; |
810 |
} else if (id == MouseEvent.MOUSE_DRAGGED) { |
|
811 |
// Cocoa dragged event has the information about which mouse |
|
812 |
// button is being dragged. Use it to determine the peer that |
|
813 |
// should receive the dragged event. |
|
814 |
targetPeer = mouseDownTarget[targetIdx]; |
|
815 |
mouseClickButtons &= ~modifiers; |
|
816 |
} else if (id == MouseEvent.MOUSE_RELEASED) { |
|
817 |
// TODO: currently, mouse released event goes to the same component |
|
818 |
// that received corresponding mouse pressed event. For most cases, |
|
819 |
// it's OK, however, we need to make sure that our behavior is consistent |
|
820 |
// with 1.6 for cases where component in question have been |
|
821 |
// hidden/removed in between of mouse pressed/released events. |
|
822 |
targetPeer = mouseDownTarget[targetIdx]; |
|
823 |
||
824 |
if ((modifiers & eventButtonMask) == 0) { |
|
825 |
mouseDownTarget[targetIdx] = null; |
|
826 |
} |
|
827 |
||
828 |
// mouseClickButtons is updated below, after MOUSE_CLICK is sent |
|
829 |
} |
|
830 |
||
831 |
if (targetPeer == null) { |
|
832 |
//TODO This can happen if this window is invisible. this is correct behavior in this case? |
|
833 |
targetPeer = this; |
|
834 |
} |
|
835 |
||
836 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
837 |
Point lp = targetPeer.windowToLocal(x, y, this); |
12047 | 838 |
if (targetPeer.isEnabled()) { |
839 |
MouseEvent event = new MouseEvent(targetPeer.getTarget(), id, |
|
840 |
when, modifiers, lp.x, lp.y, |
|
841 |
screenX, screenY, clickCount, |
|
842 |
popupTrigger, button); |
|
843 |
postEvent(event); |
|
844 |
} |
|
845 |
||
846 |
if (id == MouseEvent.MOUSE_RELEASED) { |
|
847 |
if ((mouseClickButtons & eventButtonMask) != 0 |
|
848 |
&& targetPeer.isEnabled()) { |
|
849 |
postEvent(new MouseEvent(targetPeer.getTarget(), |
|
850 |
MouseEvent.MOUSE_CLICKED, |
|
851 |
when, modifiers, |
|
852 |
lp.x, lp.y, screenX, screenY, |
|
853 |
clickCount, popupTrigger, button)); |
|
854 |
} |
|
855 |
mouseClickButtons &= ~eventButtonMask; |
|
856 |
} |
|
857 |
} |
|
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
858 |
notifyUpdateCursor(); |
12047 | 859 |
} |
860 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
861 |
private void generateMouseEnterExitEventsForComponents(long when, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
862 |
int button, int x, int y, int screenX, int screenY, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
863 |
int modifiers, int clickCount, boolean popupTrigger, |
20153 | 864 |
final LWComponentPeer<?, ?> targetPeer) { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
865 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
866 |
if (!isMouseOver || targetPeer == lastMouseEventPeer) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
867 |
return; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
868 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
869 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
870 |
// Generate Mouse Exit for components |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
871 |
if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
872 |
Point oldp = lastMouseEventPeer.windowToLocal(x, y, this); |
18241 | 873 |
Component target = lastMouseEventPeer.getTarget(); |
874 |
postMouseExitedEvent(target, when, modifiers, oldp, screenX, screenY, |
|
875 |
clickCount, popupTrigger, button); |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
876 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
877 |
lastCommonMouseEventPeer = targetPeer; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
878 |
lastMouseEventPeer = targetPeer; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
879 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
880 |
// Generate Mouse Enter for components |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
881 |
if (targetPeer != null && targetPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
882 |
Point newp = targetPeer.windowToLocal(x, y, this); |
18241 | 883 |
Component target = targetPeer.getTarget(); |
884 |
postMouseEnteredEvent(target, when, modifiers, newp, screenX, screenY, clickCount, popupTrigger, button); |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
885 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
886 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
887 |
|
18241 | 888 |
private void postMouseEnteredEvent(Component target, long when, int modifiers, |
889 |
Point loc, int xAbs, int yAbs, |
|
890 |
int clickCount, boolean popupTrigger, int button) { |
|
891 |
||
892 |
updateSecurityWarningVisibility(); |
|
893 |
||
894 |
postEvent(new MouseEvent(target, |
|
895 |
MouseEvent.MOUSE_ENTERED, |
|
896 |
when, modifiers, |
|
897 |
loc.x, loc.y, xAbs, yAbs, |
|
898 |
clickCount, popupTrigger, button)); |
|
899 |
} |
|
900 |
||
901 |
private void postMouseExitedEvent(Component target, long when, int modifiers, |
|
902 |
Point loc, int xAbs, int yAbs, |
|
903 |
int clickCount, boolean popupTrigger, int button) { |
|
904 |
||
905 |
updateSecurityWarningVisibility(); |
|
906 |
||
907 |
postEvent(new MouseEvent(target, |
|
908 |
MouseEvent.MOUSE_EXITED, |
|
909 |
when, modifiers, |
|
910 |
loc.x, loc.y, xAbs, yAbs, |
|
911 |
clickCount, popupTrigger, button)); |
|
912 |
} |
|
913 |
||
914 |
@Override |
|
915 |
public void notifyMouseWheelEvent(long when, int x, int y, int modifiers, |
|
916 |
int scrollType, int scrollAmount, |
|
917 |
int wheelRotation, double preciseWheelRotation, |
|
918 |
byte[] bdata) |
|
12047 | 919 |
{ |
920 |
// TODO: could we just use the last mouse event target here? |
|
921 |
Rectangle r = getBounds(); |
|
922 |
// findPeerAt() expects parent coordinates |
|
20153 | 923 |
final LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y); |
12047 | 924 |
if (targetPeer == null || !targetPeer.isEnabled()) { |
925 |
return; |
|
926 |
} |
|
927 |
||
928 |
Point lp = targetPeer.windowToLocal(x, y, this); |
|
929 |
// TODO: fill "bdata" member of AWTEvent |
|
930 |
// TODO: screenX/screenY |
|
931 |
postEvent(new MouseWheelEvent(targetPeer.getTarget(), |
|
932 |
MouseEvent.MOUSE_WHEEL, |
|
933 |
when, modifiers, |
|
934 |
lp.x, lp.y, |
|
935 |
0, 0, /* screenX, Y */ |
|
936 |
0 /* clickCount */, false /* popupTrigger */, |
|
937 |
scrollType, scrollAmount, |
|
938 |
wheelRotation, preciseWheelRotation)); |
|
939 |
} |
|
940 |
||
941 |
/* |
|
942 |
* Called by the delegate when a key is pressed. |
|
943 |
*/ |
|
18241 | 944 |
@Override |
945 |
public void notifyKeyEvent(int id, long when, int modifiers, |
|
946 |
int keyCode, char keyChar, int keyLocation) |
|
12047 | 947 |
{ |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
948 |
LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
949 |
Component focusOwner = kfmPeer.getCurrentFocusOwner(); |
12047 | 950 |
|
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
951 |
if (focusOwner == null) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
952 |
focusOwner = kfmPeer.getCurrentFocusedWindow(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
953 |
if (focusOwner == null) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
954 |
focusOwner = this.getTarget(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
955 |
} |
12047 | 956 |
} |
20109
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
957 |
|
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
958 |
KeyEvent keyEvent = new KeyEvent(focusOwner, id, when, modifiers, |
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
959 |
keyCode, keyChar, keyLocation); |
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
960 |
AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent, |
21783
a3863a1446bf
8025126: [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X
alexsch
parents:
21247
diff
changeset
|
961 |
(keyChar == KeyEvent.CHAR_UNDEFINED) ? keyCode |
a3863a1446bf
8025126: [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X
alexsch
parents:
21247
diff
changeset
|
962 |
: ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar)); |
20109
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
963 |
postEvent(keyEvent); |
12047 | 964 |
} |
965 |
||
966 |
// ---- UTILITY METHODS ---- // |
|
967 |
||
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
968 |
private void activateDisplayListener() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
969 |
final GraphicsEnvironment ge = |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
970 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
971 |
((SunGraphicsEnvironment) ge).addDisplayChangedListener(this); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
972 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
973 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
974 |
private void deactivateDisplayListener() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
975 |
final GraphicsEnvironment ge = |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
976 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
977 |
((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
978 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
979 |
|
12047 | 980 |
private void postWindowStateChangedEvent(int newWindowState) { |
981 |
if (getTarget() instanceof Frame) { |
|
982 |
AWTAccessor.getFrameAccessor().setExtendedState( |
|
983 |
(Frame)getTarget(), newWindowState); |
|
984 |
} |
|
18241 | 985 |
|
12047 | 986 |
WindowEvent stateChangedEvent = new WindowEvent(getTarget(), |
987 |
WindowEvent.WINDOW_STATE_CHANGED, |
|
988 |
windowState, newWindowState); |
|
989 |
postEvent(stateChangedEvent); |
|
990 |
windowState = newWindowState; |
|
18241 | 991 |
|
992 |
updateSecurityWarningVisibility(); |
|
12047 | 993 |
} |
994 |
||
995 |
private static int getGraphicsConfigScreen(GraphicsConfiguration gc) { |
|
996 |
// TODO: this method can be implemented in a more |
|
997 |
// efficient way by forwarding to the delegate |
|
998 |
GraphicsDevice gd = gc.getDevice(); |
|
999 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
1000 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
|
1001 |
for (int i = 0; i < gds.length; i++) { |
|
1002 |
if (gds[i] == gd) { |
|
1003 |
return i; |
|
1004 |
} |
|
1005 |
} |
|
1006 |
// Should never happen if gc is a screen device config |
|
1007 |
return 0; |
|
1008 |
} |
|
1009 |
||
1010 |
/* |
|
1011 |
* This method is called when window's graphics config is changed from |
|
1012 |
* the app code (e.g. when the window is made non-opaque) or when |
|
1013 |
* the window is moved to another screen by user. |
|
1014 |
* |
|
1015 |
* Returns true if the graphics config has been changed, false otherwise. |
|
1016 |
*/ |
|
1017 |
private boolean setGraphicsConfig(GraphicsConfiguration gc) { |
|
1018 |
synchronized (getStateLock()) { |
|
1019 |
if (graphicsConfig == gc) { |
|
1020 |
return false; |
|
1021 |
} |
|
1022 |
// If window's graphics config is changed from the app code, the |
|
1023 |
// config correspond to the same device as before; when the window |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1024 |
// is moved by user, graphicsDevice is updated in notifyReshape(). |
12047 | 1025 |
// In either case, there's nothing to do with screenOn here |
1026 |
graphicsConfig = gc; |
|
1027 |
} |
|
1028 |
// SurfaceData is replaced later in updateGraphicsData() |
|
1029 |
return true; |
|
1030 |
} |
|
1031 |
||
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1032 |
/** |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1033 |
* Returns true if the GraphicsDevice has been changed, false otherwise. |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1034 |
*/ |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1035 |
public boolean updateGraphicsDevice() { |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1036 |
GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice(); |
12047 | 1037 |
synchronized (getStateLock()) { |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1038 |
if (graphicsDevice == newGraphicsDevice) { |
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1039 |
return false; |
12047 | 1040 |
} |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1041 |
graphicsDevice = newGraphicsDevice; |
12047 | 1042 |
} |
1043 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1044 |
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1045 |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1046 |
if (!setGraphicsConfig(newGC)) return false; |
12047 | 1047 |
|
1048 |
SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() { |
|
1049 |
public void run() { |
|
1050 |
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC); |
|
1051 |
} |
|
1052 |
}); |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1053 |
return true; |
12047 | 1054 |
} |
1055 |
||
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1056 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1057 |
public final void displayChanged() { |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1058 |
if (updateGraphicsDevice()) { |
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1059 |
updateMinimumSize(); |
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1060 |
} |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1061 |
// Replace surface unconditionally, because internal state of the |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1062 |
// GraphicsDevice could be changed. |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1063 |
replaceSurfaceData(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1064 |
repaintPeer(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1065 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1066 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1067 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1068 |
public final void paletteChanged() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1069 |
// components do not need to react to this event. |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1070 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1071 |
|
12047 | 1072 |
/* |
1073 |
* May be called by delegate to provide SD to Java2D code. |
|
1074 |
*/ |
|
1075 |
public SurfaceData getSurfaceData() { |
|
1076 |
synchronized (surfaceDataLock) { |
|
1077 |
return surfaceData; |
|
1078 |
} |
|
1079 |
} |
|
1080 |
||
1081 |
private void replaceSurfaceData() { |
|
13233 | 1082 |
replaceSurfaceData(true); |
1083 |
} |
|
1084 |
||
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
1085 |
private void replaceSurfaceData(final boolean blit) { |
12047 | 1086 |
synchronized (surfaceDataLock) { |
1087 |
final SurfaceData oldData = getSurfaceData(); |
|
1088 |
surfaceData = platformWindow.replaceSurfaceData(); |
|
1089 |
final Rectangle size = getSize(); |
|
1090 |
if (getSurfaceData() != null && oldData != getSurfaceData()) { |
|
1091 |
clearBackground(size.width, size.height); |
|
1092 |
} |
|
13233 | 1093 |
|
1094 |
if (blit) { |
|
1095 |
blitSurfaceData(oldData, getSurfaceData()); |
|
1096 |
} |
|
12047 | 1097 |
|
1098 |
if (oldData != null && oldData != getSurfaceData()) { |
|
1099 |
// TODO: drop oldData for D3D/WGL pipelines |
|
1100 |
// This can only happen when this peer is being created |
|
1101 |
oldData.flush(); |
|
1102 |
} |
|
1103 |
} |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1104 |
flushOnscreenGraphics(); |
12047 | 1105 |
} |
1106 |
||
1107 |
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) { |
|
1108 |
//TODO blit. proof-of-concept |
|
1109 |
if (src != dst && src != null && dst != null |
|
1110 |
&& !(dst instanceof NullSurfaceData) |
|
1111 |
&& !(src instanceof NullSurfaceData) |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1112 |
&& src.getSurfaceType().equals(dst.getSurfaceType()) |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1113 |
&& src.getDefaultScale() == dst.getDefaultScale()) { |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1114 |
final Rectangle size = src.getBounds(); |
12047 | 1115 |
final Blit blit = Blit.locate(src.getSurfaceType(), |
1116 |
CompositeType.Src, |
|
1117 |
dst.getSurfaceType()); |
|
1118 |
if (blit != null) { |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1119 |
blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0, |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1120 |
size.width, size.height); |
12047 | 1121 |
} |
1122 |
} |
|
1123 |
} |
|
1124 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1125 |
/** |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1126 |
* Request the window insets from the delegate and compares it with the |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1127 |
* current one. This method is mostly called by the delegate, e.g. when the |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1128 |
* window state is changed and insets should be recalculated. |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1129 |
* <p/> |
12047 | 1130 |
* This method may be called on the toolkit thread. |
1131 |
*/ |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1132 |
public final boolean updateInsets(final Insets newInsets) { |
12047 | 1133 |
synchronized (getStateLock()) { |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1134 |
if (insets.equals(newInsets)) { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1135 |
return false; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1136 |
} |
12047 | 1137 |
insets = newInsets; |
1138 |
} |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1139 |
return true; |
12047 | 1140 |
} |
1141 |
||
1142 |
public static LWWindowPeer getWindowUnderCursor() { |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
1143 |
return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null; |
12047 | 1144 |
} |
1145 |
||
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1146 |
public static LWComponentPeer<?, ?> getPeerUnderCursor() { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
1147 |
return lastCommonMouseEventPeer; |
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1148 |
} |
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1149 |
|
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1150 |
/* |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1151 |
* Requests platform to set native focus on a frame/dialog. |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1152 |
* In case of a simple window, triggers appropriate java focus change. |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1153 |
*/ |
12047 | 1154 |
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1155 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1156 |
focusLog.fine("requesting native focus to " + this); |
1157 |
} |
|
1158 |
||
1159 |
if (!focusAllowedFor()) { |
|
1160 |
focusLog.fine("focus is not allowed"); |
|
1161 |
return false; |
|
1162 |
} |
|
1163 |
||
12176 | 1164 |
if (platformWindow.rejectFocusRequest(cause)) { |
12047 | 1165 |
return false; |
1166 |
} |
|
1167 |
||
20448
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1168 |
AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget()); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1169 |
KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor() |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1170 |
.getCurrentKeyboardFocusManager(targetAppContext); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1171 |
Window currentActive = kfm.getActiveWindow(); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1172 |
|
12047 | 1173 |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1174 |
Window opposite = LWKeyboardFocusManagerPeer.getInstance(). |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1175 |
getCurrentFocusedWindow(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1176 |
|
12047 | 1177 |
// Make the owner active window. |
1178 |
if (isSimpleWindow()) { |
|
1179 |
LWWindowPeer owner = getOwnerFrameDialog(this); |
|
1180 |
||
1181 |
// If owner is not natively active, request native |
|
1182 |
// activation on it w/o sending events up to java. |
|
1183 |
if (owner != null && !owner.platformWindow.isActive()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1184 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1185 |
focusLog.fine("requesting native focus to the owner " + owner); |
1186 |
} |
|
20153 | 1187 |
LWWindowPeer currentActivePeer = currentActive == null ? null : |
1188 |
(LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer( |
|
1189 |
currentActive); |
|
12047 | 1190 |
|
1191 |
// Ensure the opposite is natively active and suppress sending events. |
|
1192 |
if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1193 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1194 |
focusLog.fine("the opposite is " + currentActivePeer); |
1195 |
} |
|
1196 |
currentActivePeer.skipNextFocusChange = true; |
|
1197 |
} |
|
1198 |
owner.skipNextFocusChange = true; |
|
1199 |
||
1200 |
owner.platformWindow.requestWindowFocus(); |
|
1201 |
} |
|
1202 |
||
1203 |
// DKFM will synthesize all the focus/activation events correctly. |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1204 |
changeFocusedWindow(true, opposite); |
12047 | 1205 |
return true; |
1206 |
||
1207 |
// In case the toplevel is active but not focused, change focus directly, |
|
1208 |
// as requesting native focus on it will not have effect. |
|
1209 |
} else if (getTarget() == currentActive && !getTarget().hasFocus()) { |
|
1210 |
||
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1211 |
changeFocusedWindow(true, opposite); |
12047 | 1212 |
return true; |
1213 |
} |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1214 |
|
12047 | 1215 |
return platformWindow.requestWindowFocus(); |
1216 |
} |
|
1217 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1218 |
protected boolean focusAllowedFor() { |
12047 | 1219 |
Window window = getTarget(); |
1220 |
// TODO: check if modal blocked |
|
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1221 |
return window.isVisible() && window.isEnabled() && isFocusableWindow(); |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1222 |
} |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1223 |
|
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1224 |
private boolean isFocusableWindow() { |
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
1225 |
boolean focusable = targetFocusable; |
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1226 |
if (isSimpleWindow()) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1227 |
LWWindowPeer ownerPeer = getOwnerFrameDialog(this); |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1228 |
if (ownerPeer == null) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1229 |
return false; |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1230 |
} |
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
1231 |
return focusable && ownerPeer.targetFocusable; |
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1232 |
} |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1233 |
return focusable; |
12047 | 1234 |
} |
1235 |
||
1236 |
public boolean isSimpleWindow() { |
|
1237 |
Window window = getTarget(); |
|
1238 |
return !(window instanceof Dialog || window instanceof Frame); |
|
1239 |
} |
|
1240 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1241 |
@Override |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1242 |
public void emulateActivation(boolean activate) { |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1243 |
changeFocusedWindow(activate, null); |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1244 |
} |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1245 |
|
28235
0dfebfcb9f8a
8067086: Suppress mac-specific deprecation warnings in the java.desktop module
darcy
parents:
26037
diff
changeset
|
1246 |
@SuppressWarnings("deprecation") |
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1247 |
private boolean isOneOfOwnersOf(LWWindowPeer peer) { |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1248 |
Window owner = (peer != null ? peer.getTarget().getOwner() : null); |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1249 |
while (owner != null) { |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1250 |
if ((LWWindowPeer)owner.getPeer() == this) { |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1251 |
return true; |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1252 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1253 |
owner = owner.getOwner(); |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1254 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1255 |
return false; |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1256 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1257 |
|
12047 | 1258 |
/* |
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1259 |
* Changes focused window on java level. |
12047 | 1260 |
*/ |
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1261 |
protected void changeFocusedWindow(boolean becomesFocused, Window opposite) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1262 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1263 |
focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this); |
1264 |
} |
|
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1265 |
if (skipNextFocusChange) { |
12047 | 1266 |
focusLog.fine("skipping focus change"); |
1267 |
skipNextFocusChange = false; |
|
1268 |
return; |
|
1269 |
} |
|
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1270 |
if (!isFocusableWindow() && becomesFocused) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1271 |
focusLog.fine("the window is not focusable"); |
12047 | 1272 |
return; |
1273 |
} |
|
1274 |
if (becomesFocused) { |
|
1275 |
synchronized (getPeerTreeLock()) { |
|
1276 |
if (blocker != null) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1277 |
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) { |
12047 | 1278 |
focusLog.finest("the window is blocked by " + blocker); |
1279 |
} |
|
1280 |
return; |
|
1281 |
} |
|
1282 |
} |
|
1283 |
} |
|
1284 |
||
1285 |
// Note, the method is not called: |
|
1286 |
// - when the opposite (gaining focus) window is an owned/owner window. |
|
1287 |
// - for a simple window in any case. |
|
1288 |
if (!becomesFocused && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1289 |
(isGrabbing() || this.isOneOfOwnersOf(grabbingWindow))) |
12047 | 1290 |
{ |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1291 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
15983
diff
changeset
|
1292 |
focusLog.fine("ungrabbing on " + grabbingWindow); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
15983
diff
changeset
|
1293 |
} |
12047 | 1294 |
// ungrab a simple window if its owner looses activation. |
1295 |
grabbingWindow.ungrab(); |
|
1296 |
} |
|
1297 |
||
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1298 |
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
29884
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1299 |
|
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1300 |
if (!becomesFocused && kfmPeer.getCurrentFocusedWindow() != getTarget()) { |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1301 |
// late window focus lost event - ingoring |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1302 |
return; |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1303 |
} |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1304 |
|
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
1305 |
kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null); |
12047 | 1306 |
|
1307 |
int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS; |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1308 |
WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, opposite, System.currentTimeMillis()); |
12047 | 1309 |
|
1310 |
// TODO: wrap in SequencedEvent |
|
1311 |
postEvent(windowEvent); |
|
1312 |
} |
|
1313 |
||
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1314 |
/* |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1315 |
* Retrieves the owner of the peer. |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1316 |
* Note: this method returns the owner which can be activated, (i.e. the instance |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1317 |
* of Frame or Dialog may be returned). |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1318 |
*/ |
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1319 |
static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) { |
12047 | 1320 |
Window owner = (peer != null ? peer.getTarget().getOwner() : null); |
1321 |
while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { |
|
1322 |
owner = owner.getOwner(); |
|
1323 |
} |
|
20153 | 1324 |
return owner == null ? null : |
1325 |
(LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner); |
|
12047 | 1326 |
} |
1327 |
||
1328 |
/** |
|
1329 |
* Returns the foremost modal blocker of this window, or null. |
|
1330 |
*/ |
|
1331 |
public LWWindowPeer getBlocker() { |
|
1332 |
synchronized (getPeerTreeLock()) { |
|
1333 |
LWWindowPeer blocker = this.blocker; |
|
1334 |
if (blocker == null) { |
|
1335 |
return null; |
|
1336 |
} |
|
1337 |
while (blocker.blocker != null) { |
|
1338 |
blocker = blocker.blocker; |
|
1339 |
} |
|
1340 |
return blocker; |
|
1341 |
} |
|
1342 |
} |
|
1343 |
||
20153 | 1344 |
@Override |
12047 | 1345 |
public void enterFullScreenMode() { |
1346 |
platformWindow.enterFullScreenMode(); |
|
18241 | 1347 |
updateSecurityWarningVisibility(); |
12047 | 1348 |
} |
1349 |
||
20153 | 1350 |
@Override |
12047 | 1351 |
public void exitFullScreenMode() { |
1352 |
platformWindow.exitFullScreenMode(); |
|
18241 | 1353 |
updateSecurityWarningVisibility(); |
12047 | 1354 |
} |
1355 |
||
1356 |
public long getLayerPtr() { |
|
1357 |
return getPlatformWindow().getLayerPtr(); |
|
1358 |
} |
|
1359 |
||
1360 |
void grab() { |
|
1361 |
if (grabbingWindow != null && !isGrabbing()) { |
|
1362 |
grabbingWindow.ungrab(); |
|
1363 |
} |
|
1364 |
grabbingWindow = this; |
|
1365 |
} |
|
1366 |
||
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1367 |
final void ungrab(boolean doPost) { |
12047 | 1368 |
if (isGrabbing()) { |
1369 |
grabbingWindow = null; |
|
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1370 |
if (doPost) { |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1371 |
postEvent(new UngrabEvent(getTarget())); |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1372 |
} |
12047 | 1373 |
} |
1374 |
} |
|
1375 |
||
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1376 |
void ungrab() { |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1377 |
ungrab(true); |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1378 |
} |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1379 |
|
12047 | 1380 |
private boolean isGrabbing() { |
1381 |
return this == grabbingWindow; |
|
1382 |
} |
|
1383 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1384 |
public PeerType getPeerType() { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1385 |
return peerType; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1386 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1387 |
|
18241 | 1388 |
public void updateSecurityWarningVisibility() { |
1389 |
if (warningWindow == null) { |
|
1390 |
return; |
|
1391 |
} |
|
1392 |
||
1393 |
if (!isVisible()) { |
|
1394 |
return; // The warning window should already be hidden. |
|
1395 |
} |
|
1396 |
||
1397 |
boolean show = false; |
|
1398 |
||
1399 |
if (!platformWindow.isFullScreenMode()) { |
|
1400 |
if (isVisible()) { |
|
1401 |
if (LWKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == |
|
1402 |
getTarget()) { |
|
1403 |
show = true; |
|
1404 |
} |
|
1405 |
||
1406 |
if (platformWindow.isUnderMouse() || warningWindow.isUnderMouse()) { |
|
1407 |
show = true; |
|
1408 |
} |
|
1409 |
} |
|
1410 |
} |
|
1411 |
||
1412 |
warningWindow.setVisible(show, true); |
|
1413 |
} |
|
1414 |
||
12047 | 1415 |
@Override |
1416 |
public String toString() { |
|
1417 |
return super.toString() + " [target is " + getTarget() + "]"; |
|
1418 |
} |
|
1419 |
} |