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