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