author | ssadetsky |
Tue, 18 Oct 2016 12:43:07 +0300 | |
changeset 41802 | 89f634379c0c |
parent 41409 | 04b42eb73ee6 |
child 43081 | 66a49615076d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
39856
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
2 |
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
||
29 |
import java.awt.event.ComponentEvent; |
|
30 |
import java.awt.event.InvocationEvent; |
|
31 |
import java.awt.event.WindowEvent; |
|
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
32 |
import java.util.Collections; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
33 |
import java.util.HashMap; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
34 |
import java.util.Map; |
2 | 35 |
|
18241 | 36 |
import sun.awt.IconInfo; |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
37 |
import sun.util.logging.PlatformLogger; |
2 | 38 |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
39 |
import sun.awt.AWTAccessor; |
2 | 40 |
import sun.awt.SunToolkit; |
41 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
42 |
abstract class XDecoratedPeer extends XWindowPeer { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
43 |
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XDecoratedPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
44 |
private static final PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
45 |
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
46 |
private static final PlatformLogger iconLog = PlatformLogger.getLogger("sun.awt.X11.icon.XDecoratedPeer"); |
2 | 47 |
|
48 |
// Set to true when we get the first ConfigureNotify after being |
|
49 |
// reparented - indicates that WM has adopted the top-level. |
|
50 |
boolean configure_seen; |
|
51 |
boolean insets_corrected; |
|
52 |
||
53 |
XIconWindow iconWindow; |
|
54 |
WindowDimensions dimensions; |
|
55 |
XContentWindow content; |
|
56 |
Insets currentInsets; |
|
57 |
XFocusProxyWindow focusProxy; |
|
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
58 |
static final Map<Class<?>,Insets> lastKnownInsets = |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
59 |
Collections.synchronizedMap(new HashMap<>()); |
2 | 60 |
|
61 |
XDecoratedPeer(Window target) { |
|
62 |
super(target); |
|
63 |
} |
|
64 |
||
65 |
XDecoratedPeer(XCreateWindowParams params) { |
|
66 |
super(params); |
|
67 |
} |
|
68 |
||
69 |
public long getShell() { |
|
70 |
return window; |
|
71 |
} |
|
72 |
||
73 |
public long getContentWindow() { |
|
74 |
return (content == null) ? window : content.getWindow(); |
|
75 |
} |
|
76 |
||
77 |
void preInit(XCreateWindowParams params) { |
|
78 |
super.preInit(params); |
|
79 |
winAttr.initialFocus = true; |
|
80 |
||
449 | 81 |
currentInsets = new Insets(0,0,0,0); |
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
82 |
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
83 |
currentInsets = lastKnownInsets.get(getClass()); |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
84 |
} |
449 | 85 |
applyGuessedInsets(); |
2 | 86 |
|
87 |
Rectangle bounds = (Rectangle)params.get(BOUNDS); |
|
88 |
dimensions = new WindowDimensions(bounds, getRealInsets(), false); |
|
89 |
params.put(BOUNDS, dimensions.getClientRect()); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
90 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
91 |
insLog.fine("Initial dimensions {0}", dimensions); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
92 |
} |
2 | 93 |
|
94 |
// Deny default processing of these events on the shell - proxy will take care of |
|
95 |
// them instead |
|
96 |
Long eventMask = (Long)params.get(EVENT_MASK); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
97 |
params.add(EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask))); |
2 | 98 |
} |
99 |
||
100 |
void postInit(XCreateWindowParams params) { |
|
6822
0a6eba317c96
6895647: Frame may jump to an unpredicted location upon entering the non-opaque mode on X11
anthony
parents:
6637
diff
changeset
|
101 |
// The size hints must be set BEFORE mapping the window (see 6895647) |
0a6eba317c96
6895647: Frame may jump to an unpredicted location upon entering the non-opaque mode on X11
anthony
parents:
6637
diff
changeset
|
102 |
updateSizeHints(dimensions); |
0a6eba317c96
6895647: Frame may jump to an unpredicted location upon entering the non-opaque mode on X11
anthony
parents:
6637
diff
changeset
|
103 |
|
0a6eba317c96
6895647: Frame may jump to an unpredicted location upon entering the non-opaque mode on X11
anthony
parents:
6637
diff
changeset
|
104 |
// The super method maps the window if it's visible on the shared level |
2 | 105 |
super.postInit(params); |
6822
0a6eba317c96
6895647: Frame may jump to an unpredicted location upon entering the non-opaque mode on X11
anthony
parents:
6637
diff
changeset
|
106 |
|
2 | 107 |
// The lines that follow need to be in a postInit, so they |
108 |
// happen after the X window is created. |
|
109 |
initResizability(); |
|
449 | 110 |
XWM.requestWMExtents(getWindow()); |
111 |
||
115 | 112 |
content = XContentWindow.createContent(this); |
449 | 113 |
|
2 | 114 |
if (warningWindow != null) { |
115 |
warningWindow.toFront(); |
|
116 |
} |
|
117 |
focusProxy = createFocusProxy(); |
|
118 |
} |
|
119 |
||
18241 | 120 |
void setIconHints(java.util.List<IconInfo> icons) { |
2 | 121 |
if (!XWM.getWM().setNetWMIcon(this, icons)) { |
122 |
if (icons.size() > 0) { |
|
123 |
if (iconWindow == null) { |
|
124 |
iconWindow = new XIconWindow(this); |
|
125 |
} |
|
126 |
iconWindow.setIconImages(icons); |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
public void updateMinimumSize() { |
|
132 |
super.updateMinimumSize(); |
|
133 |
updateMinSizeHints(); |
|
134 |
} |
|
135 |
||
136 |
private void updateMinSizeHints() { |
|
137 |
if (isResizable()) { |
|
138 |
Dimension minimumSize = getTargetMinimumSize(); |
|
139 |
if (minimumSize != null) { |
|
140 |
Insets insets = getRealInsets(); |
|
141 |
int minWidth = minimumSize.width - insets.left - insets.right; |
|
142 |
int minHeight = minimumSize.height - insets.top - insets.bottom; |
|
143 |
if (minWidth < 0) minWidth = 0; |
|
144 |
if (minHeight < 0) minHeight = 0; |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
145 |
setSizeHints(XUtilConstants.PMinSize | (isLocationByPlatform()?0:(XUtilConstants.PPosition | XUtilConstants.USPosition)), |
2 | 146 |
getX(), getY(), minWidth, minHeight); |
147 |
if (isVisible()) { |
|
148 |
Rectangle bounds = getShellBounds(); |
|
149 |
int nw = (bounds.width < minWidth) ? minWidth : bounds.width; |
|
150 |
int nh = (bounds.height < minHeight) ? minHeight : bounds.height; |
|
151 |
if (nw != bounds.width || nh != bounds.height) { |
|
152 |
setShellSize(new Rectangle(0, 0, nw, nh)); |
|
153 |
} |
|
154 |
} |
|
155 |
} else { |
|
156 |
boolean isMinSizeSet = isMinSizeSet(); |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
157 |
XWM.removeSizeHints(this, XUtilConstants.PMinSize); |
2 | 158 |
/* Some WMs need remap to redecorate the window */ |
159 |
if (isMinSizeSet && isShowing() && XWM.needRemap(this)) { |
|
160 |
/* |
|
161 |
* Do the re/mapping at the Xlib level. Since we essentially |
|
162 |
* work around a WM bug we don't want this hack to be exposed |
|
163 |
* to Intrinsics (i.e. don't mess with grabs, callbacks etc). |
|
164 |
*/ |
|
165 |
xSetVisible(false); |
|
166 |
XToolkit.XSync(); |
|
167 |
xSetVisible(true); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
||
173 |
XFocusProxyWindow createFocusProxy() { |
|
174 |
return new XFocusProxyWindow(this); |
|
175 |
} |
|
176 |
||
177 |
protected XAtomList getWMProtocols() { |
|
178 |
XAtomList protocols = super.getWMProtocols(); |
|
179 |
protocols.add(wm_delete_window); |
|
180 |
protocols.add(wm_take_focus); |
|
181 |
return protocols; |
|
182 |
} |
|
183 |
||
184 |
public Graphics getGraphics() { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
185 |
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
2 | 186 |
return getGraphics(content.surfaceData, |
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
187 |
compAccessor.getForeground(target), |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
188 |
compAccessor.getBackground(target), |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
189 |
compAccessor.getFont(target)); |
2 | 190 |
} |
191 |
||
192 |
public void setTitle(String title) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
193 |
if (log.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
194 |
log.fine("Title is " + title); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
195 |
} |
2 | 196 |
winAttr.title = title; |
197 |
updateWMName(); |
|
198 |
} |
|
199 |
||
200 |
protected String getWMName() { |
|
201 |
if (winAttr.title == null || winAttr.title.trim().equals("")) { |
|
202 |
return " "; |
|
203 |
} else { |
|
204 |
return winAttr.title; |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
void updateWMName() { |
|
209 |
super.updateWMName(); |
|
210 |
String name = getWMName(); |
|
211 |
XToolkit.awtLock(); |
|
212 |
try { |
|
213 |
if (name == null || name.trim().equals("")) { |
|
214 |
name = "Java"; |
|
215 |
} |
|
216 |
XAtom iconNameAtom = XAtom.get(XAtom.XA_WM_ICON_NAME); |
|
217 |
iconNameAtom.setProperty(getWindow(), name); |
|
218 |
XAtom netIconNameAtom = XAtom.get("_NET_WM_ICON_NAME"); |
|
219 |
netIconNameAtom.setPropertyUTF8(getWindow(), name); |
|
220 |
} finally { |
|
221 |
XToolkit.awtUnlock(); |
|
222 |
} |
|
223 |
} |
|
224 |
||
225 |
// NOTE: This method may be called by privileged threads. |
|
226 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
227 |
public void handleIconify() { |
|
228 |
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED)); |
|
229 |
} |
|
230 |
||
231 |
// NOTE: This method may be called by privileged threads. |
|
232 |
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
233 |
public void handleDeiconify() { |
|
234 |
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED)); |
|
235 |
} |
|
236 |
||
237 |
public void handleFocusEvent(XEvent xev) { |
|
238 |
super.handleFocusEvent(xev); |
|
239 |
XFocusChangeEvent xfe = xev.get_xfocus(); |
|
240 |
||
241 |
// If we somehow received focus events forward it instead to proxy |
|
242 |
// FIXME: Shouldn't we instead check for inferrior? |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
243 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
244 |
focusLog.finer("Received focus event on shell: " + xfe); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
245 |
} |
2 | 246 |
// focusProxy.xRequestFocus(); |
247 |
} |
|
248 |
||
249 |
/*************************************************************************************** |
|
250 |
* I N S E T S C O D E |
|
251 |
**************************************************************************************/ |
|
252 |
||
253 |
protected boolean isInitialReshape() { |
|
254 |
return false; |
|
255 |
} |
|
256 |
||
449 | 257 |
private static Insets difference(Insets i1, Insets i2) { |
2 | 258 |
return new Insets(i1.top-i2.top, i1.left - i2.left, i1.bottom-i2.bottom, i1.right-i2.right); |
259 |
} |
|
260 |
||
449 | 261 |
private static boolean isNull(Insets i) { |
2 | 262 |
return (i == null) || ((i.left | i.top | i.right | i.bottom) == 0); |
263 |
} |
|
449 | 264 |
|
265 |
private static Insets copy(Insets i) { |
|
2 | 266 |
return new Insets(i.top, i.left, i.bottom, i.right); |
267 |
} |
|
268 |
||
40161
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
269 |
private Insets copyAndScaleDown(Insets i) { |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
270 |
return new Insets(scaleDown(i.top), scaleDown(i.left), |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
271 |
scaleDown(i.bottom), scaleDown(i.right)); |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
272 |
} |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
273 |
|
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
274 |
|
449 | 275 |
// insets which we get from WM (e.g from _NET_FRAME_EXTENTS) |
276 |
private Insets wm_set_insets; |
|
277 |
||
278 |
private Insets getWMSetInsets(XAtom changedAtom) { |
|
279 |
if (isEmbedded()) { |
|
280 |
return null; |
|
281 |
} |
|
282 |
||
283 |
if (wm_set_insets != null) { |
|
284 |
return wm_set_insets; |
|
285 |
} |
|
286 |
||
287 |
if (changedAtom == null) { |
|
288 |
wm_set_insets = XWM.getInsetsFromExtents(getWindow()); |
|
289 |
} else { |
|
290 |
wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); |
|
291 |
} |
|
292 |
||
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
293 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
294 |
insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
295 |
} |
449 | 296 |
|
297 |
if (wm_set_insets != null) { |
|
40161
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
298 |
wm_set_insets = copyAndScaleDown(wm_set_insets); |
449 | 299 |
} |
300 |
return wm_set_insets; |
|
301 |
} |
|
302 |
||
303 |
private void resetWMSetInsets() { |
|
41802
89f634379c0c
8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
41409
diff
changeset
|
304 |
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { |
89f634379c0c
8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
41409
diff
changeset
|
305 |
currentInsets = new Insets(0, 0, 0, 0); |
89f634379c0c
8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
41409
diff
changeset
|
306 |
wm_set_insets = null; |
89f634379c0c
8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
41409
diff
changeset
|
307 |
} |
449 | 308 |
} |
309 |
||
310 |
public void handlePropertyNotify(XEvent xev) { |
|
311 |
super.handlePropertyNotify(xev); |
|
312 |
||
313 |
XPropertyEvent ev = xev.get_xproperty(); |
|
41409
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
314 |
if( !insets_corrected && isReparented() && |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
315 |
XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
316 |
int state = XWM.getWM().getState(this); |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
317 |
if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) { |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
318 |
// Stop ignoring ConfigureNotify because no extents will be sent |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
319 |
// by WM for initially maximized decorated window. |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
320 |
// Re-request window bounds to ensure actual dimensions and |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
321 |
// notify the target with the initial size. |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
322 |
insets_corrected = true; |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
323 |
XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
324 |
getWindow(), 0, 0); |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
325 |
} |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
326 |
} |
449 | 327 |
if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom() |
328 |
|| ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom()) |
|
329 |
{ |
|
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
330 |
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
331 |
getWMSetInsets(XAtom.get(ev.get_atom())); |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
332 |
} else { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
333 |
if(!isReparented()) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
334 |
return; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
335 |
} |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
336 |
wm_set_insets = null; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
337 |
Insets in = getWMSetInsets(XAtom.get(ev.get_atom())); |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
338 |
if (isNull(in)) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
339 |
return; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
340 |
} |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
341 |
if (!isEmbedded() && !isTargetUndecorated()) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
342 |
lastKnownInsets.put(getClass(), in); |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
343 |
} |
41409
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
344 |
if (!in.equals(dimensions.getInsets())) { |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
345 |
if (insets_corrected || isMaximized()) { |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
346 |
currentInsets = in; |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
347 |
insets_corrected = true; |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
348 |
// insets were changed by WM. To handle this situation |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
349 |
// re-request window bounds because the current |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
350 |
// dimensions may be not actual as well. |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
351 |
XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
352 |
getWindow(), 0, 0); |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
353 |
} else { |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
354 |
// recalculate dimensions when window is just created |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
355 |
// and the initially guessed insets were wrong |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
356 |
handleCorrectInsets(in); |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
357 |
} |
41802
89f634379c0c
8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
41409
diff
changeset
|
358 |
} else if (!insets_corrected || !dimensions.isClientSizeSet()) { |
41409
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
359 |
insets_corrected = true; |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
360 |
// initial insets were guessed correctly. Re-request |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
361 |
// frame bounds because they may be changed by WM if the |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
362 |
// initial window position overlapped desktop's toolbars. |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
363 |
// This should initiate the final ConfigureNotify upon which |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
364 |
// the target will be notified with the final size. |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
365 |
XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), |
04b42eb73ee6
8165619: Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
ssadetsky
parents:
41393
diff
changeset
|
366 |
getWindow(), 0, 0); |
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
367 |
} |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
368 |
} |
449 | 369 |
} |
370 |
} |
|
371 |
||
2 | 372 |
long reparent_serial = 0; |
373 |
||
374 |
public void handleReparentNotifyEvent(XEvent xev) { |
|
375 |
XReparentEvent xe = xev.get_xreparent(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
376 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
377 |
insLog.fine(xe.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
378 |
} |
2 | 379 |
reparent_serial = xe.get_serial(); |
380 |
XToolkit.awtLock(); |
|
381 |
try { |
|
382 |
long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); |
|
383 |
||
384 |
if (isEmbedded()) { |
|
385 |
setReparented(true); |
|
386 |
insets_corrected = true; |
|
387 |
return; |
|
388 |
} |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
389 |
Component t = target; |
115 | 390 |
if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) { |
2 | 391 |
setReparented(true); |
392 |
insets_corrected = true; |
|
393 |
reshape(dimensions, SET_SIZE, false); |
|
394 |
} else if (xe.get_parent() == root) { |
|
395 |
configure_seen = false; |
|
396 |
insets_corrected = false; |
|
397 |
||
398 |
/* |
|
399 |
* We can be repareted to root for two reasons: |
|
400 |
* . setVisible(false) |
|
401 |
* . WM exited |
|
402 |
*/ |
|
403 |
if (isVisible()) { /* WM exited */ |
|
404 |
/* Work around 4775545 */ |
|
405 |
XWM.getWM().unshadeKludge(this); |
|
406 |
insLog.fine("- WM exited"); |
|
407 |
} else { |
|
408 |
insLog.fine(" - reparent due to hide"); |
|
409 |
} |
|
410 |
} else { /* reparented to WM frame, figure out our insets */ |
|
411 |
setReparented(true); |
|
412 |
insets_corrected = false; |
|
41393
ebc8d972cd3f
8161910: [PIT] regression: HW/LW mixing seems broken on Unity
ssadetsky
parents:
40161
diff
changeset
|
413 |
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { |
ebc8d972cd3f
8161910: [PIT] regression: HW/LW mixing seems broken on Unity
ssadetsky
parents:
40161
diff
changeset
|
414 |
return; |
ebc8d972cd3f
8161910: [PIT] regression: HW/LW mixing seems broken on Unity
ssadetsky
parents:
40161
diff
changeset
|
415 |
} |
2 | 416 |
|
417 |
// Check if we have insets provided by the WM |
|
418 |
Insets correctWM = getWMSetInsets(null); |
|
419 |
if (correctWM != null) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
420 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
421 |
insLog.finer("wm-provided insets {0}", correctWM); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
422 |
} |
2 | 423 |
// If these insets are equal to our current insets - no actions are necessary |
424 |
Insets dimInsets = dimensions.getInsets(); |
|
425 |
if (correctWM.equals(dimInsets)) { |
|
426 |
insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); |
|
427 |
no_reparent_artifacts = true; |
|
428 |
insets_corrected = true; |
|
429 |
applyGuessedInsets(); |
|
430 |
return; |
|
431 |
} |
|
432 |
} else { |
|
433 |
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); |
|
40161
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
434 |
if (correctWM != null) { |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
435 |
correctWM = copyAndScaleDown(correctWM); |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
436 |
} |
2 | 437 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
438 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
439 |
if (correctWM != null) { |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
440 |
insLog.finer("correctWM {0}", correctWM); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
441 |
} else { |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
442 |
insLog.finer("correctWM insets are not available, waiting for configureNotify"); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
443 |
} |
2 | 444 |
} |
445 |
} |
|
446 |
||
41393
ebc8d972cd3f
8161910: [PIT] regression: HW/LW mixing seems broken on Unity
ssadetsky
parents:
40161
diff
changeset
|
447 |
if (correctWM != null) { |
2 | 448 |
handleCorrectInsets(correctWM); |
449 |
} |
|
450 |
} |
|
451 |
} finally { |
|
452 |
XToolkit.awtUnlock(); |
|
453 |
} |
|
454 |
} |
|
455 |
||
456 |
protected void handleCorrectInsets(Insets correctWM) { |
|
457 |
XToolkit.awtLock(); |
|
458 |
try { |
|
459 |
/* |
|
460 |
* Ok, now see if we need adjust window size because |
|
461 |
* initial insets were wrong (most likely they were). |
|
462 |
*/ |
|
463 |
Insets correction = difference(correctWM, currentInsets); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
464 |
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
465 |
insLog.finest("Corrention {0}", correction); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
466 |
} |
2 | 467 |
if (!isNull(correction)) { |
449 | 468 |
currentInsets = copy(correctWM); |
2 | 469 |
applyGuessedInsets(); |
470 |
||
471 |
//Fix for 6318109: PIT: Min Size is not honored properly when a |
|
472 |
//smaller size is specified in setSize(), XToolkit |
|
473 |
//update minimum size hints |
|
474 |
updateMinSizeHints(); |
|
475 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
476 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
477 |
insLog.finer("Dimensions before reparent: " + dimensions); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
478 |
} |
2 | 479 |
|
480 |
dimensions.setInsets(getRealInsets()); |
|
481 |
insets_corrected = true; |
|
482 |
||
2466
32f16bfa9608
6805897: Gap present between the choice and its drop down list in Jdk 7 build for a non resizable frame.
dcherepanov
parents:
1977
diff
changeset
|
483 |
if (isMaximized()) { |
2 | 484 |
return; |
485 |
} |
|
486 |
||
449 | 487 |
/* |
488 |
* If this window has been sized by a pack() we need |
|
489 |
* to keep the interior geometry intact. Since pack() |
|
490 |
* computed width and height with wrong insets, we |
|
491 |
* must adjust the target dimensions appropriately. |
|
492 |
*/ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
493 |
if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) { |
2 | 494 |
reshape(dimensions, SET_BOUNDS, false); |
495 |
} else { |
|
496 |
reshape(dimensions, SET_SIZE, false); |
|
497 |
} |
|
498 |
} finally { |
|
499 |
XToolkit.awtUnlock(); |
|
500 |
} |
|
501 |
} |
|
502 |
||
503 |
public void handleMoved(WindowDimensions dims) { |
|
504 |
Point loc = dims.getLocation(); |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
505 |
AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y); |
2 | 506 |
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); |
507 |
} |
|
508 |
||
509 |
||
510 |
protected Insets guessInsets() { |
|
449 | 511 |
if (isEmbedded() || isTargetUndecorated()) { |
2 | 512 |
return new Insets(0, 0, 0, 0); |
513 |
} else { |
|
449 | 514 |
if (!isNull(currentInsets)) { |
2 | 515 |
/* insets were set on wdata by System Properties */ |
516 |
return copy(currentInsets); |
|
517 |
} else { |
|
518 |
Insets res = getWMSetInsets(null); |
|
519 |
if (res == null) { |
|
520 |
res = XWM.getWM().guessInsets(this); |
|
40161
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
521 |
if (res != null) { |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
522 |
res = copyAndScaleDown(res); |
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
523 |
} |
2 | 524 |
} |
525 |
return res; |
|
526 |
} |
|
527 |
} |
|
528 |
} |
|
529 |
||
530 |
private void applyGuessedInsets() { |
|
531 |
Insets guessed = guessInsets(); |
|
532 |
currentInsets = copy(guessed); |
|
533 |
} |
|
534 |
||
535 |
public void revalidate() { |
|
536 |
XToolkit.executeOnEventHandlerThread(target, new Runnable() { |
|
537 |
public void run() { |
|
538 |
target.invalidate(); |
|
539 |
target.validate(); |
|
540 |
} |
|
541 |
}); |
|
542 |
} |
|
543 |
||
544 |
Insets getRealInsets() { |
|
449 | 545 |
if (isNull(currentInsets)) { |
2 | 546 |
applyGuessedInsets(); |
547 |
} |
|
449 | 548 |
return currentInsets; |
2 | 549 |
} |
550 |
||
551 |
public Insets getInsets() { |
|
552 |
Insets in = copy(getRealInsets()); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2466
diff
changeset
|
553 |
in.top += getMenuBarHeight(); |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
554 |
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
555 |
insLog.finest("Get insets returns {0}", in); |
449 | 556 |
} |
2 | 557 |
return in; |
558 |
} |
|
559 |
||
560 |
boolean gravityBug() { |
|
561 |
return XWM.configureGravityBuggy(); |
|
562 |
} |
|
563 |
||
564 |
// The height of area used to display current active input method |
|
565 |
int getInputMethodHeight() { |
|
566 |
return 0; |
|
567 |
} |
|
568 |
||
569 |
void updateSizeHints(WindowDimensions dims) { |
|
570 |
Rectangle rec = dims.getClientRect(); |
|
571 |
checkShellRect(rec); |
|
572 |
updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
|
573 |
} |
|
574 |
||
575 |
void updateSizeHints() { |
|
576 |
updateSizeHints(dimensions); |
|
577 |
} |
|
578 |
||
579 |
// Coordinates are that of the target |
|
580 |
// Called only on Toolkit thread |
|
581 |
public void reshape(WindowDimensions newDimensions, int op, |
|
582 |
boolean userReshape) |
|
583 |
{ |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
584 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 585 |
insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape); |
586 |
} |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
587 |
if (userReshape) { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
588 |
// We handle only userReshape == true cases. It means that |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
589 |
// if the window manager or any other part of the windowing |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
590 |
// system sets inappropriate size for this window, we can |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
591 |
// do nothing but accept it. |
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
592 |
Rectangle newBounds = newDimensions.getBounds(); |
1977
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
593 |
Insets insets = newDimensions.getInsets(); |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
594 |
// Inherit isClientSizeSet from newDimensions |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
595 |
if (newDimensions.isClientSizeSet()) { |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
596 |
newBounds = new Rectangle(newBounds.x, newBounds.y, |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
597 |
newBounds.width - insets.left - insets.right, |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
598 |
newBounds.height - insets.top - insets.bottom); |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
599 |
} |
3a9980ccb120
6721088: Bad window size calculation after using pack()
art
parents:
449
diff
changeset
|
600 |
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet()); |
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
601 |
} |
2 | 602 |
XToolkit.awtLock(); |
603 |
try { |
|
604 |
if (!isReparented() || !isVisible()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
605 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
606 |
insLog.fine("- not reparented({0}) or not visible({1}), default reshape", |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
607 |
Boolean.valueOf(isReparented()), Boolean.valueOf(visible)); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
608 |
} |
2 | 609 |
|
610 |
// Fix for 6323293. |
|
611 |
// This actually is needed to preserve compatibility with previous releases - |
|
612 |
// some of licensees are expecting componentMoved event on invisible one while |
|
613 |
// its location changes. |
|
614 |
Point oldLocation = getLocation(); |
|
615 |
||
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
616 |
Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target), |
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
617 |
AWTAccessor.getComponentAccessor().getY(target)); |
2 | 618 |
|
619 |
if (!newLocation.equals(oldLocation)) { |
|
620 |
handleMoved(newDimensions); |
|
621 |
} |
|
622 |
||
623 |
dimensions = new WindowDimensions(newDimensions); |
|
624 |
updateSizeHints(dimensions); |
|
625 |
Rectangle client = dimensions.getClientRect(); |
|
626 |
checkShellRect(client); |
|
627 |
setShellBounds(client); |
|
628 |
if (content != null && |
|
629 |
!content.getSize().equals(newDimensions.getSize())) |
|
630 |
{ |
|
631 |
reconfigureContentWindow(newDimensions); |
|
632 |
} |
|
633 |
return; |
|
634 |
} |
|
635 |
||
636 |
int wm = XWM.getWMID(); |
|
637 |
updateChildrenSizes(); |
|
638 |
applyGuessedInsets(); |
|
639 |
||
640 |
Rectangle shellRect = newDimensions.getClientRect(); |
|
641 |
||
642 |
if (gravityBug()) { |
|
643 |
Insets in = newDimensions.getInsets(); |
|
644 |
shellRect.translate(in.left, in.top); |
|
645 |
} |
|
646 |
||
647 |
if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) { |
|
648 |
shellRect.setLocation(0, 0); |
|
649 |
} |
|
650 |
||
651 |
checkShellRectSize(shellRect); |
|
652 |
if (!isEmbedded()) { |
|
653 |
checkShellRectPos(shellRect); |
|
654 |
} |
|
655 |
||
656 |
op = op & ~NO_EMBEDDED_CHECK; |
|
657 |
||
658 |
if (op == SET_LOCATION) { |
|
659 |
setShellPosition(shellRect); |
|
660 |
} else if (isResizable()) { |
|
661 |
if (op == SET_BOUNDS) { |
|
662 |
setShellBounds(shellRect); |
|
663 |
} else { |
|
664 |
setShellSize(shellRect); |
|
665 |
} |
|
666 |
} else { |
|
667 |
XWM.setShellNotResizable(this, newDimensions, shellRect, true); |
|
668 |
if (op == SET_BOUNDS) { |
|
669 |
setShellPosition(shellRect); |
|
670 |
} |
|
671 |
} |
|
672 |
||
673 |
reconfigureContentWindow(newDimensions); |
|
674 |
} finally { |
|
675 |
XToolkit.awtUnlock(); |
|
676 |
} |
|
677 |
} |
|
678 |
||
679 |
/** |
|
680 |
* @param x, y, width, heith - dimensions of the window with insets |
|
681 |
*/ |
|
682 |
private void reshape(int x, int y, int width, int height, int operation, |
|
683 |
boolean userReshape) |
|
684 |
{ |
|
685 |
Rectangle newRec; |
|
686 |
boolean setClient = false; |
|
687 |
WindowDimensions dims = new WindowDimensions(dimensions); |
|
688 |
switch (operation & (~NO_EMBEDDED_CHECK)) { |
|
689 |
case SET_LOCATION: |
|
690 |
// Set location always sets bounds location. However, until the window is mapped we |
|
691 |
// should use client coordinates |
|
692 |
dims.setLocation(x, y); |
|
693 |
break; |
|
694 |
case SET_SIZE: |
|
695 |
// Set size sets bounds size. However, until the window is mapped we |
|
696 |
// should use client coordinates |
|
697 |
dims.setSize(width, height); |
|
698 |
break; |
|
699 |
case SET_CLIENT_SIZE: { |
|
700 |
// Sets client rect size. Width and height contain insets. |
|
701 |
Insets in = currentInsets; |
|
702 |
width -= in.left+in.right; |
|
703 |
height -= in.top+in.bottom; |
|
704 |
dims.setClientSize(width, height); |
|
705 |
break; |
|
706 |
} |
|
707 |
case SET_BOUNDS: |
|
708 |
default: |
|
709 |
dims.setLocation(x, y); |
|
710 |
dims.setSize(width, height); |
|
711 |
break; |
|
712 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
713 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
714 |
insLog.fine("For the operation {0} new dimensions are {1}", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
715 |
operationToString(operation), dims); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
716 |
} |
2 | 717 |
|
718 |
reshape(dims, operation, userReshape); |
|
719 |
} |
|
720 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
721 |
// This method gets overriden in XFramePeer & XDialogPeer. |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
722 |
abstract boolean isTargetUndecorated(); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
118
diff
changeset
|
723 |
|
2 | 724 |
/** |
725 |
* @see java.awt.peer.ComponentPeer#setBounds |
|
726 |
*/ |
|
727 |
public void setBounds(int x, int y, int width, int height, int op) { |
|
728 |
// TODO: Rewrite with WindowDimensions |
|
729 |
reshape(x, y, width, height, op, true); |
|
730 |
validateSurface(); |
|
731 |
} |
|
732 |
||
733 |
// Coordinates are that of the shell |
|
734 |
void reconfigureContentWindow(WindowDimensions dims) { |
|
735 |
if (content == null) { |
|
736 |
insLog.fine("WARNING: Content window is null"); |
|
737 |
return; |
|
738 |
} |
|
739 |
content.setContentBounds(dims); |
|
740 |
} |
|
741 |
||
742 |
boolean no_reparent_artifacts = false; |
|
743 |
public void handleConfigureNotifyEvent(XEvent xev) { |
|
39862
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
744 |
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) { |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
745 |
return; |
a3fc74a6c5a3
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
39856
diff
changeset
|
746 |
} |
2 | 747 |
assert (SunToolkit.isAWTLockHeldByCurrentThread()); |
748 |
XConfigureEvent xe = xev.get_xconfigure(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
749 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
750 |
insLog.fine("Configure notify {0}", xe); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
751 |
} |
2 | 752 |
|
753 |
// XXX: should really only consider synthetic events, but |
|
754 |
if (isReparented()) { |
|
755 |
configure_seen = true; |
|
756 |
} |
|
757 |
||
758 |
if (!isMaximized() |
|
759 |
&& (xe.get_serial() == reparent_serial || xe.get_window() != getShell()) |
|
760 |
&& !no_reparent_artifacts) |
|
761 |
{ |
|
762 |
insLog.fine("- reparent artifact, skipping"); |
|
763 |
return; |
|
764 |
} |
|
765 |
no_reparent_artifacts = false; |
|
766 |
||
767 |
/** |
|
768 |
* When there is a WM we receive some CN before being visible and after. |
|
769 |
* We should skip all CN which are before being visible, because we assume |
|
770 |
* the gravity is in action while it is not yet. |
|
771 |
* |
|
772 |
* When there is no WM we receive CN only _before_ being visible. |
|
773 |
* We should process these CNs. |
|
774 |
*/ |
|
775 |
if (!isVisible() && XWM.getWMID() != XWM.NO_WM) { |
|
776 |
insLog.fine(" - not visible, skipping"); |
|
777 |
return; |
|
778 |
} |
|
779 |
||
780 |
/* |
|
781 |
* Some window managers configure before we are reparented and |
|
782 |
* the send event flag is set! ugh... (Enlighetenment for one, |
|
783 |
* possibly MWM as well). If we haven't been reparented yet |
|
784 |
* this is just the WM shuffling us into position. Ignore |
|
785 |
* it!!!! or we wind up in a bogus location. |
|
786 |
*/ |
|
787 |
int runningWM = XWM.getWMID(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
788 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
789 |
insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
790 |
isReparented(), isVisible(), runningWM, getDecorations()); |
2 | 791 |
} |
792 |
if (!isReparented() && isVisible() && runningWM != XWM.NO_WM |
|
793 |
&& !XWM.isNonReparentingWM() |
|
115 | 794 |
&& getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
2 | 795 |
insLog.fine("- visible but not reparented, skipping"); |
796 |
return; |
|
797 |
} |
|
798 |
//Last chance to correct insets |
|
115 | 799 |
if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
2 | 800 |
long parent = XlibUtil.getParentWindow(window); |
801 |
Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
802 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 803 |
if (correctWM != null) { |
804 |
insLog.finer("Configure notify - insets : " + correctWM); |
|
805 |
} else { |
|
806 |
insLog.finer("Configure notify - insets are still not available"); |
|
807 |
} |
|
808 |
} |
|
809 |
if (correctWM != null) { |
|
40161
d1621c3f403c
8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents:
39862
diff
changeset
|
810 |
handleCorrectInsets(copyAndScaleDown(correctWM)); |
2 | 811 |
} else { |
812 |
//Only one attempt to correct insets is made (to lower risk) |
|
813 |
//if insets are still not available we simply set the flag |
|
814 |
insets_corrected = true; |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
updateChildrenSizes(); |
|
819 |
||
21786
2f3ad6aa2ac5
8027628: JWindow jumps to (0, 0) after mouse clicked
bagiras
parents:
21591
diff
changeset
|
820 |
Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top); |
2 | 821 |
WindowDimensions newDimensions = |
822 |
new WindowDimensions(newLocation, |
|
34395 | 823 |
new Dimension(scaleDown(xe.get_width()), |
824 |
scaleDown(xe.get_height())), |
|
825 |
copy(currentInsets), true); |
|
2 | 826 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
827 |
if (insLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
828 |
insLog.finer("Insets are {0}, new dimensions {1}", |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
829 |
currentInsets, newDimensions); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
830 |
} |
2 | 831 |
|
832 |
checkIfOnNewScreen(newDimensions.getBounds()); |
|
833 |
||
834 |
Point oldLocation = getLocation(); |
|
835 |
dimensions = newDimensions; |
|
836 |
if (!newLocation.equals(oldLocation)) { |
|
837 |
handleMoved(newDimensions); |
|
838 |
} |
|
839 |
reconfigureContentWindow(newDimensions); |
|
840 |
updateChildrenSizes(); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2466
diff
changeset
|
841 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2466
diff
changeset
|
842 |
repositionSecurityWarning(); |
2 | 843 |
} |
844 |
||
845 |
private void checkShellRectSize(Rectangle shellRect) { |
|
6637
64ecd501905b
6987945: XDecoratedPeer shouldn't allow to resize a frame to zero size
omajid
parents:
5506
diff
changeset
|
846 |
shellRect.width = Math.max(MIN_SIZE, shellRect.width); |
64ecd501905b
6987945: XDecoratedPeer shouldn't allow to resize a frame to zero size
omajid
parents:
5506
diff
changeset
|
847 |
shellRect.height = Math.max(MIN_SIZE, shellRect.height); |
2 | 848 |
} |
849 |
||
850 |
private void checkShellRectPos(Rectangle shellRect) { |
|
851 |
int wm = XWM.getWMID(); |
|
852 |
if (wm == XWM.MOTIF_WM || wm == XWM.CDE_WM) { |
|
853 |
if (shellRect.x == 0 && shellRect.y == 0) { |
|
854 |
shellRect.x = shellRect.y = 1; |
|
855 |
} |
|
856 |
} |
|
857 |
} |
|
858 |
||
859 |
private void checkShellRect(Rectangle shellRect) { |
|
860 |
checkShellRectSize(shellRect); |
|
861 |
checkShellRectPos(shellRect); |
|
862 |
} |
|
863 |
||
864 |
public void setShellBounds(Rectangle rec) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
865 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
866 |
insLog.fine("Setting shell bounds on " + this + " to " + rec); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
867 |
} |
2 | 868 |
XToolkit.awtLock(); |
869 |
try { |
|
870 |
updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
|
33248
76e17c81ec4c
8058959: closed/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java failed automatically
ssadetsky
parents:
32865
diff
changeset
|
871 |
XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(), |
34395 | 872 |
scaleUp(rec.x), scaleUp(rec.y), |
873 |
scaleUp(rec.width), scaleUp(rec.height)); |
|
2 | 874 |
} |
875 |
finally { |
|
876 |
XToolkit.awtUnlock(); |
|
877 |
} |
|
878 |
} |
|
879 |
public void setShellSize(Rectangle rec) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
880 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
881 |
insLog.fine("Setting shell size on " + this + " to " + rec); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
882 |
} |
2 | 883 |
XToolkit.awtLock(); |
884 |
try { |
|
885 |
updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
|
34395 | 886 |
XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), |
887 |
scaleUp(rec.width), scaleUp(rec.height)); |
|
2 | 888 |
} |
889 |
finally { |
|
890 |
XToolkit.awtUnlock(); |
|
891 |
} |
|
892 |
} |
|
893 |
public void setShellPosition(Rectangle rec) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
894 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
895 |
insLog.fine("Setting shell position on " + this + " to " + rec); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
896 |
} |
2 | 897 |
XToolkit.awtLock(); |
898 |
try { |
|
899 |
updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
|
34395 | 900 |
XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), |
901 |
scaleUp(rec.x), scaleUp(rec.y)); |
|
2 | 902 |
} |
903 |
finally { |
|
904 |
XToolkit.awtUnlock(); |
|
905 |
} |
|
906 |
} |
|
907 |
||
908 |
void initResizability() { |
|
909 |
setResizable(winAttr.initialResizability); |
|
910 |
} |
|
911 |
public void setResizable(boolean resizable) { |
|
912 |
int fs = winAttr.functions; |
|
913 |
if (!isResizable() && resizable) { |
|
914 |
resetWMSetInsets(); |
|
915 |
if (!isEmbedded()) { |
|
916 |
setReparented(false); |
|
917 |
} |
|
918 |
winAttr.isResizable = resizable; |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
919 |
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
920 |
fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 921 |
} else { |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
922 |
fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 923 |
} |
924 |
winAttr.functions = fs; |
|
925 |
XWM.setShellResizable(this); |
|
926 |
} else if (isResizable() && !resizable) { |
|
927 |
resetWMSetInsets(); |
|
928 |
if (!isEmbedded()) { |
|
929 |
setReparented(false); |
|
930 |
} |
|
931 |
winAttr.isResizable = resizable; |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
932 |
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
933 |
fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 934 |
} else { |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
935 |
fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); |
2 | 936 |
} |
937 |
winAttr.functions = fs; |
|
118
35b334a806ab
6522731: Location of the frame changes,when the frame is resized & non-resized.
dcherepanov
parents:
115
diff
changeset
|
938 |
XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false); |
2 | 939 |
} |
940 |
} |
|
941 |
||
942 |
Rectangle getShellBounds() { |
|
943 |
return dimensions.getClientRect(); |
|
944 |
} |
|
945 |
||
946 |
public Rectangle getBounds() { |
|
947 |
return dimensions.getBounds(); |
|
948 |
} |
|
949 |
||
950 |
public Dimension getSize() { |
|
951 |
return dimensions.getSize(); |
|
952 |
} |
|
953 |
||
954 |
public int getX() { |
|
955 |
return dimensions.getLocation().x; |
|
956 |
} |
|
957 |
||
958 |
public int getY() { |
|
959 |
return dimensions.getLocation().y; |
|
960 |
} |
|
961 |
||
962 |
public Point getLocation() { |
|
963 |
return dimensions.getLocation(); |
|
964 |
} |
|
965 |
||
966 |
public int getAbsoluteX() { |
|
967 |
// NOTE: returning this peer's location which is shell location |
|
968 |
return dimensions.getScreenBounds().x; |
|
969 |
} |
|
970 |
||
971 |
public int getAbsoluteY() { |
|
972 |
// NOTE: returning this peer's location which is shell location |
|
973 |
return dimensions.getScreenBounds().y; |
|
974 |
} |
|
975 |
||
976 |
public int getWidth() { |
|
977 |
return getSize().width; |
|
978 |
} |
|
979 |
||
980 |
public int getHeight() { |
|
981 |
return getSize().height; |
|
982 |
} |
|
983 |
||
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
30469
diff
changeset
|
984 |
public final WindowDimensions getDimensions() { |
2 | 985 |
return dimensions; |
986 |
} |
|
987 |
||
988 |
public Point getLocationOnScreen() { |
|
989 |
XToolkit.awtLock(); |
|
990 |
try { |
|
991 |
if (configure_seen) { |
|
992 |
return toGlobal(0,0); |
|
993 |
} else { |
|
994 |
Point location = target.getLocation(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
995 |
if (insLog.isLoggable(PlatformLogger.Level.FINE)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
996 |
insLog.fine("getLocationOnScreen {0} not reparented: {1} ", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
997 |
this, location); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
998 |
} |
2 | 999 |
return location; |
1000 |
} |
|
1001 |
} finally { |
|
1002 |
XToolkit.awtUnlock(); |
|
1003 |
} |
|
1004 |
} |
|
1005 |
||
1006 |
||
1007 |
/*************************************************************************************** |
|
1008 |
* END OF I N S E T S C O D E |
|
1009 |
**************************************************************************************/ |
|
1010 |
||
1011 |
protected boolean isEventDisabled(XEvent e) { |
|
1012 |
switch (e.get_type()) { |
|
1013 |
// Do not generate MOVED/RESIZED events since we generate them by ourselves |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
1014 |
case XConstants.ConfigureNotify: |
2 | 1015 |
return true; |
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
1016 |
case XConstants.EnterNotify: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
1017 |
case XConstants.LeaveNotify: |
2 | 1018 |
// Disable crossing event on outer borders of Frame so |
1019 |
// we receive only one set of cross notifications(first set is from content window) |
|
1020 |
return true; |
|
1021 |
default: |
|
1022 |
return super.isEventDisabled(e); |
|
1023 |
} |
|
1024 |
} |
|
1025 |
||
1026 |
int getDecorations() { |
|
1027 |
return winAttr.decorations; |
|
1028 |
} |
|
1029 |
||
1030 |
int getFunctions() { |
|
1031 |
return winAttr.functions; |
|
1032 |
} |
|
1033 |
||
1034 |
public void setVisible(boolean vis) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1035 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1036 |
log.finer("Setting {0} to visible {1}", this, Boolean.valueOf(vis)); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1037 |
} |
2 | 1038 |
if (vis && !isVisible()) { |
1039 |
XWM.setShellDecor(this); |
|
1040 |
super.setVisible(vis); |
|
1041 |
if (winAttr.isResizable) { |
|
1042 |
//Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. |
|
1043 |
//We need to update frame's minimum size, not to reset it |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
420
diff
changeset
|
1044 |
XWM.removeSizeHints(this, XUtilConstants.PMaxSize); |
2 | 1045 |
updateMinimumSize(); |
1046 |
} |
|
1047 |
} else { |
|
1048 |
super.setVisible(vis); |
|
1049 |
} |
|
1050 |
} |
|
1051 |
||
1052 |
protected void suppressWmTakeFocus(boolean doSuppress) { |
|
1053 |
XAtomList protocols = getWMProtocols(); |
|
1054 |
if (doSuppress) { |
|
1055 |
protocols.remove(wm_take_focus); |
|
1056 |
} else { |
|
1057 |
protocols.add(wm_take_focus); |
|
1058 |
} |
|
1059 |
wm_protocols.setAtomListProperty(this, protocols); |
|
1060 |
} |
|
1061 |
||
1062 |
public void dispose() { |
|
1063 |
if (content != null) { |
|
1064 |
content.destroy(); |
|
1065 |
} |
|
1066 |
focusProxy.destroy(); |
|
1067 |
||
1068 |
if (iconWindow != null) { |
|
1069 |
iconWindow.destroy(); |
|
1070 |
} |
|
1071 |
||
1072 |
super.dispose(); |
|
1073 |
} |
|
1074 |
||
1075 |
public void handleClientMessage(XEvent xev) { |
|
1076 |
super.handleClientMessage(xev); |
|
1077 |
XClientMessageEvent cl = xev.get_xclient(); |
|
1078 |
if ((wm_protocols != null) && (cl.get_message_type() == wm_protocols.getAtom())) { |
|
1079 |
if (cl.get_data(0) == wm_delete_window.getAtom()) { |
|
1080 |
handleQuit(); |
|
1081 |
} else if (cl.get_data(0) == wm_take_focus.getAtom()) { |
|
1082 |
handleWmTakeFocus(cl); |
|
1083 |
} |
|
1084 |
} |
|
1085 |
} |
|
1086 |
||
1087 |
private void handleWmTakeFocus(XClientMessageEvent cl) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1088 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1089 |
focusLog.fine("WM_TAKE_FOCUS on {0}", this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1090 |
} |
39856
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1091 |
|
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1092 |
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1093 |
// JDK-8159460 |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1094 |
Window focusedWindow = XKeyboardFocusManagerPeer.getInstance() |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1095 |
.getCurrentFocusedWindow(); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1096 |
Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1097 |
if (activeWindow != target) { |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1098 |
requestWindowFocus(cl.get_data(1), true); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1099 |
} else { |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1100 |
WindowEvent we = new WindowEvent(focusedWindow, |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1101 |
WindowEvent.WINDOW_GAINED_FOCUS); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1102 |
sendEvent(we); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1103 |
} |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1104 |
} else { |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1105 |
requestWindowFocus(cl.get_data(1), true); |
96d7761b869a
8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest
ssadetsky
parents:
34395
diff
changeset
|
1106 |
} |
2 | 1107 |
} |
1108 |
||
1109 |
/** |
|
1110 |
* Requests focus to this decorated top-level by requesting X input focus |
|
1111 |
* to the shell window. |
|
1112 |
*/ |
|
1113 |
protected void requestXFocus(long time, boolean timeProvided) { |
|
1114 |
// We have proxied focus mechanism - instead of shell the focus is held |
|
1115 |
// by "proxy" - invisible mapped window. When we want to set X input focus to |
|
1116 |
// toplevel set it on proxy instead. |
|
1117 |
if (focusProxy == null) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1118 |
if (focusLog.isLoggable(PlatformLogger.Level.WARNING)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1119 |
focusLog.warning("Focus proxy is null for " + this); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1120 |
} |
2 | 1121 |
} else { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1122 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1123 |
focusLog.fine("Requesting focus to proxy: " + focusProxy); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1124 |
} |
2 | 1125 |
if (timeProvided) { |
1126 |
focusProxy.xRequestFocus(time); |
|
1127 |
} else { |
|
1128 |
focusProxy.xRequestFocus(); |
|
1129 |
} |
|
1130 |
} |
|
1131 |
} |
|
1132 |
||
1133 |
XFocusProxyWindow getFocusProxy() { |
|
1134 |
return focusProxy; |
|
1135 |
} |
|
1136 |
||
1137 |
public void handleQuit() { |
|
1138 |
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING)); |
|
1139 |
} |
|
1140 |
||
1141 |
final void dumpMe() { |
|
1142 |
System.err.println(">>> Peer: " + x + ", " + y + ", " + width + ", " + height); |
|
1143 |
} |
|
1144 |
||
1145 |
final void dumpTarget() { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
1146 |
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
1147 |
int getWidth = compAccessor.getWidth(target); |
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
1148 |
int getHeight = compAccessor.getHeight(target); |
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
1149 |
int getTargetX = compAccessor.getX(target); |
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21786
diff
changeset
|
1150 |
int getTargetY = compAccessor.getY(target); |
2 | 1151 |
System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight); |
1152 |
} |
|
1153 |
||
1154 |
final void dumpShell() { |
|
1155 |
dumpWindow("Shell", getShell()); |
|
1156 |
} |
|
1157 |
final void dumpContent() { |
|
1158 |
dumpWindow("Content", getContentWindow()); |
|
1159 |
} |
|
1160 |
final void dumpParent() { |
|
1161 |
long parent = XlibUtil.getParentWindow(getShell()); |
|
1162 |
if (parent != 0) |
|
1163 |
{ |
|
1164 |
dumpWindow("Parent", parent); |
|
1165 |
} |
|
1166 |
else |
|
1167 |
{ |
|
1168 |
System.err.println(">>> NO PARENT"); |
|
1169 |
} |
|
1170 |
} |
|
1171 |
||
1172 |
final void dumpWindow(String id, long window) { |
|
1173 |
XWindowAttributes pattr = new XWindowAttributes(); |
|
1174 |
try { |
|
1175 |
XToolkit.awtLock(); |
|
1176 |
try { |
|
1177 |
int status = |
|
1178 |
XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), |
|
1179 |
window, pattr.pData); |
|
1180 |
} |
|
1181 |
finally { |
|
1182 |
XToolkit.awtUnlock(); |
|
1183 |
} |
|
1184 |
System.err.println(">>>> " + id + ": " + pattr.get_x() |
|
1185 |
+ ", " + pattr.get_y() + ", " + pattr.get_width() |
|
1186 |
+ ", " + pattr.get_height()); |
|
1187 |
} finally { |
|
1188 |
pattr.dispose(); |
|
1189 |
} |
|
1190 |
} |
|
1191 |
||
1192 |
final void dumpAll() { |
|
1193 |
dumpTarget(); |
|
1194 |
dumpMe(); |
|
1195 |
dumpParent(); |
|
1196 |
dumpShell(); |
|
1197 |
dumpContent(); |
|
1198 |
} |
|
1199 |
||
1200 |
boolean isMaximized() { |
|
1201 |
return false; |
|
1202 |
} |
|
1203 |
||
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4214
diff
changeset
|
1204 |
@Override |
2 | 1205 |
boolean isOverrideRedirect() { |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4214
diff
changeset
|
1206 |
return Window.Type.POPUP.equals(getWindowType()); |
2 | 1207 |
} |
1208 |
||
1209 |
public boolean requestWindowFocus(long time, boolean timeProvided) { |
|
1210 |
focusLog.fine("Request for decorated window focus"); |
|
1211 |
// If this is Frame or Dialog we can't assure focus request success - but we still can try |
|
1212 |
// If this is Window and its owner Frame is active we can be sure request succedded. |
|
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
12829
diff
changeset
|
1213 |
Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow(); |
2 | 1214 |
Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); |
1215 |
||
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1216 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1217 |
focusLog.finer("Current window is: active={0}, focused={1}", |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
1218 |
Boolean.valueOf(target == activeWindow), |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2802
diff
changeset
|
1219 |
Boolean.valueOf(target == focusedWindow)); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1220 |
} |
2 | 1221 |
|
1222 |
XWindowPeer toFocus = this; |
|
1223 |
while (toFocus.nextTransientFor != null) { |
|
1224 |
toFocus = toFocus.nextTransientFor; |
|
1225 |
} |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1226 |
if (toFocus == null || !toFocus.focusAllowedFor()) { |
2 | 1227 |
// This might change when WM will have property to determine focus policy. |
1228 |
// Right now, because policy is unknown we can't be sure we succedded |
|
1229 |
return false; |
|
1230 |
} |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1231 |
if (this == toFocus) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1232 |
if (isWMStateNetHidden()) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1233 |
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
|
1234 |
return false; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1235 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1236 |
if (target == activeWindow && target != focusedWindow) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1237 |
// Happens when an owned window is currently focused |
21591 | 1238 |
focusLog.fine("Focus is on child window - transferring it back to the owner"); |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1239 |
handleWindowFocusInSync(-1); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1240 |
return true; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1241 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1242 |
Window realNativeFocusedWindow = XWindowPeer.getNativeFocusedWindow(); |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1243 |
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1244 |
focusLog.finest("Real native focused window: " + realNativeFocusedWindow + |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1245 |
"\nKFM's focused window: " + focusedWindow); |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1246 |
} |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1247 |
|
16842
78641211dbbc
7147075: JTextField doesn't get focus or loses focus forever
ant
parents:
16839
diff
changeset
|
1248 |
// A workaround for Metacity. See 6522725, 6613426, 7147075. |
78641211dbbc
7147075: JTextField doesn't get focus or loses focus forever
ant
parents:
16839
diff
changeset
|
1249 |
if (target == realNativeFocusedWindow && XWM.getWMID() == XWM.METACITY_WM) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1250 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1251 |
focusLog.fine("The window is already natively focused."); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1252 |
} |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1253 |
return true; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1254 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1255 |
} |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16842
diff
changeset
|
1256 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1257 |
focusLog.fine("Requesting focus to " + (this == toFocus ? "this window" : toFocus)); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13648
diff
changeset
|
1258 |
} |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1259 |
|
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1260 |
if (timeProvided) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1261 |
toFocus.requestXFocus(time); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1262 |
} else { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1263 |
toFocus.requestXFocus(); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1264 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
1265 |
return (this == toFocus); |
2 | 1266 |
} |
1267 |
||
1268 |
XWindowPeer actualFocusedWindow = null; |
|
1269 |
void setActualFocusedWindow(XWindowPeer actualFocusedWindow) { |
|
1270 |
synchronized(getStateLock()) { |
|
1271 |
this.actualFocusedWindow = actualFocusedWindow; |
|
1272 |
} |
|
1273 |
} |
|
1274 |
||
1275 |
boolean requestWindowFocus(XWindowPeer actualFocusedWindow, |
|
1276 |
long time, boolean timeProvided) |
|
1277 |
{ |
|
1278 |
setActualFocusedWindow(actualFocusedWindow); |
|
1279 |
return requestWindowFocus(time, timeProvided); |
|
1280 |
} |
|
1281 |
public void handleWindowFocusIn(long serial) { |
|
1282 |
if (null == actualFocusedWindow) { |
|
1283 |
super.handleWindowFocusIn(serial); |
|
1284 |
} else { |
|
1285 |
/* |
|
1286 |
* Fix for 6314575. |
|
1287 |
* If this is a result of clicking on one of the Frame's component |
|
1288 |
* then 'actualFocusedWindow' shouldn't be focused. A decision of focusing |
|
1289 |
* it or not should be made after the appropriate Java mouse event (if any) |
|
1290 |
* is handled by the component where 'actualFocusedWindow' value may be reset. |
|
1291 |
* |
|
1292 |
* The fix is based on the empiric fact consisting in that the component |
|
1293 |
* receives native mouse event nearly at the same time the Frame receives |
|
1294 |
* WM_TAKE_FOCUS (when FocusIn is generated via XSetInputFocus call) but |
|
1295 |
* definetely before the Frame gets FocusIn event (when this method is called). |
|
1296 |
*/ |
|
1297 |
postEvent(new InvocationEvent(target, new Runnable() { |
|
1298 |
public void run() { |
|
1299 |
XWindowPeer fw = null; |
|
1300 |
synchronized (getStateLock()) { |
|
1301 |
fw = actualFocusedWindow; |
|
1302 |
actualFocusedWindow = null; |
|
1303 |
if (null == fw || !fw.isVisible() || !fw.isFocusableWindow()) { |
|
1304 |
fw = XDecoratedPeer.this; |
|
1305 |
} |
|
1306 |
} |
|
1307 |
fw.handleWindowFocusIn_Dispatch(); |
|
1308 |
} |
|
1309 |
})); |
|
1310 |
} |
|
1311 |
} |
|
1312 |
||
1313 |
public void handleWindowFocusOut(Window oppositeWindow, long serial) { |
|
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
12829
diff
changeset
|
1314 |
Window actualFocusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow(); |
2 | 1315 |
|
1316 |
// If the actual focused window is not this decorated window then retain it. |
|
1317 |
if (actualFocusedWindow != null && actualFocusedWindow != target) { |
|
1318 |
Window owner = XWindowPeer.getDecoratedOwner(actualFocusedWindow); |
|
1319 |
||
1320 |
if (owner != null && owner == target) { |
|
30469 | 1321 |
setActualFocusedWindow(AWTAccessor.getComponentAccessor().getPeer(actualFocusedWindow)); |
2 | 1322 |
} |
1323 |
} |
|
1324 |
super.handleWindowFocusOut(oppositeWindow, serial); |
|
1325 |
} |
|
1326 |
} |