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