author | yan |
Mon, 06 Oct 2008 16:45:00 +0400 | |
changeset 1966 | 12a51fb0db0d |
parent 1962 | 6c293d33645b |
child 2451 | 597df8e1d786 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
116
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
2 |
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
||
29 |
import java.awt.event.ComponentEvent; |
|
30 |
import java.awt.event.FocusEvent; |
|
31 |
import java.awt.event.WindowEvent; |
|
32 |
||
33 |
import java.awt.peer.ComponentPeer; |
|
34 |
import java.awt.peer.WindowPeer; |
|
35 |
||
36 |
import java.util.ArrayList; |
|
37 |
import java.util.HashSet; |
|
38 |
import java.util.Iterator; |
|
39 |
import java.util.Set; |
|
40 |
import java.util.Vector; |
|
41 |
||
42 |
import java.util.logging.Level; |
|
43 |
import java.util.logging.Logger; |
|
44 |
||
45 |
import sun.awt.ComponentAccessor; |
|
46 |
import sun.awt.WindowAccessor; |
|
47 |
import sun.awt.DisplayChangedListener; |
|
48 |
import sun.awt.SunToolkit; |
|
49 |
import sun.awt.X11GraphicsDevice; |
|
50 |
import sun.awt.X11GraphicsEnvironment; |
|
51 |
||
52 |
class XWindowPeer extends XPanelPeer implements WindowPeer, |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
53 |
DisplayChangedListener { |
2 | 54 |
|
55 |
private static final Logger log = Logger.getLogger("sun.awt.X11.XWindowPeer"); |
|
56 |
private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XWindowPeer"); |
|
57 |
private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XWindowPeer"); |
|
58 |
private static final Logger grabLog = Logger.getLogger("sun.awt.X11.grab.XWindowPeer"); |
|
59 |
private static final Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XWindowPeer"); |
|
60 |
||
61 |
// should be synchronized on awtLock |
|
62 |
private static Set<XWindowPeer> windows = new HashSet<XWindowPeer>(); |
|
63 |
||
64 |
static XAtom wm_protocols; |
|
65 |
static XAtom wm_delete_window; |
|
66 |
static XAtom wm_take_focus; |
|
67 |
||
68 |
XWindowAttributesData winAttr; |
|
69 |
private boolean cachedFocusableWindow; |
|
70 |
XWarningWindow warningWindow; |
|
71 |
||
72 |
private boolean alwaysOnTop; |
|
73 |
PropMwmHints mwm_hints; |
|
74 |
private boolean locationByPlatform; |
|
75 |
||
76 |
Dialog modalBlocker; |
|
77 |
boolean delayedModalBlocking = false; |
|
78 |
Dimension targetMinimumSize = null; |
|
79 |
||
80 |
private XWindowPeer ownerPeer; |
|
81 |
||
82 |
// used for modal blocking to keep existing z-order |
|
83 |
protected XWindowPeer prevTransientFor, nextTransientFor; |
|
84 |
// value of WM_TRANSIENT_FOR hint set on this window |
|
85 |
private XWindowPeer curRealTransientFor; |
|
86 |
||
87 |
private boolean grab = false; // Whether to do a grab during showing |
|
88 |
||
89 |
private boolean isMapped = false; // Is this window mapped or not |
|
90 |
private boolean stateChanged; // Indicates whether the value on savedState is valid |
|
91 |
private int savedState; // Holds last known state of the top-level window |
|
92 |
private boolean mustControlStackPosition = false; // Am override-redirect not on top |
|
93 |
private XEventDispatcher rootPropertyEventDispatcher = null; |
|
94 |
||
95 |
/* |
|
96 |
* Focus related flags |
|
97 |
*/ |
|
98 |
private boolean isUnhiding = false; // Is the window unhiding. |
|
99 |
private boolean isBeforeFirstMapNotify = false; // Is the window (being shown) between |
|
100 |
// setVisible(true) & handleMapNotify(). |
|
101 |
||
102 |
// It need to be accessed from XFramePeer. |
|
103 |
protected Vector <ToplevelStateListener> toplevelStateListeners = new Vector<ToplevelStateListener>(); |
|
104 |
XWindowPeer(XCreateWindowParams params) { |
|
105 |
super(params.putIfNull(PARENT_WINDOW, Long.valueOf(0))); |
|
106 |
} |
|
107 |
||
108 |
XWindowPeer(Window target) { |
|
109 |
super(new XCreateWindowParams(new Object[] { |
|
110 |
TARGET, target, |
|
111 |
PARENT_WINDOW, Long.valueOf(0)})); |
|
112 |
} |
|
113 |
||
114 |
/* |
|
115 |
* This constant defines icon size recommended for using. |
|
116 |
* Apparently, we should use XGetIconSizes which should |
|
117 |
* return icon sizes would be most appreciated by the WM. |
|
118 |
* However, XGetIconSizes always returns 0 for some reason. |
|
119 |
* So the constant has been introduced. |
|
120 |
*/ |
|
121 |
private static final int PREFERRED_SIZE_FOR_ICON = 128; |
|
122 |
||
123 |
/* |
|
124 |
* Sometimes XChangeProperty(_NET_WM_ICON) doesn't work if |
|
125 |
* image buffer is too large. This constant holds maximum |
|
126 |
* length of buffer which can be used with _NET_WM_ICON hint. |
|
127 |
* It holds int's value. |
|
128 |
*/ |
|
129 |
private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1; |
|
130 |
||
131 |
void preInit(XCreateWindowParams params) { |
|
1190
f27065d0d9f0
6708392: Provide internal API to create OverrideRedirect windows, XToolkit
art
parents:
449
diff
changeset
|
132 |
target = (Component)params.get(TARGET); |
2 | 133 |
params.put(REPARENTED, |
134 |
Boolean.valueOf(isOverrideRedirect() || isSimpleWindow())); |
|
135 |
super.preInit(params); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
136 |
params.putIfNull(BIT_GRAVITY, Integer.valueOf(XConstants.NorthWestGravity)); |
2 | 137 |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
138 |
savedState = XUtilConstants.WithdrawnState; |
2 | 139 |
XA_NET_WM_STATE = XAtom.get("_NET_WM_STATE"); |
140 |
||
141 |
winAttr = new XWindowAttributesData(); |
|
142 |
||
143 |
params.put(OVERRIDE_REDIRECT, Boolean.valueOf(isOverrideRedirect())); |
|
144 |
||
145 |
SunToolkit.awtLock(); |
|
146 |
try { |
|
147 |
windows.add(this); |
|
148 |
if (wm_protocols == null) { |
|
149 |
wm_protocols = XAtom.get("WM_PROTOCOLS"); |
|
150 |
wm_delete_window = XAtom.get("WM_DELETE_WINDOW"); |
|
151 |
wm_take_focus = XAtom.get("WM_TAKE_FOCUS"); |
|
152 |
} |
|
153 |
} |
|
154 |
finally { |
|
155 |
SunToolkit.awtUnlock(); |
|
156 |
} |
|
157 |
cachedFocusableWindow = isFocusableWindow(); |
|
158 |
||
159 |
Font f = target.getFont(); |
|
160 |
if (f == null) { |
|
116
9c43d9eb1029
6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents:
2
diff
changeset
|
161 |
f = XWindow.getDefaultFont(); |
2 | 162 |
target.setFont(f); |
163 |
// we should not call setFont because it will call a repaint |
|
164 |
// which the peer may not be ready to do yet. |
|
165 |
} |
|
166 |
Color c = target.getBackground(); |
|
167 |
if (c == null) { |
|
168 |
Color background = SystemColor.window; |
|
169 |
target.setBackground(background); |
|
170 |
// we should not call setBackGround because it will call a repaint |
|
171 |
// which the peer may not be ready to do yet. |
|
172 |
} |
|
173 |
c = target.getForeground(); |
|
174 |
if (c == null) { |
|
175 |
target.setForeground(SystemColor.windowText); |
|
176 |
// we should not call setForeGround because it will call a repaint |
|
177 |
// which the peer may not be ready to do yet. |
|
178 |
} |
|
179 |
||
180 |
alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported(); |
|
181 |
||
182 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
183 |
((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
184 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
185 |
Rectangle bounds = (Rectangle)(params.get(BOUNDS)); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
186 |
params.put(BOUNDS, constrainBounds(bounds.x, bounds.y, bounds.width, bounds.height)); |
2 | 187 |
} |
188 |
||
189 |
private void initWMProtocols() { |
|
190 |
wm_protocols.setAtomListProperty(this, getWMProtocols()); |
|
191 |
} |
|
192 |
||
193 |
/** |
|
194 |
* Returns list of protocols which should be installed on this window. |
|
195 |
* Descendants can override this method to add class-specific protocols |
|
196 |
*/ |
|
197 |
protected XAtomList getWMProtocols() { |
|
198 |
// No protocols on simple window |
|
199 |
return new XAtomList(); |
|
200 |
} |
|
201 |
||
202 |
||
203 |
protected String getWMName() { |
|
204 |
String name = target.getName(); |
|
205 |
if (name == null || name.trim().equals("")) { |
|
206 |
name = " "; |
|
207 |
} |
|
208 |
return name; |
|
209 |
} |
|
210 |
||
211 |
void postInit(XCreateWindowParams params) { |
|
212 |
super.postInit(params); |
|
213 |
||
214 |
// Init WM_PROTOCOLS atom |
|
215 |
initWMProtocols(); |
|
216 |
||
217 |
// Set WM_TRANSIENT_FOR and group_leader |
|
218 |
Window t_window = (Window)target; |
|
219 |
Window owner = t_window.getOwner(); |
|
220 |
if (owner != null) { |
|
221 |
ownerPeer = (XWindowPeer)owner.getPeer(); |
|
222 |
if (focusLog.isLoggable(Level.FINER)) { |
|
223 |
focusLog.fine("Owner is " + owner); |
|
224 |
focusLog.fine("Owner peer is " + ownerPeer); |
|
225 |
focusLog.fine("Owner X window " + Long.toHexString(ownerPeer.getWindow())); |
|
226 |
focusLog.fine("Owner content X window " + Long.toHexString(ownerPeer.getContentWindow())); |
|
227 |
} |
|
228 |
// as owner window may be an embedded window, we must get a toplevel window |
|
229 |
// to set as TRANSIENT_FOR hint |
|
230 |
long ownerWindow = ownerPeer.getWindow(); |
|
231 |
if (ownerWindow != 0) { |
|
232 |
XToolkit.awtLock(); |
|
233 |
try { |
|
234 |
// Set WM_TRANSIENT_FOR |
|
235 |
if (focusLog.isLoggable(Level.FINE)) focusLog.fine("Setting transient on " + Long.toHexString(getWindow()) |
|
236 |
+ " for " + Long.toHexString(ownerWindow)); |
|
237 |
setToplevelTransientFor(this, ownerPeer, false, true); |
|
238 |
||
239 |
// Set group leader |
|
240 |
XWMHints hints = getWMHints(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
241 |
hints.set_flags(hints.get_flags() | (int)XUtilConstants.WindowGroupHint); |
2 | 242 |
hints.set_window_group(ownerWindow); |
243 |
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData); |
|
244 |
} |
|
245 |
finally { |
|
246 |
XToolkit.awtUnlock(); |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
// Init warning window(for applets) |
|
252 |
if (((Window)target).getWarningString() != null) { |
|
253 |
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip |
|
254 |
// and TrayIcon balloon windows without a warning window. |
|
255 |
if (!WindowAccessor.isTrayIconWindow((Window)target)) { |
|
256 |
warningWindow = new XWarningWindow((Window)target, getWindow()); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
setSaveUnder(true); |
|
261 |
||
262 |
updateIconImages(); |
|
263 |
} |
|
264 |
||
265 |
public void updateIconImages() { |
|
266 |
Window target = (Window)this.target; |
|
267 |
java.util.List<Image> iconImages = ((Window)target).getIconImages(); |
|
268 |
XWindowPeer ownerPeer = getOwnerPeer(); |
|
269 |
winAttr.icons = new ArrayList<XIconInfo>(); |
|
270 |
if (iconImages.size() != 0) { |
|
271 |
//read icon images from target |
|
272 |
winAttr.iconsInherited = false; |
|
273 |
for (Iterator<Image> i = iconImages.iterator(); i.hasNext(); ) { |
|
274 |
Image image = i.next(); |
|
275 |
if (image == null) { |
|
276 |
if (log.isLoggable(Level.FINEST)) { |
|
277 |
log.finest("XWindowPeer.updateIconImages: Skipping the image passed into Java because it's null."); |
|
278 |
} |
|
279 |
continue; |
|
280 |
} |
|
281 |
XIconInfo iconInfo; |
|
282 |
try { |
|
283 |
iconInfo = new XIconInfo(image); |
|
284 |
} catch (Exception e){ |
|
285 |
if (log.isLoggable(Level.FINEST)) { |
|
286 |
log.finest("XWindowPeer.updateIconImages: Perhaps the image passed into Java is broken. Skipping this icon."); |
|
287 |
} |
|
288 |
continue; |
|
289 |
} |
|
290 |
if (iconInfo.isValid()) { |
|
291 |
winAttr.icons.add(iconInfo); |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
||
296 |
// Fix for CR#6425089 |
|
297 |
winAttr.icons = normalizeIconImages(winAttr.icons); |
|
298 |
||
299 |
if (winAttr.icons.size() == 0) { |
|
300 |
//target.icons is empty or all icon images are broken |
|
301 |
if (ownerPeer != null) { |
|
302 |
//icon is inherited from parent |
|
303 |
winAttr.iconsInherited = true; |
|
304 |
winAttr.icons = ownerPeer.getIconInfo(); |
|
305 |
} else { |
|
306 |
//default icon is used |
|
307 |
winAttr.iconsInherited = false; |
|
308 |
winAttr.icons = getDefaultIconInfo(); |
|
309 |
} |
|
310 |
} |
|
311 |
recursivelySetIcon(winAttr.icons); |
|
312 |
} |
|
313 |
||
314 |
/* |
|
315 |
* Sometimes XChangeProperty(_NET_WM_ICON) doesn't work if |
|
316 |
* image buffer is too large. This function help us accommodate |
|
317 |
* initial list of the icon images to certainly-acceptable. |
|
318 |
* It does scale some of these icons to appropriate size |
|
319 |
* if it's necessary. |
|
320 |
*/ |
|
321 |
static java.util.List<XIconInfo> normalizeIconImages(java.util.List<XIconInfo> icons) { |
|
322 |
java.util.List<XIconInfo> result = new ArrayList<XIconInfo>(); |
|
323 |
int totalLength = 0; |
|
324 |
boolean haveLargeIcon = false; |
|
325 |
||
326 |
for (XIconInfo icon : icons) { |
|
327 |
int width = icon.getWidth(); |
|
328 |
int height = icon.getHeight(); |
|
329 |
int length = icon.getRawLength(); |
|
330 |
||
331 |
if (width > PREFERRED_SIZE_FOR_ICON || height > PREFERRED_SIZE_FOR_ICON) { |
|
332 |
if (haveLargeIcon) { |
|
333 |
continue; |
|
334 |
} |
|
335 |
int scaledWidth = width; |
|
336 |
int scaledHeight = height; |
|
337 |
while (scaledWidth > PREFERRED_SIZE_FOR_ICON || |
|
338 |
scaledHeight > PREFERRED_SIZE_FOR_ICON) { |
|
339 |
scaledWidth = scaledWidth / 2; |
|
340 |
scaledHeight = scaledHeight / 2; |
|
341 |
} |
|
342 |
||
343 |
icon.setScaledSize(scaledWidth, scaledHeight); |
|
344 |
length = icon.getRawLength(); |
|
345 |
} |
|
346 |
||
347 |
if (totalLength + length <= MAXIMUM_BUFFER_LENGTH_NET_WM_ICON) { |
|
348 |
totalLength += length; |
|
349 |
result.add(icon); |
|
350 |
if (width > PREFERRED_SIZE_FOR_ICON || height > PREFERRED_SIZE_FOR_ICON) { |
|
351 |
haveLargeIcon = true; |
|
352 |
} |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
if (iconLog.isLoggable(Level.FINEST)) { |
|
357 |
iconLog.log(Level.FINEST, ">>> Length_ of buffer of icons data: " + totalLength + |
|
358 |
", maximum length: " + MAXIMUM_BUFFER_LENGTH_NET_WM_ICON); |
|
359 |
} |
|
360 |
||
361 |
return result; |
|
362 |
} |
|
363 |
||
364 |
/* |
|
365 |
* Dumps each icon from the list |
|
366 |
*/ |
|
367 |
static void dumpIcons(java.util.List<XIconInfo> icons) { |
|
368 |
if (iconLog.isLoggable(Level.FINEST)) { |
|
369 |
iconLog.log(Level.FINEST, ">>> Sizes of icon images:"); |
|
370 |
for (Iterator<XIconInfo> i = icons.iterator(); i.hasNext(); ) { |
|
371 |
iconLog.log(Level.FINEST, " {0}", i.next()); |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
public void recursivelySetIcon(java.util.List<XIconInfo> icons) { |
|
377 |
dumpIcons(winAttr.icons); |
|
378 |
setIconHints(icons); |
|
379 |
Window target = (Window)this.target; |
|
380 |
Window[] children = target.getOwnedWindows(); |
|
381 |
int cnt = children.length; |
|
382 |
for (int i = 0; i < cnt; i++) { |
|
383 |
ComponentPeer childPeer = children[i].getPeer(); |
|
384 |
if (childPeer != null && childPeer instanceof XWindowPeer) { |
|
385 |
if (((XWindowPeer)childPeer).winAttr.iconsInherited) { |
|
386 |
((XWindowPeer)childPeer).winAttr.icons = icons; |
|
387 |
((XWindowPeer)childPeer).recursivelySetIcon(icons); |
|
388 |
} |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
||
393 |
java.util.List<XIconInfo> getIconInfo() { |
|
394 |
return winAttr.icons; |
|
395 |
} |
|
396 |
void setIconHints(java.util.List<XIconInfo> icons) { |
|
397 |
//This does nothing for XWindowPeer, |
|
398 |
//It's overriden in XDecoratedPeer |
|
399 |
} |
|
400 |
||
401 |
private static ArrayList<XIconInfo> defaultIconInfo; |
|
402 |
protected synchronized static java.util.List<XIconInfo> getDefaultIconInfo() { |
|
403 |
if (defaultIconInfo == null) { |
|
404 |
defaultIconInfo = new ArrayList<XIconInfo>(); |
|
405 |
if (XlibWrapper.dataModel == 32) { |
|
406 |
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon16_png.java_icon16_png)); |
|
407 |
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon24_png.java_icon24_png)); |
|
408 |
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon32_png.java_icon32_png)); |
|
409 |
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon48_png.java_icon48_png)); |
|
410 |
} else { |
|
411 |
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon16_png.java_icon16_png)); |
|
412 |
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon24_png.java_icon24_png)); |
|
413 |
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon32_png.java_icon32_png)); |
|
414 |
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon48_png.java_icon48_png)); |
|
415 |
} |
|
416 |
} |
|
417 |
return defaultIconInfo; |
|
418 |
} |
|
419 |
||
420 |
public void updateMinimumSize() { |
|
421 |
//This function only saves minimumSize value in XWindowPeer |
|
422 |
//Setting WMSizeHints is implemented in XDecoratedPeer |
|
423 |
targetMinimumSize = (((Component)target).isMinimumSizeSet()) ? |
|
424 |
((Component)target).getMinimumSize() : null; |
|
425 |
} |
|
426 |
||
427 |
public Dimension getTargetMinimumSize() { |
|
428 |
return (targetMinimumSize == null) ? null : new Dimension(targetMinimumSize); |
|
429 |
} |
|
430 |
||
431 |
public XWindowPeer getOwnerPeer() { |
|
432 |
return ownerPeer; |
|
433 |
} |
|
434 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
435 |
// This method is overriden at the XDecoratedPeer to handle |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
436 |
// decorated windows a bit differently. |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
437 |
Rectangle constrainBounds(int x, int y, int width, int height) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
438 |
// We don't restrict the setBounds() operation if the code is trusted. |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
439 |
if (!hasWarningWindow()) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
440 |
return new Rectangle(x, y, width, height); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
441 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
442 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
443 |
// The window bounds should be within the visible part of the screen |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
444 |
int newX = x; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
445 |
int newY = y; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
446 |
int newW = width; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
447 |
int newH = height; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
448 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
449 |
// Now check each point is within the visible part of the screen |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
450 |
GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
451 |
Rectangle sB = gc.getBounds(); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
452 |
Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
453 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
454 |
int screenX = sB.x + sIn.left; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
455 |
int screenY = sB.y + sIn.top; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
456 |
int screenW = sB.width - sIn.left - sIn.right; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
457 |
int screenH = sB.height - sIn.top - sIn.bottom; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
458 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
459 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
460 |
// First make sure the size is withing the visible part of the screen |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
461 |
if (newW > screenW) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
462 |
newW = screenW; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
463 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
464 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
465 |
if (newH > screenH) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
466 |
newH = screenH; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
467 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
468 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
469 |
// Tweak the location if needed |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
470 |
if (newX < screenX) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
471 |
newX = screenX; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
472 |
} else if (newX + newW > screenX + screenW) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
473 |
newX = screenX + screenW - newW; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
474 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
475 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
476 |
if (newY < screenY) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
477 |
newY = screenY; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
478 |
} else if (newY + newH > screenY + screenH) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
479 |
newY = screenY + screenH - newH; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
480 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
481 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
482 |
return new Rectangle(newX, newY, newW, newH); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
483 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
484 |
|
2 | 485 |
//Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges |
486 |
//the window but fails to revalidate, Sol-CDE |
|
487 |
//This bug is regression for |
|
488 |
//5025858: Resizing a decorated frame triggers componentResized event twice. |
|
489 |
//Since events are not posted from Component.setBounds we need to send them here. |
|
490 |
//Note that this function is overriden in XDecoratedPeer so event |
|
491 |
//posting is not changing for decorated peers |
|
492 |
public void setBounds(int x, int y, int width, int height, int op) { |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
493 |
Rectangle newBounds = constrainBounds(x, y, width, height); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
494 |
|
2 | 495 |
XToolkit.awtLock(); |
496 |
try { |
|
497 |
Rectangle oldBounds = getBounds(); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
498 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
499 |
super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
500 |
|
2 | 501 |
Rectangle bounds = getBounds(); |
502 |
||
503 |
XSizeHints hints = getHints(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
504 |
setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize, |
2 | 505 |
bounds.x, bounds.y, bounds.width, bounds.height); |
506 |
XWM.setMotifDecor(this, false, 0, 0); |
|
507 |
||
508 |
XNETProtocol protocol = XWM.getWM().getNETProtocol(); |
|
509 |
if (protocol != null && protocol.active()) { |
|
510 |
XAtomList net_wm_state = getNETWMState(); |
|
511 |
net_wm_state.add(protocol.XA_NET_WM_STATE_SKIP_TASKBAR); |
|
512 |
setNETWMState(net_wm_state); |
|
513 |
} |
|
514 |
||
515 |
||
516 |
if (!bounds.getSize().equals(oldBounds.getSize())) { |
|
517 |
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED)); |
|
518 |
} |
|
519 |
if (!bounds.getLocation().equals(oldBounds.getLocation())) { |
|
520 |
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED)); |
|
521 |
} |
|
522 |
} finally { |
|
523 |
XToolkit.awtUnlock(); |
|
524 |
} |
|
525 |
} |
|
526 |
||
527 |
void updateFocusability() { |
|
528 |
updateFocusableWindowState(); |
|
529 |
XToolkit.awtLock(); |
|
530 |
try { |
|
531 |
XWMHints hints = getWMHints(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
532 |
hints.set_flags(hints.get_flags() | (int)XUtilConstants.InputHint); |
2 | 533 |
hints.set_input(false/*isNativelyNonFocusableWindow() ? (0):(1)*/); |
534 |
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData); |
|
535 |
} |
|
536 |
finally { |
|
537 |
XToolkit.awtUnlock(); |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
public Insets getInsets() { |
|
449 | 542 |
return new Insets(getWarningWindowHeight(), 0, 0, 0); |
2 | 543 |
} |
544 |
||
545 |
// NOTE: This method may be called by privileged threads. |
|
546 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
547 |
public void handleIconify() { |
|
548 |
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED)); |
|
549 |
} |
|
550 |
||
551 |
// NOTE: This method may be called by privileged threads. |
|
552 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
553 |
public void handleDeiconify() { |
|
554 |
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED)); |
|
555 |
} |
|
556 |
||
557 |
// NOTE: This method may be called by privileged threads. |
|
558 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
559 |
public void handleStateChange(int oldState, int newState) { |
|
560 |
postEvent(new WindowEvent((Window)target, |
|
561 |
WindowEvent.WINDOW_STATE_CHANGED, |
|
562 |
oldState, newState)); |
|
563 |
} |
|
564 |
||
565 |
/** |
|
566 |
* DEPRECATED: Replaced by getInsets(). |
|
567 |
*/ |
|
568 |
public Insets insets() { |
|
569 |
return getInsets(); |
|
570 |
} |
|
571 |
||
572 |
boolean isAutoRequestFocus() { |
|
573 |
if (XToolkit.isToolkitThread()) { |
|
574 |
return WindowAccessor.isAutoRequestFocus((Window)target); |
|
575 |
} else { |
|
576 |
return ((Window)target).isAutoRequestFocus(); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
/* |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
581 |
* Retrives real native focused window and converts it into Java peer. |
2 | 582 |
*/ |
583 |
static XWindowPeer getNativeFocusedWindowPeer() { |
|
584 |
XBaseWindow baseWindow = XToolkit.windowToXWindow(xGetInputFocus()); |
|
585 |
return (baseWindow instanceof XWindowPeer) ? (XWindowPeer)baseWindow : |
|
586 |
(baseWindow instanceof XFocusProxyWindow) ? |
|
587 |
((XFocusProxyWindow)baseWindow).getOwner() : null; |
|
588 |
} |
|
589 |
||
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
590 |
/* |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
591 |
* Retrives real native focused window and converts it into Java window. |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
592 |
*/ |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
593 |
static Window getNativeFocusedWindow() { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
594 |
XWindowPeer peer = getNativeFocusedWindowPeer(); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
595 |
return peer != null ? (Window)peer.target : null; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
596 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
597 |
|
2 | 598 |
boolean isFocusableWindow() { |
599 |
if (XToolkit.isToolkitThread() || SunToolkit.isAWTLockHeldByCurrentThread()) |
|
600 |
{ |
|
601 |
return cachedFocusableWindow; |
|
602 |
} else { |
|
603 |
return ((Window)target).isFocusableWindow(); |
|
604 |
} |
|
605 |
} |
|
606 |
||
607 |
/* WARNING: don't call client code in this method! */ |
|
608 |
boolean isFocusedWindowModalBlocker() { |
|
609 |
return false; |
|
610 |
} |
|
611 |
||
612 |
long getFocusTargetWindow() { |
|
613 |
return getContentWindow(); |
|
614 |
} |
|
615 |
||
616 |
/** |
|
617 |
* Returns whether or not this window peer has native X window |
|
618 |
* configured as non-focusable window. It might happen if: |
|
619 |
* - Java window is non-focusable |
|
620 |
* - Java window is simple Window(not Frame or Dialog) |
|
621 |
*/ |
|
622 |
boolean isNativelyNonFocusableWindow() { |
|
623 |
if (XToolkit.isToolkitThread() || SunToolkit.isAWTLockHeldByCurrentThread()) |
|
624 |
{ |
|
625 |
return isSimpleWindow() || !cachedFocusableWindow; |
|
626 |
} else { |
|
627 |
return isSimpleWindow() || !(((Window)target).isFocusableWindow()); |
|
628 |
} |
|
629 |
} |
|
630 |
||
631 |
public void handleWindowFocusIn_Dispatch() { |
|
632 |
if (EventQueue.isDispatchThread()) { |
|
633 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target); |
|
634 |
target.dispatchEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS)); |
|
635 |
} |
|
636 |
} |
|
637 |
||
638 |
public void handleWindowFocusInSync(long serial) { |
|
639 |
WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS); |
|
640 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target); |
|
641 |
sendEvent(we); |
|
642 |
} |
|
643 |
// NOTE: This method may be called by privileged threads. |
|
644 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
645 |
public void handleWindowFocusIn(long serial) { |
|
646 |
WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS); |
|
647 |
/* wrap in Sequenced, then post*/ |
|
648 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target); |
|
649 |
postEvent(wrapInSequenced((AWTEvent) we)); |
|
650 |
} |
|
651 |
||
652 |
// NOTE: This method may be called by privileged threads. |
|
653 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
654 |
public void handleWindowFocusOut(Window oppositeWindow, long serial) { |
|
655 |
WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow); |
|
656 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null); |
|
657 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null); |
|
658 |
/* wrap in Sequenced, then post*/ |
|
659 |
postEvent(wrapInSequenced((AWTEvent) we)); |
|
660 |
} |
|
661 |
public void handleWindowFocusOutSync(Window oppositeWindow, long serial) { |
|
662 |
WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow); |
|
663 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null); |
|
664 |
XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null); |
|
665 |
sendEvent(we); |
|
666 |
} |
|
667 |
||
668 |
/* --- DisplayChangedListener Stuff --- */ |
|
669 |
||
670 |
/* Xinerama |
|
671 |
* called to check if we've been moved onto a different screen |
|
672 |
* Based on checkNewXineramaScreen() in awt_GraphicsEnv.c |
|
673 |
*/ |
|
674 |
public void checkIfOnNewScreen(Rectangle newBounds) { |
|
675 |
if (!XToolkit.localEnv.runningXinerama()) { |
|
676 |
return; |
|
677 |
} |
|
678 |
||
679 |
if (log.isLoggable(Level.FINEST)) { |
|
680 |
log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode"); |
|
681 |
} |
|
682 |
||
683 |
int area = newBounds.width * newBounds.height; |
|
684 |
int intAmt, vertAmt, horizAmt; |
|
685 |
int largestAmt = 0; |
|
686 |
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen(); |
|
687 |
int newScreenNum = 0; |
|
688 |
GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices(); |
|
689 |
Rectangle screenBounds; |
|
690 |
||
691 |
for (int i = 0; i < gds.length; i++) { |
|
692 |
screenBounds = gds[i].getDefaultConfiguration().getBounds(); |
|
693 |
if (newBounds.intersects(screenBounds)) { |
|
694 |
horizAmt = Math.min(newBounds.x + newBounds.width, |
|
695 |
screenBounds.x + screenBounds.width) - |
|
696 |
Math.max(newBounds.x, screenBounds.x); |
|
697 |
vertAmt = Math.min(newBounds.y + newBounds.height, |
|
698 |
screenBounds.y + screenBounds.height)- |
|
699 |
Math.max(newBounds.y, screenBounds.y); |
|
700 |
intAmt = horizAmt * vertAmt; |
|
701 |
if (intAmt == area) { |
|
702 |
// Completely on this screen - done! |
|
703 |
newScreenNum = i; |
|
704 |
break; |
|
705 |
} |
|
706 |
if (intAmt > largestAmt) { |
|
707 |
largestAmt = intAmt; |
|
708 |
newScreenNum = i; |
|
709 |
} |
|
710 |
} |
|
711 |
} |
|
712 |
if (newScreenNum != curScreenNum) { |
|
713 |
if (log.isLoggable(Level.FINEST)) { |
|
714 |
log.finest("XWindowPeer: Moved to a new screen"); |
|
715 |
} |
|
716 |
draggedToNewScreen(newScreenNum); |
|
717 |
} |
|
718 |
} |
|
719 |
||
720 |
/* Xinerama |
|
721 |
* called to update our GC when dragged onto another screen |
|
722 |
*/ |
|
723 |
public void draggedToNewScreen(int screenNum) { |
|
724 |
executeDisplayChangedOnEDT(screenNum); |
|
725 |
} |
|
726 |
||
727 |
/** |
|
728 |
* Helper method that executes the displayChanged(screen) method on |
|
729 |
* the event dispatch thread. This method is used in the Xinerama case |
|
730 |
* and after display mode change events. |
|
731 |
*/ |
|
732 |
private void executeDisplayChangedOnEDT(final int screenNum) { |
|
733 |
Runnable dc = new Runnable() { |
|
734 |
public void run() { |
|
735 |
// Updates this window's GC and notifies all the children. |
|
736 |
// See XPanelPeer/XCanvasPeer.displayChanged(int) for details. |
|
737 |
displayChanged(screenNum); |
|
738 |
} |
|
739 |
}; |
|
740 |
SunToolkit.executeOnEventHandlerThread((Component)target, dc); |
|
741 |
} |
|
742 |
||
743 |
/** |
|
744 |
* From the DisplayChangedListener interface; called from |
|
745 |
* X11GraphicsDevice when the display mode has been changed. |
|
746 |
*/ |
|
747 |
public void displayChanged() { |
|
748 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
749 |
int curScreenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen(); |
|
750 |
executeDisplayChangedOnEDT(curScreenNum); |
|
751 |
} |
|
752 |
||
753 |
/** |
|
754 |
* From the DisplayChangedListener interface; top-levels do not need |
|
755 |
* to react to this event. |
|
756 |
*/ |
|
757 |
public void paletteChanged() { |
|
758 |
} |
|
759 |
||
760 |
/* |
|
761 |
* Overridden to check if we need to update our GraphicsDevice/Config |
|
762 |
* Added for 4934052. |
|
763 |
*/ |
|
764 |
public void handleConfigureNotifyEvent(XEvent xev) { |
|
765 |
// TODO: We create an XConfigureEvent every time we override |
|
766 |
// handleConfigureNotify() - too many! |
|
767 |
XConfigureEvent xe = xev.get_xconfigure(); |
|
768 |
checkIfOnNewScreen(new Rectangle(xe.get_x(), |
|
769 |
xe.get_y(), |
|
770 |
xe.get_width(), |
|
771 |
xe.get_height())); |
|
772 |
||
773 |
// Don't call super until we've handled a screen change. Otherwise |
|
774 |
// there could be a race condition in which a ComponentListener could |
|
775 |
// see the old screen. |
|
776 |
super.handleConfigureNotifyEvent(xev); |
|
777 |
// for 5085647: no applet warning window visible |
|
778 |
updateChildrenSizes(); |
|
779 |
} |
|
780 |
||
781 |
final void requestXFocus(long time) { |
|
782 |
requestXFocus(time, true); |
|
783 |
} |
|
784 |
||
785 |
final void requestXFocus() { |
|
786 |
requestXFocus(0, false); |
|
787 |
} |
|
788 |
||
789 |
/** |
|
790 |
* Requests focus to this top-level. Descendants should override to provide |
|
791 |
* implementations based on a class of top-level. |
|
792 |
*/ |
|
793 |
protected void requestXFocus(long time, boolean timeProvided) { |
|
794 |
// Since in XAWT focus is synthetic and all basic Windows are |
|
795 |
// override_redirect all we can do is check whether our parent |
|
796 |
// is active. If it is - we can freely synthesize focus transfer. |
|
797 |
// Luckily, this logic is already implemented in requestWindowFocus. |
|
798 |
if (focusLog.isLoggable(Level.FINE)) focusLog.fine("Requesting window focus"); |
|
799 |
requestWindowFocus(time, timeProvided); |
|
800 |
} |
|
801 |
||
802 |
public final boolean focusAllowedFor() { |
|
803 |
if (isNativelyNonFocusableWindow()) { |
|
804 |
return false; |
|
805 |
} |
|
806 |
/* |
|
807 |
Window target = (Window)this.target; |
|
808 |
if (!target.isVisible() || |
|
809 |
!target.isEnabled() || |
|
810 |
!target.isFocusable()) |
|
811 |
{ |
|
812 |
return false; |
|
813 |
} |
|
814 |
*/ |
|
815 |
if (isModalBlocked()) { |
|
816 |
return false; |
|
817 |
} |
|
818 |
return true; |
|
819 |
} |
|
820 |
||
821 |
public void handleFocusEvent(XEvent xev) { |
|
822 |
XFocusChangeEvent xfe = xev.get_xfocus(); |
|
823 |
FocusEvent fe; |
|
824 |
focusLog.log(Level.FINE, "{0}", new Object[] {xfe}); |
|
825 |
if (isEventDisabled(xev)) { |
|
826 |
return; |
|
827 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
828 |
if (xev.get_type() == XConstants.FocusIn) |
2 | 829 |
{ |
830 |
// If this window is non-focusable don't post any java focus event |
|
831 |
if (focusAllowedFor()) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
832 |
if (xfe.get_mode() == XConstants.NotifyNormal // Normal notify |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
833 |
|| xfe.get_mode() == XConstants.NotifyWhileGrabbed) // Alt-Tab notify |
2 | 834 |
{ |
835 |
handleWindowFocusIn(xfe.get_serial()); |
|
836 |
} |
|
837 |
} |
|
838 |
} |
|
839 |
else |
|
840 |
{ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
841 |
if (xfe.get_mode() == XConstants.NotifyNormal // Normal notify |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
842 |
|| xfe.get_mode() == XConstants.NotifyWhileGrabbed) // Alt-Tab notify |
2 | 843 |
{ |
844 |
// If this window is non-focusable don't post any java focus event |
|
845 |
if (!isNativelyNonFocusableWindow()) { |
|
846 |
XWindowPeer oppositeXWindow = getNativeFocusedWindowPeer(); |
|
847 |
Object oppositeTarget = (oppositeXWindow!=null)? oppositeXWindow.getTarget() : null; |
|
848 |
Window oppositeWindow = null; |
|
849 |
if (oppositeTarget instanceof Window) { |
|
850 |
oppositeWindow = (Window) oppositeTarget; |
|
851 |
} |
|
852 |
// Check if opposite window is non-focusable. In that case we don't want to |
|
853 |
// post any event. |
|
854 |
if (oppositeXWindow != null && oppositeXWindow.isNativelyNonFocusableWindow()) { |
|
855 |
return; |
|
856 |
} |
|
857 |
if (this == oppositeXWindow) { |
|
858 |
oppositeWindow = null; |
|
859 |
} else if (oppositeXWindow instanceof XDecoratedPeer) { |
|
860 |
if (((XDecoratedPeer) oppositeXWindow).actualFocusedWindow != null) { |
|
861 |
oppositeXWindow = ((XDecoratedPeer) oppositeXWindow).actualFocusedWindow; |
|
862 |
oppositeTarget = oppositeXWindow.getTarget(); |
|
863 |
if (oppositeTarget instanceof Window |
|
864 |
&& oppositeXWindow.isVisible() |
|
865 |
&& oppositeXWindow.isNativelyNonFocusableWindow()) |
|
866 |
{ |
|
867 |
oppositeWindow = ((Window) oppositeTarget); |
|
868 |
} |
|
869 |
} |
|
870 |
} |
|
871 |
handleWindowFocusOut(oppositeWindow, xfe.get_serial()); |
|
872 |
} |
|
873 |
} |
|
874 |
} |
|
875 |
} |
|
876 |
||
877 |
void setSaveUnder(boolean state) {} |
|
878 |
||
879 |
public void toFront() { |
|
880 |
if (isOverrideRedirect() && mustControlStackPosition) { |
|
881 |
mustControlStackPosition = false; |
|
882 |
removeRootPropertyEventDispatcher(); |
|
883 |
} |
|
884 |
if (isVisible()) { |
|
885 |
super.toFront(); |
|
886 |
if (isFocusableWindow() && isAutoRequestFocus() && |
|
887 |
!isModalBlocked() && !isWithdrawn()) |
|
888 |
{ |
|
889 |
requestInitialFocus(); |
|
890 |
} |
|
891 |
} else { |
|
892 |
setVisible(true); |
|
893 |
} |
|
894 |
} |
|
895 |
||
896 |
public void toBack() { |
|
897 |
XToolkit.awtLock(); |
|
898 |
try { |
|
899 |
if(!isOverrideRedirect()) { |
|
900 |
XlibWrapper.XLowerWindow(XToolkit.getDisplay(), getWindow()); |
|
901 |
}else{ |
|
902 |
lowerOverrideRedirect(); |
|
903 |
} |
|
904 |
} |
|
905 |
finally { |
|
906 |
XToolkit.awtUnlock(); |
|
907 |
} |
|
908 |
} |
|
909 |
private void lowerOverrideRedirect() { |
|
910 |
// |
|
911 |
// make new hash of toplevels of all windows from 'windows' hash. |
|
912 |
// FIXME: do not call them "toplevel" as it is misleading. |
|
913 |
// |
|
914 |
HashSet toplevels = new HashSet(); |
|
915 |
long topl = 0, mytopl = 0; |
|
916 |
||
917 |
for (XWindowPeer xp : windows) { |
|
918 |
topl = getToplevelWindow( xp.getWindow() ); |
|
919 |
if( xp.equals( this ) ) { |
|
920 |
mytopl = topl; |
|
921 |
} |
|
922 |
if( topl > 0 ) |
|
923 |
toplevels.add( Long.valueOf( topl ) ); |
|
924 |
} |
|
925 |
||
926 |
// |
|
927 |
// find in the root's tree: |
|
928 |
// (1) my toplevel, (2) lowest java toplevel, (3) desktop |
|
929 |
// We must enforce (3), (1), (2) order, upward; |
|
930 |
// note that nautilus on the next restacking will do (1),(3),(2). |
|
931 |
// |
|
932 |
long laux, wDesktop = -1, wBottom = -1; |
|
933 |
int iMy = -1, iDesktop = -1, iBottom = -1; |
|
934 |
int i = 0; |
|
935 |
XQueryTree xqt = new XQueryTree(XToolkit.getDefaultRootWindow()); |
|
936 |
try { |
|
937 |
if( xqt.execute() > 0 ) { |
|
938 |
int nchildren = xqt.get_nchildren(); |
|
939 |
long children = xqt.get_children(); |
|
940 |
for(i = 0; i < nchildren; i++) { |
|
941 |
laux = Native.getWindow(children, i); |
|
942 |
if( laux == mytopl ) { |
|
943 |
iMy = i; |
|
944 |
}else if( isDesktopWindow( laux ) ) { |
|
945 |
// we need topmost desktop of them all. |
|
946 |
iDesktop = i; |
|
947 |
wDesktop = laux; |
|
948 |
}else if(iBottom < 0 && |
|
949 |
toplevels.contains( Long.valueOf(laux) ) && |
|
950 |
laux != mytopl) { |
|
951 |
iBottom = i; |
|
952 |
wBottom = laux; |
|
953 |
} |
|
954 |
} |
|
955 |
} |
|
956 |
||
957 |
if( (iMy < iBottom || iBottom < 0 )&& iDesktop < iMy) |
|
958 |
return; // no action necessary |
|
959 |
||
960 |
long to_restack = Native.allocateLongArray(2); |
|
961 |
Native.putLong(to_restack, 0, wBottom); |
|
962 |
Native.putLong(to_restack, 1, mytopl); |
|
963 |
XlibWrapper.XRestackWindows(XToolkit.getDisplay(), to_restack, 2); |
|
964 |
XlibWrapper.unsafe.freeMemory(to_restack); |
|
965 |
||
966 |
||
967 |
if( !mustControlStackPosition ) { |
|
968 |
mustControlStackPosition = true; |
|
969 |
// add root window property listener: |
|
970 |
// somebody (eg nautilus desktop) may obscure us |
|
971 |
addRootPropertyEventDispatcher(); |
|
972 |
} |
|
973 |
} finally { |
|
974 |
xqt.dispose(); |
|
975 |
} |
|
976 |
} |
|
977 |
/** |
|
978 |
Get XID of closest to root window in a given window hierarchy. |
|
979 |
FIXME: do not call it "toplevel" as it is misleading. |
|
980 |
On error return 0. |
|
981 |
*/ |
|
982 |
private long getToplevelWindow( long w ) { |
|
983 |
long wi = w, ret, root; |
|
984 |
do { |
|
985 |
ret = wi; |
|
986 |
XQueryTree qt = new XQueryTree(wi); |
|
987 |
try { |
|
988 |
if (qt.execute() == 0) { |
|
989 |
return 0; |
|
990 |
} |
|
991 |
root = qt.get_root(); |
|
992 |
wi = qt.get_parent(); |
|
993 |
} finally { |
|
994 |
qt.dispose(); |
|
995 |
} |
|
996 |
||
997 |
} while (wi != root); |
|
998 |
||
999 |
return ret; |
|
1000 |
} |
|
449 | 1001 |
|
1002 |
private static boolean isDesktopWindow( long wi ) { |
|
2 | 1003 |
return XWM.getWM().isDesktopWindow( wi ); |
1004 |
} |
|
1005 |
||
1006 |
private void updateAlwaysOnTop() { |
|
1007 |
log.log(Level.FINE, "Promoting always-on-top state {0}", Boolean.valueOf(alwaysOnTop)); |
|
1008 |
XWM.getWM().setLayer(this, |
|
1009 |
alwaysOnTop ? |
|
1010 |
XLayerProtocol.LAYER_ALWAYS_ON_TOP : |
|
1011 |
XLayerProtocol.LAYER_NORMAL); |
|
1012 |
} |
|
1013 |
||
1014 |
public void setAlwaysOnTop(boolean alwaysOnTop) { |
|
1015 |
this.alwaysOnTop = alwaysOnTop; |
|
1016 |
updateAlwaysOnTop(); |
|
1017 |
} |
|
1018 |
||
1019 |
boolean isLocationByPlatform() { |
|
1020 |
return locationByPlatform; |
|
1021 |
} |
|
1022 |
||
1023 |
private void promoteDefaultPosition() { |
|
1024 |
this.locationByPlatform = ((Window)target).isLocationByPlatform(); |
|
1025 |
if (locationByPlatform) { |
|
1026 |
XToolkit.awtLock(); |
|
1027 |
try { |
|
1028 |
Rectangle bounds = getBounds(); |
|
1029 |
XSizeHints hints = getHints(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1030 |
setSizeHints(hints.get_flags() & ~(XUtilConstants.USPosition | XUtilConstants.PPosition), |
2 | 1031 |
bounds.x, bounds.y, bounds.width, bounds.height); |
1032 |
} finally { |
|
1033 |
XToolkit.awtUnlock(); |
|
1034 |
} |
|
1035 |
} |
|
1036 |
} |
|
1037 |
||
1038 |
public void setVisible(boolean vis) { |
|
1039 |
if (!isVisible() && vis) { |
|
1040 |
isBeforeFirstMapNotify = true; |
|
1041 |
winAttr.initialFocus = isAutoRequestFocus(); |
|
1042 |
if (!winAttr.initialFocus) { |
|
1043 |
/* |
|
1044 |
* It's easier and safer to temporary suppress WM_TAKE_FOCUS |
|
1045 |
* protocol itself than to ignore WM_TAKE_FOCUS client message. |
|
1046 |
* Because we will have to make the difference between |
|
1047 |
* the message come after showing and the message come after |
|
1048 |
* activation. Also, on Metacity, for some reason, we have _two_ |
|
1049 |
* WM_TAKE_FOCUS client messages when showing a frame/dialog. |
|
1050 |
*/ |
|
1051 |
suppressWmTakeFocus(true); |
|
1052 |
} |
|
1053 |
} |
|
1054 |
updateFocusability(); |
|
1055 |
promoteDefaultPosition(); |
|
1056 |
super.setVisible(vis); |
|
1057 |
if (!vis && !isWithdrawn()) { |
|
1058 |
// ICCCM, 4.1.4. Changing Window State: |
|
1059 |
// "Iconic -> Withdrawn - The client should unmap the window and follow it |
|
1060 |
// with a synthetic UnmapNotify event as described later in this section." |
|
1061 |
// The same is true for Normal -> Withdrawn |
|
1062 |
XToolkit.awtLock(); |
|
1063 |
try { |
|
1064 |
XUnmapEvent unmap = new XUnmapEvent(); |
|
1065 |
unmap.set_window(window); |
|
1066 |
unmap.set_event(XToolkit.getDefaultRootWindow()); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1067 |
unmap.set_type((int)XConstants.UnmapNotify); |
2 | 1068 |
unmap.set_from_configure(false); |
1069 |
XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1070 |
false, XConstants.SubstructureNotifyMask | XConstants.SubstructureRedirectMask, |
2 | 1071 |
unmap.pData); |
1072 |
unmap.dispose(); |
|
1073 |
} |
|
1074 |
finally { |
|
1075 |
XToolkit.awtUnlock(); |
|
1076 |
} |
|
1077 |
} |
|
1078 |
// method called somewhere in parent does not generate configure-notify |
|
1079 |
// event for override-redirect. |
|
1080 |
// Ergo, no reshape and bugs like 5085647 in case setBounds was |
|
1081 |
// called before setVisible. |
|
1082 |
if (isOverrideRedirect() && vis) { |
|
1083 |
updateChildrenSizes(); |
|
1084 |
} |
|
1085 |
} |
|
1086 |
||
1087 |
protected void suppressWmTakeFocus(boolean doSuppress) { |
|
1088 |
} |
|
1089 |
||
1090 |
final boolean isSimpleWindow() { |
|
1091 |
return !(target instanceof Frame || target instanceof Dialog); |
|
1092 |
} |
|
1093 |
boolean hasWarningWindow() { |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
116
diff
changeset
|
1094 |
return ((Window)target).getWarningString() != null; |
2 | 1095 |
} |
1096 |
||
1097 |
// The height of menu bar window |
|
1098 |
int getMenuBarHeight() { |
|
1099 |
return 0; |
|
1100 |
} |
|
1101 |
||
1102 |
// The height of area used to display Applet's warning about securit |
|
1103 |
int getWarningWindowHeight() { |
|
1104 |
if (warningWindow != null) { |
|
1105 |
return warningWindow.getHeight(); |
|
1106 |
} else { |
|
1107 |
return 0; |
|
1108 |
} |
|
1109 |
} |
|
1110 |
||
1111 |
// Called when shell changes its size and requires children windows |
|
1112 |
// to update their sizes appropriately |
|
1113 |
void updateChildrenSizes() { |
|
1114 |
if (warningWindow != null) { |
|
1115 |
warningWindow.reshape(0, getMenuBarHeight(), getSize().width, warningWindow.getHeight()); |
|
1116 |
} |
|
1117 |
} |
|
1118 |
||
1119 |
boolean isOverrideRedirect() { |
|
1120 |
return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) || |
|
1190
f27065d0d9f0
6708392: Provide internal API to create OverrideRedirect windows, XToolkit
art
parents:
449
diff
changeset
|
1121 |
((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) || |
2 | 1122 |
XTrayIconPeer.isTrayIconStuffWindow((Window)target); |
1123 |
} |
|
1124 |
||
1125 |
final boolean isOLWMDecorBug() { |
|
1126 |
return XWM.getWMID() == XWM.OPENLOOK_WM && |
|
1127 |
winAttr.nativeDecor == false; |
|
1128 |
} |
|
1129 |
||
1130 |
public void dispose() { |
|
1131 |
SunToolkit.awtLock(); |
|
1132 |
try { |
|
1133 |
windows.remove(this); |
|
1134 |
} finally { |
|
1135 |
SunToolkit.awtUnlock(); |
|
1136 |
} |
|
1137 |
if (warningWindow != null) { |
|
1138 |
warningWindow.destroy(); |
|
1139 |
} |
|
1140 |
removeRootPropertyEventDispatcher(); |
|
1141 |
mustControlStackPosition = false; |
|
1142 |
super.dispose(); |
|
1143 |
||
1144 |
/* |
|
1145 |
* Fix for 6457980. |
|
1146 |
* When disposing an owned Window we should implicitly |
|
1147 |
* return focus to its decorated owner because it won't |
|
1148 |
* receive WM_TAKE_FOCUS. |
|
1149 |
*/ |
|
1150 |
if (isSimpleWindow()) { |
|
1151 |
if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) { |
|
1152 |
Window owner = getDecoratedOwner((Window)target); |
|
1153 |
((XWindowPeer)ComponentAccessor.getPeer(owner)).requestWindowFocus(); |
|
1154 |
} |
|
1155 |
} |
|
1156 |
} |
|
1157 |
boolean isResizable() { |
|
1158 |
return winAttr.isResizable; |
|
1159 |
} |
|
1160 |
||
1161 |
public void handleVisibilityEvent(XEvent xev) { |
|
1162 |
super.handleVisibilityEvent(xev); |
|
1163 |
XVisibilityEvent ve = xev.get_xvisibility(); |
|
1164 |
winAttr.visibilityState = ve.get_state(); |
|
1165 |
// if (ve.get_state() == XlibWrapper.VisibilityUnobscured) { |
|
1166 |
// // raiseInputMethodWindow |
|
1167 |
// } |
|
1168 |
} |
|
1169 |
||
1170 |
public void handlePropertyNotify(XEvent xev) { |
|
1171 |
super.handlePropertyNotify(xev); |
|
1172 |
XPropertyEvent ev = xev.get_xproperty(); |
|
1173 |
if (ev.get_atom() == XWM.XA_WM_STATE.getAtom()) { |
|
1174 |
// State has changed, invalidate saved value |
|
1175 |
stateChanged = true; |
|
1176 |
stateChanged(ev.get_time(), savedState, getWMState()); |
|
1177 |
} |
|
1178 |
} |
|
1179 |
||
1180 |
void handleRootPropertyNotify(XEvent xev) { |
|
1181 |
XPropertyEvent ev = xev.get_xproperty(); |
|
1182 |
if( mustControlStackPosition && |
|
1183 |
ev.get_atom() == XAtom.get("_NET_CLIENT_LIST_STACKING").getAtom()){ |
|
1184 |
// Restore stack order unhadled/spoiled by WM or some app (nautilus). |
|
1185 |
// As of now, don't use any generic machinery: just |
|
1186 |
// do toBack() again. |
|
1187 |
if(isOverrideRedirect()) { |
|
1188 |
toBack(); |
|
1189 |
} |
|
1190 |
} |
|
1191 |
} |
|
1192 |
||
1193 |
public void handleMapNotifyEvent(XEvent xev) { |
|
1194 |
// See 6480534. |
|
1195 |
isUnhiding |= isWMStateNetHidden(); |
|
1196 |
||
1197 |
super.handleMapNotifyEvent(xev); |
|
1198 |
if (!winAttr.initialFocus) { |
|
1199 |
suppressWmTakeFocus(false); // restore the protocol. |
|
1200 |
/* |
|
1201 |
* For some reason, on Metacity, a frame/dialog being shown |
|
1202 |
* without WM_TAKE_FOCUS protocol doesn't get moved to the front. |
|
1203 |
* So, we do it evidently. |
|
1204 |
*/ |
|
1205 |
XToolkit.awtLock(); |
|
1206 |
try { |
|
1207 |
XlibWrapper.XRaiseWindow(XToolkit.getDisplay(), getWindow()); |
|
1208 |
} finally { |
|
1209 |
XToolkit.awtUnlock(); |
|
1210 |
} |
|
1211 |
} |
|
1212 |
if (shouldFocusOnMapNotify()) { |
|
1213 |
focusLog.fine("Automatically request focus on window"); |
|
1214 |
requestInitialFocus(); |
|
1215 |
} |
|
1216 |
isUnhiding = false; |
|
1217 |
isBeforeFirstMapNotify = false; |
|
1218 |
updateAlwaysOnTop(); |
|
1219 |
||
1220 |
synchronized (getStateLock()) { |
|
1221 |
if (!isMapped) { |
|
1222 |
isMapped = true; |
|
1223 |
} |
|
1224 |
} |
|
1225 |
} |
|
1226 |
||
1227 |
public void handleUnmapNotifyEvent(XEvent xev) { |
|
1228 |
super.handleUnmapNotifyEvent(xev); |
|
1229 |
||
1230 |
// On Metacity UnmapNotify comes before PropertyNotify (for _NET_WM_STATE_HIDDEN). |
|
1231 |
// So we also check for the property later in MapNotify. See 6480534. |
|
1232 |
isUnhiding |= isWMStateNetHidden(); |
|
1233 |
||
1234 |
synchronized (getStateLock()) { |
|
1235 |
if (isMapped) { |
|
1236 |
isMapped = false; |
|
1237 |
} |
|
1238 |
} |
|
1239 |
} |
|
1240 |
||
1241 |
private boolean shouldFocusOnMapNotify() { |
|
1242 |
boolean res = false; |
|
1243 |
||
1244 |
if (isBeforeFirstMapNotify) { |
|
1245 |
res = (winAttr.initialFocus || // Window.autoRequestFocus |
|
1246 |
isFocusedWindowModalBlocker()); |
|
1247 |
} else { |
|
1248 |
res = isUnhiding; // Unhiding |
|
1249 |
} |
|
1250 |
res = res && |
|
1251 |
isFocusableWindow() && // General focusability |
|
1252 |
!isModalBlocked(); // Modality |
|
1253 |
||
1254 |
return res; |
|
1255 |
} |
|
1256 |
||
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1257 |
protected boolean isWMStateNetHidden() { |
2 | 1258 |
XNETProtocol protocol = XWM.getWM().getNETProtocol(); |
1259 |
return (protocol != null && protocol.isWMStateNetHidden(this)); |
|
1260 |
} |
|
1261 |
||
1262 |
protected void requestInitialFocus() { |
|
1263 |
requestXFocus(); |
|
1264 |
} |
|
1265 |
||
1266 |
public void addToplevelStateListener(ToplevelStateListener l){ |
|
1267 |
toplevelStateListeners.add(l); |
|
1268 |
} |
|
1269 |
||
1270 |
public void removeToplevelStateListener(ToplevelStateListener l){ |
|
1271 |
toplevelStateListeners.remove(l); |
|
1272 |
} |
|
1273 |
||
1274 |
/** |
|
1275 |
* Override this methods to get notifications when top-level window state changes. The state is |
|
1276 |
* meant in terms of ICCCM: WithdrawnState, IconicState, NormalState |
|
1277 |
*/ |
|
1278 |
protected void stateChanged(long time, int oldState, int newState) { |
|
1279 |
// Fix for 6401700, 6412803 |
|
1280 |
// If this window is modal blocked, it is put into the transient_for |
|
1281 |
// chain using prevTransientFor and nextTransientFor hints. However, |
|
1282 |
// the real WM_TRANSIENT_FOR hint shouldn't be set for windows in |
|
1283 |
// different WM states (except for owner-window relationship), so |
|
1284 |
// if the window changes its state, its real WM_TRANSIENT_FOR hint |
|
1285 |
// should be updated accordingly. |
|
1286 |
updateTransientFor(); |
|
1287 |
||
1288 |
for (ToplevelStateListener topLevelListenerTmp : toplevelStateListeners) { |
|
1289 |
topLevelListenerTmp.stateChangedICCCM(oldState, newState); |
|
1290 |
} |
|
1291 |
} |
|
1292 |
||
1293 |
||
1294 |
/* |
|
1295 |
* XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are |
|
1296 |
* unreliable, since mapping changes can happen for a virtual desktop |
|
1297 |
* switch or MacOS style shading that became quite popular under X as |
|
1298 |
* well. Yes, it probably should not be this way, as it violates |
|
1299 |
* ICCCM, but reality is that quite a lot of window managers abuse |
|
1300 |
* mapping state. |
|
1301 |
*/ |
|
1302 |
int getWMState() { |
|
1303 |
if (stateChanged) { |
|
1304 |
stateChanged = false; |
|
1305 |
WindowPropertyGetter getter = |
|
1306 |
new WindowPropertyGetter(window, XWM.XA_WM_STATE, 0, 1, false, |
|
1307 |
XWM.XA_WM_STATE); |
|
1308 |
try { |
|
1309 |
int status = getter.execute(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1310 |
if (status != XConstants.Success || getter.getData() == 0) { |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1311 |
return savedState = XUtilConstants.WithdrawnState; |
2 | 1312 |
} |
1313 |
||
1314 |
if (getter.getActualType() != XWM.XA_WM_STATE.getAtom() && getter.getActualFormat() != 32) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1315 |
return savedState = XUtilConstants.WithdrawnState; |
2 | 1316 |
} |
1317 |
savedState = (int)Native.getCard32(getter.getData()); |
|
1318 |
} finally { |
|
1319 |
getter.dispose(); |
|
1320 |
} |
|
1321 |
} |
|
1322 |
return savedState; |
|
1323 |
} |
|
1324 |
||
1325 |
boolean isWithdrawn() { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1326 |
return getWMState() == XUtilConstants.WithdrawnState; |
2 | 1327 |
} |
1328 |
||
1329 |
boolean hasDecorations(int decor) { |
|
1330 |
if (!winAttr.nativeDecor) { |
|
1331 |
return false; |
|
1332 |
} |
|
1333 |
else { |
|
1334 |
int myDecor = winAttr.decorations; |
|
1335 |
boolean hasBits = ((myDecor & decor) == decor); |
|
1336 |
if ((myDecor & XWindowAttributesData.AWT_DECOR_ALL) != 0) |
|
1337 |
return !hasBits; |
|
1338 |
else |
|
1339 |
return hasBits; |
|
1340 |
} |
|
1341 |
} |
|
1342 |
||
1343 |
void setReparented(boolean newValue) { |
|
1344 |
super.setReparented(newValue); |
|
1345 |
XToolkit.awtLock(); |
|
1346 |
try { |
|
1347 |
if (isReparented() && delayedModalBlocking) { |
|
1348 |
addToTransientFors((XDialogPeer) ComponentAccessor.getPeer(modalBlocker)); |
|
1349 |
delayedModalBlocking = false; |
|
1350 |
} |
|
1351 |
} finally { |
|
1352 |
XToolkit.awtUnlock(); |
|
1353 |
} |
|
1354 |
} |
|
1355 |
||
1356 |
/* |
|
1357 |
* Returns a Vector of all Java top-level windows, |
|
1358 |
* sorted by their current Z-order |
|
1359 |
*/ |
|
1360 |
static Vector<XWindowPeer> collectJavaToplevels() { |
|
1361 |
Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>(); |
|
1362 |
Vector<Long> v = new Vector<Long>(); |
|
1363 |
X11GraphicsEnvironment ge = |
|
1364 |
(X11GraphicsEnvironment)GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
1365 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
|
1366 |
if (!ge.runningXinerama() && (gds.length > 1)) { |
|
1367 |
for (GraphicsDevice gd : gds) { |
|
1368 |
int screen = ((X11GraphicsDevice)gd).getScreen(); |
|
1369 |
long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen); |
|
1370 |
v.add(rootWindow); |
|
1371 |
} |
|
1372 |
} else { |
|
1373 |
v.add(XToolkit.getDefaultRootWindow()); |
|
1374 |
} |
|
1375 |
final int windowsCount = windows.size(); |
|
1376 |
while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) { |
|
1377 |
long win = v.remove(0); |
|
1378 |
XQueryTree qt = new XQueryTree(win); |
|
1379 |
try { |
|
1380 |
if (qt.execute() != 0) { |
|
1381 |
int nchildren = qt.get_nchildren(); |
|
1382 |
long children = qt.get_children(); |
|
1383 |
// XQueryTree returns window children ordered by z-order |
|
1384 |
for (int i = 0; i < nchildren; i++) { |
|
1385 |
long child = Native.getWindow(children, i); |
|
1386 |
XBaseWindow childWindow = XToolkit.windowToXWindow(child); |
|
1387 |
// filter out Java non-toplevels |
|
1388 |
if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) { |
|
1389 |
continue; |
|
1390 |
} else { |
|
1391 |
v.add(child); |
|
1392 |
} |
|
1393 |
if (childWindow instanceof XWindowPeer) { |
|
1394 |
XWindowPeer np = (XWindowPeer)childWindow; |
|
1395 |
javaToplevels.add(np); |
|
1396 |
// XQueryTree returns windows sorted by their z-order. However, |
|
1397 |
// if WM has not handled transient for hint for a child window, |
|
1398 |
// it may appear in javaToplevels before its owner. Move such |
|
1399 |
// children after their owners. |
|
1400 |
int k = 0; |
|
1401 |
XWindowPeer toCheck = javaToplevels.get(k); |
|
1402 |
while (toCheck != np) { |
|
1403 |
XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer(); |
|
1404 |
if (toCheckOwnerPeer == np) { |
|
1405 |
javaToplevels.remove(k); |
|
1406 |
javaToplevels.add(toCheck); |
|
1407 |
} else { |
|
1408 |
k++; |
|
1409 |
} |
|
1410 |
toCheck = javaToplevels.get(k); |
|
1411 |
} |
|
1412 |
} |
|
1413 |
} |
|
1414 |
} |
|
1415 |
} finally { |
|
1416 |
qt.dispose(); |
|
1417 |
} |
|
1418 |
} |
|
1419 |
return javaToplevels; |
|
1420 |
} |
|
1421 |
||
1422 |
public void setModalBlocked(Dialog d, boolean blocked) { |
|
1423 |
setModalBlocked(d, blocked, null); |
|
1424 |
} |
|
1425 |
public void setModalBlocked(Dialog d, boolean blocked, |
|
1426 |
Vector<XWindowPeer> javaToplevels) |
|
1427 |
{ |
|
1428 |
XToolkit.awtLock(); |
|
1429 |
try { |
|
1430 |
// State lock should always be after awtLock |
|
1431 |
synchronized(getStateLock()) { |
|
1432 |
XDialogPeer blockerPeer = (XDialogPeer) ComponentAccessor.getPeer(d); |
|
1433 |
if (blocked) { |
|
1434 |
log.log(Level.FINE, "{0} is blocked by {1}", new Object[] { this, blockerPeer}); |
|
1435 |
modalBlocker = d; |
|
1436 |
||
1437 |
if (isReparented() || XWM.isNonReparentingWM()) { |
|
1438 |
addToTransientFors(blockerPeer, javaToplevels); |
|
1439 |
} else { |
|
1440 |
delayedModalBlocking = true; |
|
1441 |
} |
|
1442 |
} else { |
|
1443 |
if (d != modalBlocker) { |
|
1444 |
throw new IllegalStateException("Trying to unblock window blocked by another dialog"); |
|
1445 |
} |
|
1446 |
modalBlocker = null; |
|
1447 |
||
1448 |
if (isReparented() || XWM.isNonReparentingWM()) { |
|
1449 |
removeFromTransientFors(); |
|
1450 |
} else { |
|
1451 |
delayedModalBlocking = false; |
|
1452 |
} |
|
1453 |
} |
|
1454 |
||
1455 |
updateTransientFor(); |
|
1456 |
} |
|
1457 |
} finally { |
|
1458 |
XToolkit.awtUnlock(); |
|
1459 |
} |
|
1460 |
} |
|
1461 |
||
1462 |
/* |
|
1463 |
* Sets the TRANSIENT_FOR hint to the given top-level window. This |
|
1464 |
* method is used when a window is modal blocked/unblocked or |
|
1465 |
* changed its state from/to NormalState to/from other states. |
|
1466 |
* If window or transientForWindow are embedded frames, the containing |
|
1467 |
* top-level windows are used. |
|
1468 |
* |
|
1469 |
* @param window specifies the top-level window that the hint |
|
1470 |
* is to be set to |
|
1471 |
* @param transientForWindow the top-level window |
|
1472 |
* @param updateChain specifies if next/prevTransientFor fields are |
|
1473 |
* to be updated |
|
1474 |
* @param allStates if set to <code>true</code> then TRANSIENT_FOR hint |
|
1475 |
* is set regardless of the state of window and transientForWindow, |
|
1476 |
* otherwise it is set only if both are in the same state |
|
1477 |
*/ |
|
1478 |
static void setToplevelTransientFor(XWindowPeer window, XWindowPeer transientForWindow, |
|
1479 |
boolean updateChain, boolean allStates) |
|
1480 |
{ |
|
1481 |
if ((window == null) || (transientForWindow == null)) { |
|
1482 |
return; |
|
1483 |
} |
|
1484 |
if (updateChain) { |
|
1485 |
window.prevTransientFor = transientForWindow; |
|
1486 |
transientForWindow.nextTransientFor = window; |
|
1487 |
} |
|
1488 |
if (window.curRealTransientFor == transientForWindow) { |
|
1489 |
return; |
|
1490 |
} |
|
1491 |
if (!allStates && (window.getWMState() != transientForWindow.getWMState())) { |
|
1492 |
return; |
|
1493 |
} |
|
1494 |
if (window.getScreenNumber() != transientForWindow.getScreenNumber()) { |
|
1495 |
return; |
|
1496 |
} |
|
1497 |
long bpw = window.getWindow(); |
|
1498 |
while (!XlibUtil.isToplevelWindow(bpw) && !XlibUtil.isXAWTToplevelWindow(bpw)) { |
|
1499 |
bpw = XlibUtil.getParentWindow(bpw); |
|
1500 |
} |
|
1501 |
long tpw = transientForWindow.getWindow(); |
|
1502 |
while (!XlibUtil.isToplevelWindow(tpw) && !XlibUtil.isXAWTToplevelWindow(tpw)) { |
|
1503 |
tpw = XlibUtil.getParentWindow(tpw); |
|
1504 |
} |
|
1505 |
XlibWrapper.XSetTransientFor(XToolkit.getDisplay(), bpw, tpw); |
|
1506 |
window.curRealTransientFor = transientForWindow; |
|
1507 |
} |
|
1508 |
||
1509 |
/* |
|
1510 |
* This method does nothing if this window is not blocked by any modal dialog. |
|
1511 |
* For modal blocked windows this method looks up for the nearest |
|
1512 |
* prevTransiendFor window that is in the same state (Normal/Iconified/Withdrawn) |
|
1513 |
* as this one and makes this window transient for it. The same operation is |
|
1514 |
* performed for nextTransientFor window. |
|
1515 |
* Values of prevTransientFor and nextTransientFor fields are not changed. |
|
1516 |
*/ |
|
1517 |
void updateTransientFor() { |
|
1518 |
int state = getWMState(); |
|
1519 |
XWindowPeer p = prevTransientFor; |
|
1520 |
while ((p != null) && ((p.getWMState() != state) || (p.getScreenNumber() != getScreenNumber()))) { |
|
1521 |
p = p.prevTransientFor; |
|
1522 |
} |
|
1523 |
if (p != null) { |
|
1524 |
setToplevelTransientFor(this, p, false, false); |
|
1525 |
} else { |
|
1526 |
restoreTransientFor(this); |
|
1527 |
} |
|
1528 |
XWindowPeer n = nextTransientFor; |
|
1529 |
while ((n != null) && ((n.getWMState() != state) || (n.getScreenNumber() != getScreenNumber()))) { |
|
1530 |
n = n.nextTransientFor; |
|
1531 |
} |
|
1532 |
if (n != null) { |
|
1533 |
setToplevelTransientFor(n, this, false, false); |
|
1534 |
} |
|
1535 |
} |
|
1536 |
||
1537 |
/* |
|
1538 |
* Removes the TRANSIENT_FOR hint from the given top-level window. |
|
1539 |
* If window or transientForWindow are embedded frames, the containing |
|
1540 |
* top-level windows are used. |
|
1541 |
* |
|
1542 |
* @param window specifies the top-level window that the hint |
|
1543 |
* is to be removed from |
|
1544 |
*/ |
|
1545 |
private static void removeTransientForHint(XWindowPeer window) { |
|
1546 |
XAtom XA_WM_TRANSIENT_FOR = XAtom.get(XAtom.XA_WM_TRANSIENT_FOR); |
|
1547 |
long bpw = window.getWindow(); |
|
1548 |
while (!XlibUtil.isToplevelWindow(bpw) && !XlibUtil.isXAWTToplevelWindow(bpw)) { |
|
1549 |
bpw = XlibUtil.getParentWindow(bpw); |
|
1550 |
} |
|
1551 |
XlibWrapper.XDeleteProperty(XToolkit.getDisplay(), bpw, XA_WM_TRANSIENT_FOR.getAtom()); |
|
1552 |
window.curRealTransientFor = null; |
|
1553 |
} |
|
1554 |
||
1555 |
/* |
|
1556 |
* When a modal dialog is shown, all its blocked windows are lined up into |
|
1557 |
* a chain in such a way that each window is a transient_for window for |
|
1558 |
* the next one. That allows us to keep the modal dialog above all its |
|
1559 |
* blocked windows (even if there are some another modal dialogs between |
|
1560 |
* them). |
|
1561 |
* This method adds this top-level window to the chain of the given modal |
|
1562 |
* dialog. To keep the current relative z-order, we should use the |
|
1563 |
* XQueryTree to find the place to insert this window to. As each window |
|
1564 |
* can be blocked by only one modal dialog (such checks are performed in |
|
1565 |
* shared code), both this and blockerPeer are on the top of their chains |
|
1566 |
* (chains may be empty). |
|
1567 |
* If this window is a modal dialog and has its own chain, these chains are |
|
1568 |
* merged according to the current z-order (XQueryTree is used again). |
|
1569 |
* Below are some simple examples (z-order is from left to right, -- is |
|
1570 |
* modal blocking). |
|
1571 |
* |
|
1572 |
* Example 0: |
|
1573 |
* T (current chain of this, no windows are blocked by this) |
|
1574 |
* W1---B (current chain of blockerPeer, W2 is blocked by blockerPeer) |
|
1575 |
* Result is: |
|
1576 |
* W1-T-B (merged chain, all the windows are blocked by blockerPeer) |
|
1577 |
* |
|
1578 |
* Example 1: |
|
1579 |
* W1-T (current chain of this, W1 is blocked by this) |
|
1580 |
* W2-B (current chain of blockerPeer, W2 is blocked by blockerPeer) |
|
1581 |
* Result is: |
|
1582 |
* W1-T-W2-B (merged chain, all the windows are blocked by blockerPeer) |
|
1583 |
* |
|
1584 |
* Example 2: |
|
1585 |
* W1----T (current chain of this, W1 is blocked by this) |
|
1586 |
* W2---B (current chain of blockerPeer, W2 is blocked by blockerPeer) |
|
1587 |
* Result is: |
|
1588 |
* W1-W2-T-B (merged chain, all the windows are blocked by blockerPeer) |
|
1589 |
* |
|
1590 |
* This method should be called under the AWT lock. |
|
1591 |
* |
|
1592 |
* @see #removeFromTransientFors |
|
1593 |
* @see #setModalBlocked |
|
1594 |
*/ |
|
1595 |
private void addToTransientFors(XDialogPeer blockerPeer) { |
|
1596 |
addToTransientFors(blockerPeer, null); |
|
1597 |
} |
|
1598 |
||
1599 |
private void addToTransientFors(XDialogPeer blockerPeer, Vector<XWindowPeer> javaToplevels) |
|
1600 |
{ |
|
1601 |
// blockerPeer chain iterator |
|
1602 |
XWindowPeer blockerChain = blockerPeer; |
|
1603 |
while (blockerChain.prevTransientFor != null) { |
|
1604 |
blockerChain = blockerChain.prevTransientFor; |
|
1605 |
} |
|
1606 |
// this window chain iterator |
|
1607 |
// each window can be blocked no more than once, so this window |
|
1608 |
// is on top of its chain |
|
1609 |
XWindowPeer thisChain = this; |
|
1610 |
while (thisChain.prevTransientFor != null) { |
|
1611 |
thisChain = thisChain.prevTransientFor; |
|
1612 |
} |
|
1613 |
// if there are no windows blocked by modalBlocker, simply add this window |
|
1614 |
// and its chain to blocker's chain |
|
1615 |
if (blockerChain == blockerPeer) { |
|
1616 |
setToplevelTransientFor(blockerPeer, this, true, false); |
|
1617 |
} else { |
|
1618 |
// Collect all the Java top-levels, if required |
|
1619 |
if (javaToplevels == null) { |
|
1620 |
javaToplevels = collectJavaToplevels(); |
|
1621 |
} |
|
1622 |
// merged chain tail |
|
1623 |
XWindowPeer mergedChain = null; |
|
1624 |
for (XWindowPeer w : javaToplevels) { |
|
1625 |
XWindowPeer prevMergedChain = mergedChain; |
|
1626 |
if (w == thisChain) { |
|
1627 |
if (thisChain == this) { |
|
1628 |
if (prevMergedChain != null) { |
|
1629 |
setToplevelTransientFor(this, prevMergedChain, true, false); |
|
1630 |
} |
|
1631 |
setToplevelTransientFor(blockerChain, this, true, false); |
|
1632 |
break; |
|
1633 |
} else { |
|
1634 |
mergedChain = thisChain; |
|
1635 |
thisChain = thisChain.nextTransientFor; |
|
1636 |
} |
|
1637 |
} else if (w == blockerChain) { |
|
1638 |
mergedChain = blockerChain; |
|
1639 |
blockerChain = blockerChain.nextTransientFor; |
|
1640 |
} else { |
|
1641 |
continue; |
|
1642 |
} |
|
1643 |
if (prevMergedChain == null) { |
|
1644 |
mergedChain.prevTransientFor = null; |
|
1645 |
} else { |
|
1646 |
setToplevelTransientFor(mergedChain, prevMergedChain, true, false); |
|
1647 |
mergedChain.updateTransientFor(); |
|
1648 |
} |
|
1649 |
if (blockerChain == blockerPeer) { |
|
1650 |
setToplevelTransientFor(thisChain, mergedChain, true, false); |
|
1651 |
setToplevelTransientFor(blockerChain, this, true, false); |
|
1652 |
break; |
|
1653 |
} |
|
1654 |
} |
|
1655 |
} |
|
1656 |
||
1657 |
XToolkit.XSync(); |
|
1658 |
} |
|
1659 |
||
1660 |
static void restoreTransientFor(XWindowPeer window) { |
|
1661 |
XWindowPeer ownerPeer = window.getOwnerPeer(); |
|
1662 |
if (ownerPeer != null) { |
|
1663 |
setToplevelTransientFor(window, ownerPeer, false, true); |
|
1664 |
} else { |
|
1665 |
removeTransientForHint(window); |
|
1666 |
} |
|
1667 |
} |
|
1668 |
||
1669 |
/* |
|
1670 |
* When a window is modally unblocked, it should be removed from its blocker |
|
1671 |
* chain, see {@link #addToTransientFor addToTransientFors} method for the |
|
1672 |
* chain definition. |
|
1673 |
* The problem is that we cannot simply restore window's original |
|
1674 |
* TRANSIENT_FOR hint (if any) and link prevTransientFor and |
|
1675 |
* nextTransientFor together as the whole chain could be created as a merge |
|
1676 |
* of two other chains in addToTransientFors. In that case, if this window is |
|
1677 |
* a modal dialog, it would lost all its own chain, if we simply exclude it |
|
1678 |
* from the chain. |
|
1679 |
* The correct behaviour of this method should be to split the chain, this |
|
1680 |
* window is currently in, into two chains. First chain is this window own |
|
1681 |
* chain (i. e. all the windows blocked by this one, directly or indirectly), |
|
1682 |
* if any, and the rest windows from the current chain. |
|
1683 |
* |
|
1684 |
* Example: |
|
1685 |
* Original state: |
|
1686 |
* W1-B1 (window W1 is blocked by B1) |
|
1687 |
* W2-B2 (window W2 is blocked by B2) |
|
1688 |
* B3 is shown and blocks B1 and B2: |
|
1689 |
* W1-W2-B1-B2-B3 (a single chain after B1.addToTransientFors() and B2.addToTransientFors()) |
|
1690 |
* If we then unblock B1, the state should be: |
|
1691 |
* W1-B1 (window W1 is blocked by B1) |
|
1692 |
* W2-B2-B3 (window W2 is blocked by B2 and B2 is blocked by B3) |
|
1693 |
* |
|
1694 |
* This method should be called under the AWT lock. |
|
1695 |
* |
|
1696 |
* @see #addToTransientFors |
|
1697 |
* @see #setModalBlocked |
|
1698 |
*/ |
|
1699 |
private void removeFromTransientFors() { |
|
1700 |
// the head of the chain of this window |
|
1701 |
XWindowPeer thisChain = this; |
|
1702 |
// the head of the current chain |
|
1703 |
// nextTransientFor is always not null as this window is in the chain |
|
1704 |
XWindowPeer otherChain = nextTransientFor; |
|
1705 |
// the set of blockers in this chain: if this dialog blocks some other |
|
1706 |
// modal dialogs, their blocked windows should stay in this dialog's chain |
|
1707 |
Set<XWindowPeer> thisChainBlockers = new HashSet<XWindowPeer>(); |
|
1708 |
thisChainBlockers.add(this); |
|
1709 |
// current chain iterator in the order from next to prev |
|
1710 |
XWindowPeer chainToSplit = prevTransientFor; |
|
1711 |
while (chainToSplit != null) { |
|
1712 |
XWindowPeer blocker = (XWindowPeer) ComponentAccessor.getPeer(chainToSplit.modalBlocker); |
|
1713 |
if (thisChainBlockers.contains(blocker)) { |
|
1714 |
// add to this dialog's chain |
|
1715 |
setToplevelTransientFor(thisChain, chainToSplit, true, false); |
|
1716 |
thisChain = chainToSplit; |
|
1717 |
thisChainBlockers.add(chainToSplit); |
|
1718 |
} else { |
|
1719 |
// leave in the current chain |
|
1720 |
setToplevelTransientFor(otherChain, chainToSplit, true, false); |
|
1721 |
otherChain = chainToSplit; |
|
1722 |
} |
|
1723 |
chainToSplit = chainToSplit.prevTransientFor; |
|
1724 |
} |
|
1725 |
restoreTransientFor(thisChain); |
|
1726 |
thisChain.prevTransientFor = null; |
|
1727 |
restoreTransientFor(otherChain); |
|
1728 |
otherChain.prevTransientFor = null; |
|
1729 |
nextTransientFor = null; |
|
1730 |
||
1731 |
XToolkit.XSync(); |
|
1732 |
} |
|
1733 |
||
1734 |
boolean isModalBlocked() { |
|
1735 |
return modalBlocker != null; |
|
1736 |
} |
|
1737 |
||
1738 |
static Window getDecoratedOwner(Window window) { |
|
1739 |
while ((null != window) && !(window instanceof Frame || window instanceof Dialog)) { |
|
1740 |
window = (Window) ComponentAccessor.getParent_NoClientCode(window); |
|
1741 |
} |
|
1742 |
return window; |
|
1743 |
} |
|
1744 |
||
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1745 |
public boolean requestWindowFocus(XWindowPeer actualFocusedWindow) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1746 |
setActualFocusedWindow(actualFocusedWindow); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1747 |
return requestWindowFocus(); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1748 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1749 |
|
2 | 1750 |
public boolean requestWindowFocus() { |
1751 |
return requestWindowFocus(0, false); |
|
1752 |
} |
|
1753 |
||
1754 |
public boolean requestWindowFocus(long time, boolean timeProvided) { |
|
1755 |
focusLog.fine("Request for window focus"); |
|
1756 |
// If this is Frame or Dialog we can't assure focus request success - but we still can try |
|
1757 |
// If this is Window and its owner Frame is active we can be sure request succedded. |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1758 |
Window ownerWindow = XWindowPeer.getDecoratedOwner((Window)target); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1759 |
Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow(); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1760 |
Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); |
2 | 1761 |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1762 |
if (isWMStateNetHidden()) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1763 |
focusLog.fine("The window is unmapped, so rejecting the request"); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1764 |
return false; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1765 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1766 |
if (activeWindow == ownerWindow) { |
2 | 1767 |
focusLog.fine("Parent window is active - generating focus for this window"); |
1768 |
handleWindowFocusInSync(-1); |
|
1769 |
return true; |
|
1770 |
} |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1771 |
focusLog.fine("Parent window is not active"); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1772 |
|
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1773 |
XDecoratedPeer wpeer = (XDecoratedPeer)ComponentAccessor.getPeer(ownerWindow); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1774 |
if (wpeer != null && wpeer.requestWindowFocus(this, time, timeProvided)) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1775 |
focusLog.fine("Parent window accepted focus request - generating focus for this window"); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1776 |
return true; |
2 | 1777 |
} |
1778 |
focusLog.fine("Denied - parent window is not active and didn't accept focus request"); |
|
1779 |
return false; |
|
1780 |
} |
|
1781 |
||
1782 |
// This method is to be overriden in XDecoratedPeer. |
|
1783 |
void setActualFocusedWindow(XWindowPeer actualFocusedWindow) { |
|
1784 |
} |
|
1785 |
||
1786 |
public void xSetVisible(boolean visible) { |
|
1787 |
if (log.isLoggable(Level.FINE)) log.fine("Setting visible on " + this + " to " + visible); |
|
1788 |
XToolkit.awtLock(); |
|
1789 |
try { |
|
1790 |
this.visible = visible; |
|
1791 |
if (visible) { |
|
1792 |
XlibWrapper.XMapRaised(XToolkit.getDisplay(), getWindow()); |
|
1793 |
} else { |
|
1794 |
XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow()); |
|
1795 |
} |
|
1796 |
XlibWrapper.XFlush(XToolkit.getDisplay()); |
|
1797 |
} |
|
1798 |
finally { |
|
1799 |
XToolkit.awtUnlock(); |
|
1800 |
} |
|
1801 |
} |
|
1802 |
||
1803 |
private int dropTargetCount = 0; |
|
1804 |
||
1805 |
public synchronized void addDropTarget() { |
|
1806 |
if (dropTargetCount == 0) { |
|
1807 |
long window = getWindow(); |
|
1808 |
if (window != 0) { |
|
1809 |
XDropTargetRegistry.getRegistry().registerDropSite(window); |
|
1810 |
} |
|
1811 |
} |
|
1812 |
dropTargetCount++; |
|
1813 |
} |
|
1814 |
||
1815 |
public synchronized void removeDropTarget() { |
|
1816 |
dropTargetCount--; |
|
1817 |
if (dropTargetCount == 0) { |
|
1818 |
long window = getWindow(); |
|
1819 |
if (window != 0) { |
|
1820 |
XDropTargetRegistry.getRegistry().unregisterDropSite(window); |
|
1821 |
} |
|
1822 |
} |
|
1823 |
} |
|
1824 |
void addRootPropertyEventDispatcher() { |
|
1825 |
if( rootPropertyEventDispatcher == null ) { |
|
1826 |
rootPropertyEventDispatcher = new XEventDispatcher() { |
|
1827 |
public void dispatchEvent(XEvent ev) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1828 |
if( ev.get_type() == XConstants.PropertyNotify ) { |
2 | 1829 |
handleRootPropertyNotify( ev ); |
1830 |
} |
|
1831 |
} |
|
1832 |
}; |
|
1833 |
XlibWrapper.XSelectInput( XToolkit.getDisplay(), |
|
1834 |
XToolkit.getDefaultRootWindow(), |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1835 |
XConstants.PropertyChangeMask); |
2 | 1836 |
XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), |
1837 |
rootPropertyEventDispatcher); |
|
1838 |
} |
|
1839 |
} |
|
1840 |
void removeRootPropertyEventDispatcher() { |
|
1841 |
if( rootPropertyEventDispatcher != null ) { |
|
1842 |
XToolkit.removeEventDispatcher(XToolkit.getDefaultRootWindow(), |
|
1843 |
rootPropertyEventDispatcher); |
|
1844 |
rootPropertyEventDispatcher = null; |
|
1845 |
} |
|
1846 |
} |
|
1847 |
public void updateFocusableWindowState() { |
|
1848 |
cachedFocusableWindow = isFocusableWindow(); |
|
1849 |
} |
|
1850 |
||
1851 |
XAtom XA_NET_WM_STATE; |
|
1852 |
XAtomList net_wm_state; |
|
1853 |
public XAtomList getNETWMState() { |
|
1854 |
if (net_wm_state == null) { |
|
1855 |
net_wm_state = XA_NET_WM_STATE.getAtomListPropertyList(this); |
|
1856 |
} |
|
1857 |
return net_wm_state; |
|
1858 |
} |
|
1859 |
||
1860 |
public void setNETWMState(XAtomList state) { |
|
1861 |
net_wm_state = state; |
|
1862 |
if (state != null) { |
|
1863 |
XA_NET_WM_STATE.setAtomListProperty(this, state); |
|
1864 |
} |
|
1865 |
} |
|
1866 |
||
1867 |
public PropMwmHints getMWMHints() { |
|
1868 |
if (mwm_hints == null) { |
|
1869 |
mwm_hints = new PropMwmHints(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1870 |
if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS)) { |
2 | 1871 |
mwm_hints.zero(); |
1872 |
} |
|
1873 |
} |
|
1874 |
return mwm_hints; |
|
1875 |
} |
|
1876 |
||
1877 |
public void setMWMHints(PropMwmHints hints) { |
|
1878 |
mwm_hints = hints; |
|
1879 |
if (hints != null) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
430
diff
changeset
|
1880 |
XWM.XA_MWM_HINTS.setAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS); |
2 | 1881 |
} |
1882 |
} |
|
1883 |
||
1884 |
protected synchronized void updateDropTarget() { |
|
1885 |
if (dropTargetCount > 0) { |
|
1886 |
long window = getWindow(); |
|
1887 |
if (window != 0) { |
|
1888 |
XDropTargetRegistry.getRegistry().unregisterDropSite(window); |
|
1889 |
XDropTargetRegistry.getRegistry().registerDropSite(window); |
|
1890 |
} |
|
1891 |
} |
|
1892 |
} |
|
1893 |
||
1894 |
public void setGrab(boolean grab) { |
|
1895 |
this.grab = grab; |
|
1896 |
if (grab) { |
|
1897 |
pressTarget = this; |
|
1898 |
grabInput(); |
|
1899 |
} else { |
|
1900 |
ungrabInput(); |
|
1901 |
} |
|
1902 |
} |
|
1903 |
||
1904 |
public boolean isGrabbed() { |
|
1905 |
return grab && XAwtState.getGrabWindow() == this; |
|
1906 |
} |
|
1907 |
||
1908 |
public void handleXCrossingEvent(XEvent xev) { |
|
1909 |
XCrossingEvent xce = xev.get_xcrossing(); |
|
1910 |
if (grabLog.isLoggable(Level.FINE)) { |
|
1911 |
grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2}", |
|
1912 |
new Object[] {xce, isGrabbed(), containsGlobal(xce.get_x_root(), xce.get_y_root())}); |
|
1913 |
} |
|
1914 |
if (isGrabbed()) { |
|
1915 |
// When window is grabbed, all events are dispatched to |
|
1916 |
// it. Retarget them to the corresponding windows (notice |
|
1917 |
// that XBaseWindow.dispatchEvent does the opposite |
|
1918 |
// translation) |
|
1919 |
// Note that we need to retarget XCrossingEvents to content window |
|
1920 |
// since it generates MOUSE_ENTERED/MOUSE_EXITED for frame and dialog. |
|
1921 |
// (fix for 6390326) |
|
1922 |
XBaseWindow target = XToolkit.windowToXWindow(xce.get_window()); |
|
1923 |
grabLog.log(Level.FINER, " - Grab event target {0}", new Object[] {target}); |
|
1924 |
if (target != null && target != this) { |
|
1925 |
target.dispatchEvent(xev); |
|
1926 |
return; |
|
1927 |
} |
|
1928 |
} |
|
1929 |
super.handleXCrossingEvent(xev); |
|
1930 |
} |
|
1931 |
||
1932 |
public void handleMotionNotify(XEvent xev) { |
|
1933 |
XMotionEvent xme = xev.get_xmotion(); |
|
1934 |
if (grabLog.isLoggable(Level.FINE)) { |
|
1935 |
grabLog.log(Level.FINER, "{0}, when grabbed {1}, contains {2}", |
|
1936 |
new Object[] {xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())}); |
|
1937 |
} |
|
1938 |
if (isGrabbed()) { |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1939 |
boolean dragging = false; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1940 |
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1941 |
// here is the bug in WM: extra buttons doesn't have state!=0 as they should. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1942 |
if ((i != 4) && (i != 5)){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1943 |
dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1944 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1945 |
} |
2 | 1946 |
// When window is grabbed, all events are dispatched to |
1947 |
// it. Retarget them to the corresponding windows (notice |
|
1948 |
// that XBaseWindow.dispatchEvent does the opposite |
|
1949 |
// translation) |
|
1950 |
XBaseWindow target = XToolkit.windowToXWindow(xme.get_window()); |
|
1951 |
if (dragging && pressTarget != target) { |
|
1952 |
// for some reasons if we grab input MotionNotify for drag is reported with target |
|
1953 |
// to underlying window, not to window on which we have initiated drag |
|
1954 |
// so we need to retarget them. Here I use simplified logic which retarget all |
|
1955 |
// such events to source of mouse press (or the grabber). It helps with fix for 6390326. |
|
1956 |
// So, I do not want to implement complicated logic for better retargeting. |
|
1957 |
target = pressTarget.isVisible() ? pressTarget : this; |
|
1958 |
xme.set_window(target.getWindow()); |
|
430
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
1959 |
Point localCoord = target.toLocal(xme.get_x_root(), xme.get_y_root()); |
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
1960 |
xme.set_x(localCoord.x); |
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
1961 |
xme.set_y(localCoord.y); |
2 | 1962 |
} |
1963 |
grabLog.log(Level.FINER, " - Grab event target {0}", new Object[] {target}); |
|
1964 |
if (target != null) { |
|
1965 |
if (target != getContentXWindow() && target != this) { |
|
1966 |
target.dispatchEvent(xev); |
|
1967 |
return; |
|
1968 |
} |
|
1969 |
} |
|
1970 |
||
1971 |
// note that we need to pass dragging events to the grabber (6390326) |
|
1972 |
// see comment above for more inforamtion. |
|
1973 |
if (!containsGlobal(xme.get_x_root(), xme.get_y_root()) && !dragging) { |
|
1974 |
// Outside of Java |
|
1975 |
return; |
|
1976 |
} |
|
1977 |
} |
|
1978 |
super.handleMotionNotify(xev); |
|
1979 |
} |
|
1980 |
||
1981 |
// we use it to retarget mouse drag and mouse release during grab. |
|
1982 |
private XBaseWindow pressTarget = this; |
|
1983 |
||
1984 |
public void handleButtonPressRelease(XEvent xev) { |
|
1985 |
XButtonEvent xbe = xev.get_xbutton(); |
|
1986 |
if (grabLog.isLoggable(Level.FINE)) { |
|
1987 |
grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2} ({3}, {4}, {5}x{6})", |
|
1988 |
new Object[] {xbe, isGrabbed(), containsGlobal(xbe.get_x_root(), xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()}); |
|
1989 |
} |
|
1990 |
if (isGrabbed()) { |
|
1991 |
// When window is grabbed, all events are dispatched to |
|
1992 |
// it. Retarget them to the corresponding windows (notice |
|
1993 |
// that XBaseWindow.dispatchEvent does the opposite |
|
1994 |
// translation) |
|
1995 |
XBaseWindow target = XToolkit.windowToXWindow(xbe.get_window()); |
|
1996 |
try { |
|
1997 |
grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", new Object[] {target, pressTarget}); |
|
1998 |
if (xbe.get_type() == XConstants.ButtonPress |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
1999 |
&& xbe.get_button() == XConstants.buttons[0]) |
2 | 2000 |
{ |
2001 |
// need to keep it to retarget mouse release |
|
2002 |
pressTarget = target; |
|
2003 |
} else if (xbe.get_type() == XConstants.ButtonRelease |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
2004 |
&& xbe.get_button() == XConstants.buttons[0] |
2 | 2005 |
&& pressTarget != target) |
2006 |
{ |
|
2007 |
// during grab we do receive mouse release on different component (not on the source |
|
2008 |
// of mouse press). So we need to retarget it. |
|
2009 |
// see 6390326 for more information. |
|
2010 |
target = pressTarget.isVisible() ? pressTarget : this; |
|
2011 |
xbe.set_window(target.getWindow()); |
|
430
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
2012 |
Point localCoord = target.toLocal(xbe.get_x_root(), xbe.get_y_root()); |
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
2013 |
xbe.set_x(localCoord.x); |
ff8a4a3ad82f
6508505: JComboBox collapses immediately if it is placed to embedded frame
dcherepanov
parents:
129
diff
changeset
|
2014 |
xbe.set_y(localCoord.y); |
2 | 2015 |
pressTarget = this; |
2016 |
} |
|
2017 |
if (target != null && target != getContentXWindow() && target != this) { |
|
2018 |
target.dispatchEvent(xev); |
|
2019 |
return; |
|
2020 |
} |
|
2021 |
} finally { |
|
2022 |
if (target != null) { |
|
2023 |
// Target is either us or our content window - |
|
2024 |
// check that event is inside. 'Us' in case of |
|
2025 |
// shell will mean that this will also filter out press on title |
|
2026 |
if ((target == this || target == getContentXWindow()) && !containsGlobal(xbe.get_x_root(), xbe.get_y_root())) { |
|
2027 |
// Outside this toplevel hierarchy |
|
2028 |
// According to the specification of UngrabEvent, post it |
|
2029 |
// when press occurs outside of the window and not on its owned windows |
|
2030 |
grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because not inside of shell", this); |
|
2031 |
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); |
|
2032 |
return; |
|
2033 |
} |
|
2034 |
// First, get the toplevel |
|
2035 |
XWindowPeer toplevel = target.getToplevelXWindow(); |
|
2036 |
if (toplevel != null) { |
|
2037 |
Window w = (Window)toplevel.target; |
|
2038 |
while (w != null && toplevel != this && !(toplevel instanceof XDialogPeer)) { |
|
2039 |
w = (Window) ComponentAccessor.getParent_NoClientCode(w); |
|
2040 |
if (w != null) { |
|
2041 |
toplevel = (XWindowPeer) ComponentAccessor.getPeer(w); |
|
2042 |
} |
|
2043 |
} |
|
2044 |
if (w == null || (w != this.target && w instanceof Dialog)) { |
|
2045 |
// toplevel == null - outside of |
|
2046 |
// hierarchy, toplevel is Dialog - should |
|
2047 |
// send ungrab (but shouldn't for Window) |
|
2048 |
grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because hierarchy ended", this); |
|
2049 |
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); |
|
2050 |
} |
|
2051 |
} else { |
|
2052 |
// toplevel is null - outside of hierarchy |
|
2053 |
grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because toplevel is null", this); |
|
2054 |
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); |
|
2055 |
return; |
|
2056 |
} |
|
2057 |
} else { |
|
2058 |
// target doesn't map to XAWT window - outside of hierarchy |
|
2059 |
grabLog.log(Level.FINE, "Generating UngrabEvent on because target is null {0}", this); |
|
2060 |
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); |
|
2061 |
return; |
|
2062 |
} |
|
2063 |
} |
|
2064 |
} |
|
2065 |
super.handleButtonPressRelease(xev); |
|
2066 |
} |
|
2067 |
} |