author | lana |
Tue, 02 Nov 2010 22:15:35 -0700 | |
changeset 7146 | d0163a4e4e75 |
parent 6828 | 3999af3d33de |
parent 6996 | 5122ee0dcc92 |
child 7668 | d4a77089c587 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1996, 2009, 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.windows; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.event.*; |
|
29 |
import java.awt.image.*; |
|
30 |
import java.awt.peer.*; |
|
31 |
||
32 |
import java.beans.*; |
|
33 |
||
34 |
import java.lang.reflect.*; |
|
35 |
||
36 |
import java.util.*; |
|
37 |
import java.util.List; |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
38 |
import sun.util.logging.PlatformLogger; |
2 | 39 |
|
40 |
import sun.awt.*; |
|
2451 | 41 |
|
42 |
import sun.java2d.pipe.Region; |
|
2 | 43 |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
44 |
public class WWindowPeer extends WPanelPeer implements WindowPeer, |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
45 |
DisplayChangedListener |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
46 |
{ |
2 | 47 |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
48 |
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
49 |
private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer"); |
2 | 50 |
|
51 |
// we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that |
|
52 |
// extends WWindowPeer, not WDialogPeer |
|
53 |
private WWindowPeer modalBlocker = null; |
|
54 |
||
2451 | 55 |
private boolean isOpaque; |
56 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
57 |
private TranslucentWindowPainter painter; |
2451 | 58 |
|
2 | 59 |
/* |
60 |
* A key used for storing a list of active windows in AppContext. The value |
|
61 |
* is a list of windows, sorted by the time of activation: later a window is |
|
62 |
* activated, greater its index is in the list. |
|
63 |
*/ |
|
64 |
private final static StringBuffer ACTIVE_WINDOWS_KEY = |
|
65 |
new StringBuffer("active_windows_list"); |
|
66 |
||
67 |
/* |
|
68 |
* Listener for 'activeWindow' KFM property changes. It is added to each |
|
69 |
* AppContext KFM. See ActiveWindowListener inner class below. |
|
70 |
*/ |
|
71 |
private static PropertyChangeListener activeWindowListener = |
|
72 |
new ActiveWindowListener(); |
|
73 |
||
74 |
/* |
|
75 |
* The object is a listener for the AppContext.GUI_DISPOSED property. |
|
76 |
*/ |
|
77 |
private final static PropertyChangeListener guiDisposedListener = |
|
78 |
new GuiDisposedListener(); |
|
79 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
80 |
/* |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
81 |
* Called (on the Toolkit thread) before the appropriate |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
82 |
* WindowStateEvent is posted to the EventQueue. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
83 |
*/ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
84 |
private WindowListener windowListener; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
85 |
|
2 | 86 |
/** |
87 |
* Initialize JNI field IDs |
|
88 |
*/ |
|
89 |
private static native void initIDs(); |
|
90 |
static { |
|
91 |
initIDs(); |
|
92 |
} |
|
93 |
||
94 |
// WComponentPeer overrides |
|
95 |
||
96 |
protected void disposeImpl() { |
|
97 |
AppContext appContext = SunToolkit.targetToAppContext(target); |
|
98 |
synchronized (appContext) { |
|
99 |
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); |
|
100 |
if (l != null) { |
|
101 |
l.remove(this); |
|
102 |
} |
|
103 |
} |
|
2451 | 104 |
|
2 | 105 |
// Remove ourself from the Map of DisplayChangeListeners |
106 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
107 |
((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this); |
|
2451 | 108 |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
109 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
110 |
TranslucentWindowPainter currentPainter = painter; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
111 |
if (currentPainter != null) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
112 |
currentPainter.flush(); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
113 |
// don't set the current one to null here; reduces the chances of |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
114 |
// MT issues (like NPEs) |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
115 |
} |
2451 | 116 |
} |
117 |
||
2 | 118 |
super.disposeImpl(); |
119 |
} |
|
120 |
||
121 |
// WindowPeer implementation |
|
122 |
||
123 |
public void toFront() { |
|
124 |
updateFocusableWindowState(); |
|
125 |
_toFront(); |
|
126 |
} |
|
127 |
native void _toFront(); |
|
128 |
public native void toBack(); |
|
129 |
||
130 |
public native void setAlwaysOnTopNative(boolean value); |
|
131 |
public void setAlwaysOnTop(boolean value) { |
|
132 |
if ((value && ((Window)target).isVisible()) || !value) { |
|
133 |
setAlwaysOnTopNative(value); |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
public void updateFocusableWindowState() { |
|
138 |
setFocusableWindow(((Window)target).isFocusableWindow()); |
|
139 |
} |
|
140 |
native void setFocusableWindow(boolean value); |
|
141 |
||
142 |
// FramePeer & DialogPeer partial shared implementation |
|
143 |
||
144 |
public void setTitle(String title) { |
|
145 |
// allow a null title to pass as an empty string. |
|
146 |
if (title == null) { |
|
438
2ae294e4518c
6613529: Avoid duplicate object creation within JDK packages
dav
parents:
129
diff
changeset
|
147 |
title = ""; |
2 | 148 |
} |
149 |
_setTitle(title); |
|
150 |
} |
|
151 |
native void _setTitle(String title); |
|
152 |
||
153 |
public void setResizable(boolean resizable) { |
|
154 |
_setResizable(resizable); |
|
155 |
} |
|
156 |
public native void _setResizable(boolean resizable); |
|
157 |
||
158 |
// Toolkit & peer internals |
|
159 |
||
160 |
WWindowPeer(Window target) { |
|
161 |
super(target); |
|
162 |
} |
|
163 |
||
164 |
void initialize() { |
|
165 |
super.initialize(); |
|
166 |
||
167 |
updateInsets(insets_); |
|
168 |
||
169 |
Font f = ((Window)target).getFont(); |
|
170 |
if (f == null) { |
|
171 |
f = defaultFont; |
|
172 |
((Window)target).setFont(f); |
|
173 |
setFont(f); |
|
174 |
} |
|
175 |
// Express our interest in display changes |
|
176 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
177 |
((Win32GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); |
|
178 |
||
179 |
initActiveWindowsTracking((Window)target); |
|
180 |
||
181 |
updateIconImages(); |
|
2451 | 182 |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
183 |
Shape shape = ((Window)target).getShape(); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
184 |
if (shape != null) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
185 |
applyShape(Region.getInstance(shape, null)); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
186 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
187 |
|
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
188 |
float opacity = ((Window)target).getOpacity(); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
189 |
if (opacity < 1.0f) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
190 |
setOpacity(opacity); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
191 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
192 |
|
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
193 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
194 |
// default value of a boolean field is 'false', so set isOpaque to |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
195 |
// true here explicitly |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
196 |
this.isOpaque = true; |
3237 | 197 |
setOpaque(((Window)target).isOpaque()); |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
198 |
} |
2 | 199 |
} |
200 |
||
201 |
native void createAwtWindow(WComponentPeer parent); |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
202 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
203 |
private volatile Window.Type windowType = Window.Type.NORMAL; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
204 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
205 |
// This method must be called for Window, Dialog, and Frame before creating |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
206 |
// the hwnd |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
207 |
void preCreate(WComponentPeer parent) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
208 |
windowType = ((Window)target).getType(); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
209 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
210 |
|
2 | 211 |
void create(WComponentPeer parent) { |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4259
diff
changeset
|
212 |
preCreate(parent); |
2 | 213 |
createAwtWindow(parent); |
214 |
} |
|
215 |
||
216 |
// should be overriden in WDialogPeer |
|
217 |
protected void realShow() { |
|
218 |
super.show(); |
|
219 |
} |
|
220 |
||
221 |
public void show() { |
|
222 |
updateFocusableWindowState(); |
|
223 |
||
224 |
boolean alwaysOnTop = ((Window)target).isAlwaysOnTop(); |
|
225 |
||
226 |
// Fix for 4868278. |
|
227 |
// If we create a window with a specific GraphicsConfig, and then move it with |
|
228 |
// setLocation() or setBounds() to another one before its peer has been created, |
|
229 |
// then calling Window.getGraphicsConfig() returns wrong config. That may lead |
|
230 |
// to some problems like wrong-placed tooltips. It is caused by calling |
|
231 |
// super.displayChanged() in WWindowPeer.displayChanged() regardless of whether |
|
232 |
// GraphicsDevice was really changed, or not. So we need to track it here. |
|
233 |
updateGC(); |
|
234 |
||
235 |
realShow(); |
|
236 |
updateMinimumSize(); |
|
237 |
||
238 |
if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) { |
|
239 |
setAlwaysOnTop(alwaysOnTop); |
|
240 |
} |
|
2451 | 241 |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
242 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
243 |
if (!isOpaque) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
244 |
updateWindow(true); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
245 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
246 |
} |
2 | 247 |
} |
248 |
||
249 |
// Synchronize the insets members (here & in helper) with actual window |
|
250 |
// state. |
|
251 |
native void updateInsets(Insets i); |
|
252 |
||
253 |
static native int getSysMinWidth(); |
|
254 |
static native int getSysMinHeight(); |
|
255 |
static native int getSysIconWidth(); |
|
256 |
static native int getSysIconHeight(); |
|
257 |
static native int getSysSmIconWidth(); |
|
258 |
static native int getSysSmIconHeight(); |
|
259 |
/**windows/classes/sun/awt/windows/ |
|
260 |
* Creates native icon from specified raster data and updates |
|
261 |
* icon for window and all descendant windows that inherit icon. |
|
262 |
* Raster data should be passed in the ARGB form. |
|
263 |
* Note that raster data format was changed to provide support |
|
264 |
* for XP icons with alpha-channel |
|
265 |
*/ |
|
266 |
native void setIconImagesData(int[] iconRaster, int w, int h, |
|
267 |
int[] smallIconRaster, int smw, int smh); |
|
268 |
||
269 |
synchronized native void reshapeFrame(int x, int y, int width, int height); |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
270 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
271 |
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
272 |
if (!focusAllowedFor()) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
273 |
return false; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
274 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
275 |
return requestWindowFocus(cause == CausedFocusEvent.Cause.MOUSE_EVENT); |
2 | 276 |
} |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
277 |
public native boolean requestWindowFocus(boolean isMouseEventCause); |
2 | 278 |
|
279 |
public boolean focusAllowedFor() { |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
280 |
Window window = (Window)this.target; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
281 |
if (!window.isVisible() || |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
282 |
!window.isEnabled() || |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
283 |
!window.isFocusableWindow()) |
2 | 284 |
{ |
285 |
return false; |
|
286 |
} |
|
287 |
if (isModalBlocked()) { |
|
288 |
return false; |
|
289 |
} |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
290 |
return true; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
291 |
} |
2 | 292 |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
293 |
public void hide() { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
294 |
WindowListener listener = windowListener; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
295 |
if (listener != null) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
296 |
// We're not getting WINDOW_CLOSING from the native code when hiding |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
297 |
// the window programmatically. So, create it and notify the listener. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
298 |
listener.windowClosing(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING)); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
299 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
300 |
super.hide(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
301 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
302 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
303 |
// WARNING: it's called on the Toolkit thread! |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
304 |
void preprocessPostEvent(AWTEvent event) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
305 |
if (event instanceof WindowEvent) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
306 |
WindowListener listener = windowListener; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
307 |
if (listener != null) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
308 |
switch(event.getID()) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
309 |
case WindowEvent.WINDOW_CLOSING: |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
310 |
listener.windowClosing((WindowEvent)event); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
311 |
break; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
312 |
case WindowEvent.WINDOW_ICONIFIED: |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
313 |
listener.windowIconified((WindowEvent)event); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
314 |
break; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
315 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
316 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
317 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
318 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
319 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
320 |
synchronized void addWindowListener(WindowListener l) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
321 |
windowListener = AWTEventMulticaster.add(windowListener, l); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
322 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
323 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
324 |
synchronized void removeWindowListener(WindowListener l) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2459
diff
changeset
|
325 |
windowListener = AWTEventMulticaster.remove(windowListener, l); |
2 | 326 |
} |
327 |
||
328 |
public void updateMinimumSize() { |
|
329 |
Dimension minimumSize = null; |
|
330 |
if (((Component)target).isMinimumSizeSet()) { |
|
331 |
minimumSize = ((Component)target).getMinimumSize(); |
|
332 |
} |
|
333 |
if (minimumSize != null) { |
|
334 |
int msw = getSysMinWidth(); |
|
335 |
int msh = getSysMinHeight(); |
|
336 |
int w = (minimumSize.width >= msw) ? minimumSize.width : msw; |
|
337 |
int h = (minimumSize.height >= msh) ? minimumSize.height : msh; |
|
338 |
setMinSize(w, h); |
|
339 |
} else { |
|
340 |
setMinSize(0, 0); |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
public void updateIconImages() { |
|
345 |
java.util.List<Image> imageList = ((Window)target).getIconImages(); |
|
346 |
if (imageList == null || imageList.size() == 0) { |
|
347 |
setIconImagesData(null, 0, 0, null, 0, 0); |
|
348 |
} else { |
|
349 |
int w = getSysIconWidth(); |
|
350 |
int h = getSysIconHeight(); |
|
351 |
int smw = getSysSmIconWidth(); |
|
352 |
int smh = getSysSmIconHeight(); |
|
353 |
DataBufferInt iconData = SunToolkit.getScaledIconData(imageList, |
|
354 |
w, h); |
|
355 |
DataBufferInt iconSmData = SunToolkit.getScaledIconData(imageList, |
|
356 |
smw, smh); |
|
357 |
if (iconData != null && iconSmData != null) { |
|
358 |
setIconImagesData(iconData.getData(), w, h, |
|
359 |
iconSmData.getData(), smw, smh); |
|
360 |
} else { |
|
361 |
setIconImagesData(null, 0, 0, null, 0, 0); |
|
362 |
} |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
native void setMinSize(int width, int height); |
|
367 |
||
368 |
/* |
|
369 |
* ---- MODALITY SUPPORT ---- |
|
370 |
*/ |
|
371 |
||
372 |
/** |
|
373 |
* Some modality-related code here because WFileDialogPeer, WPrintDialogPeer and |
|
374 |
* WPageDialogPeer are descendants of WWindowPeer, not WDialogPeer |
|
375 |
*/ |
|
376 |
||
377 |
public boolean isModalBlocked() { |
|
378 |
return modalBlocker != null; |
|
379 |
} |
|
380 |
||
381 |
public void setModalBlocked(Dialog dialog, boolean blocked) { |
|
382 |
synchronized (((Component)getTarget()).getTreeLock()) // State lock should always be after awtLock |
|
383 |
{ |
|
384 |
// use WWindowPeer instead of WDialogPeer because of FileDialogs and PrintDialogs |
|
385 |
WWindowPeer blockerPeer = (WWindowPeer)dialog.getPeer(); |
|
386 |
if (blocked) |
|
387 |
{ |
|
388 |
modalBlocker = blockerPeer; |
|
389 |
// handle native dialogs separately, as they may have not |
|
390 |
// got HWND yet; modalEnable/modalDisable is called from |
|
391 |
// their setHWnd() methods |
|
392 |
if (blockerPeer instanceof WFileDialogPeer) { |
|
393 |
((WFileDialogPeer)blockerPeer).blockWindow(this); |
|
394 |
} else if (blockerPeer instanceof WPrintDialogPeer) { |
|
395 |
((WPrintDialogPeer)blockerPeer).blockWindow(this); |
|
396 |
} else { |
|
397 |
modalDisable(dialog, blockerPeer.getHWnd()); |
|
398 |
} |
|
399 |
} else { |
|
400 |
modalBlocker = null; |
|
401 |
if (blockerPeer instanceof WFileDialogPeer) { |
|
402 |
((WFileDialogPeer)blockerPeer).unblockWindow(this); |
|
403 |
} else if (blockerPeer instanceof WPrintDialogPeer) { |
|
404 |
((WPrintDialogPeer)blockerPeer).unblockWindow(this); |
|
405 |
} else { |
|
406 |
modalEnable(dialog); |
|
407 |
} |
|
408 |
} |
|
409 |
} |
|
410 |
} |
|
411 |
||
412 |
native void modalDisable(Dialog blocker, long blockerHWnd); |
|
413 |
native void modalEnable(Dialog blocker); |
|
414 |
||
415 |
/* |
|
416 |
* Returns all the ever active windows from the current AppContext. |
|
417 |
* The list is sorted by the time of activation, so the latest |
|
418 |
* active window is always at the end. |
|
419 |
*/ |
|
420 |
public static long[] getActiveWindowHandles() { |
|
421 |
AppContext appContext = AppContext.getAppContext(); |
|
422 |
synchronized (appContext) { |
|
423 |
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); |
|
424 |
if (l == null) { |
|
425 |
return null; |
|
426 |
} |
|
427 |
long[] result = new long[l.size()]; |
|
428 |
for (int j = 0; j < l.size(); j++) { |
|
429 |
result[j] = l.get(j).getHWnd(); |
|
430 |
} |
|
431 |
return result; |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
/* |
|
436 |
* ----DISPLAY CHANGE SUPPORT---- |
|
437 |
*/ |
|
438 |
||
439 |
/* |
|
440 |
* Called from native code when we have been dragged onto another screen. |
|
441 |
*/ |
|
442 |
void draggedToNewScreen() { |
|
443 |
SunToolkit.executeOnEventHandlerThread((Component)target,new Runnable() |
|
444 |
{ |
|
445 |
public void run() { |
|
446 |
displayChanged(); |
|
447 |
} |
|
448 |
}); |
|
449 |
} |
|
450 |
||
451 |
public void updateGC() { |
|
452 |
int scrn = getScreenImOn(); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
453 |
if (screenLog.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
454 |
log.finer("Screen number: " + scrn); |
2 | 455 |
} |
456 |
||
457 |
// get current GD |
|
458 |
Win32GraphicsDevice oldDev = (Win32GraphicsDevice)winGraphicsConfig |
|
459 |
.getDevice(); |
|
460 |
||
461 |
Win32GraphicsDevice newDev; |
|
462 |
GraphicsDevice devs[] = GraphicsEnvironment |
|
463 |
.getLocalGraphicsEnvironment() |
|
464 |
.getScreenDevices(); |
|
465 |
// Occasionally during device addition/removal getScreenImOn can return |
|
466 |
// a non-existing screen number. Use the default device in this case. |
|
467 |
if (scrn >= devs.length) { |
|
468 |
newDev = (Win32GraphicsDevice)GraphicsEnvironment |
|
469 |
.getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
|
470 |
} else { |
|
471 |
newDev = (Win32GraphicsDevice)devs[scrn]; |
|
472 |
} |
|
473 |
||
474 |
// Set winGraphicsConfig to the default GC for the monitor this Window |
|
475 |
// is now mostly on. |
|
476 |
winGraphicsConfig = (Win32GraphicsConfig)newDev |
|
477 |
.getDefaultConfiguration(); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
478 |
if (screenLog.isLoggable(PlatformLogger.FINE)) { |
2 | 479 |
if (winGraphicsConfig == null) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
480 |
screenLog.fine("Assertion (winGraphicsConfig != null) failed"); |
2 | 481 |
} |
482 |
} |
|
483 |
||
484 |
// if on a different display, take off old GD and put on new GD |
|
485 |
if (oldDev != newDev) { |
|
486 |
oldDev.removeDisplayChangedListener(this); |
|
487 |
newDev.addDisplayChangedListener(this); |
|
488 |
} |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
489 |
|
6828
3999af3d33de
6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
6645
diff
changeset
|
490 |
AWTAccessor.getComponentAccessor(). |
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
491 |
setGraphicsConfiguration((Component)target, winGraphicsConfig); |
2 | 492 |
} |
493 |
||
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
494 |
/** |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
495 |
* From the DisplayChangedListener interface. |
2 | 496 |
* |
497 |
* This method handles a display change - either when the display settings |
|
498 |
* are changed, or when the window has been dragged onto a different |
|
499 |
* display. |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
500 |
* Called after a change in the display mode. This event |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
501 |
* triggers replacing the surfaceData object (since that object |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
502 |
* reflects the current display depth information, which has |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
503 |
* just changed). |
2 | 504 |
*/ |
505 |
public void displayChanged() { |
|
506 |
updateGC(); |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
507 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
508 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
509 |
/** |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
510 |
* Part of the DisplayChangedListener interface: components |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
511 |
* do not need to react to this event |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
512 |
*/ |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2451
diff
changeset
|
513 |
public void paletteChanged() { |
2 | 514 |
} |
515 |
||
516 |
private native int getScreenImOn(); |
|
517 |
||
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3237
diff
changeset
|
518 |
// Used in Win32GraphicsDevice. |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3237
diff
changeset
|
519 |
public final native void setFullScreenExclusiveModeState(boolean state); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3237
diff
changeset
|
520 |
|
2 | 521 |
/* |
522 |
* ----END DISPLAY CHANGE SUPPORT---- |
|
523 |
*/ |
|
524 |
||
525 |
public void grab() { |
|
526 |
nativeGrab(); |
|
527 |
} |
|
528 |
||
529 |
public void ungrab() { |
|
530 |
nativeUngrab(); |
|
531 |
} |
|
532 |
private native void nativeGrab(); |
|
533 |
private native void nativeUngrab(); |
|
534 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
535 |
private final boolean hasWarningWindow() { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
536 |
return ((Window)target).getWarningString() != null; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
537 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
538 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
539 |
boolean isTargetUndecorated() { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
540 |
return true; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
541 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
542 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
543 |
// These are the peer bounds. They get updated at: |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
544 |
// 1. the WWindowPeer.setBounds() method. |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
545 |
// 2. the native code (on WM_SIZE/WM_MOVE) |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
546 |
private volatile int sysX = 0; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
547 |
private volatile int sysY = 0; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
548 |
private volatile int sysW = 0; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
549 |
private volatile int sysH = 0; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
550 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
551 |
public native void repositionSecurityWarning(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
552 |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
553 |
@Override |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
554 |
public void setBounds(int x, int y, int width, int height, int op) { |
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
555 |
sysX = x; |
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
556 |
sysY = y; |
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
557 |
sysW = width; |
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
558 |
sysH = height; |
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
559 |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
2472
diff
changeset
|
560 |
super.setBounds(x, y, width, height, op); |
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
561 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
562 |
|
2451 | 563 |
@Override |
564 |
public void print(Graphics g) { |
|
565 |
// We assume we print the whole frame, |
|
566 |
// so we expect no clip was set previously |
|
567 |
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target); |
|
568 |
if (shape != null) { |
|
569 |
g.setClip(shape); |
|
570 |
} |
|
571 |
super.print(g); |
|
572 |
} |
|
573 |
||
574 |
private void replaceSurfaceDataRecursively(Component c) { |
|
575 |
if (c instanceof Container) { |
|
576 |
for (Component child : ((Container)c).getComponents()) { |
|
577 |
replaceSurfaceDataRecursively(child); |
|
578 |
} |
|
579 |
} |
|
580 |
ComponentPeer cp = c.getPeer(); |
|
581 |
if (cp instanceof WComponentPeer) { |
|
582 |
((WComponentPeer)cp).replaceSurfaceDataLater(); |
|
583 |
} |
|
584 |
} |
|
585 |
||
4258
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
586 |
public final Graphics getTranslucentGraphics() { |
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
587 |
synchronized (getStateLock()) { |
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
588 |
return isOpaque ? null : painter.getBackBuffer(false).getGraphics(); |
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
589 |
} |
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
590 |
} |
50b23b28d857
6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents:
4256
diff
changeset
|
591 |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
592 |
@Override |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
593 |
public void setBackground(Color c) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
594 |
super.setBackground(c); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
595 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
596 |
if (!isOpaque && ((Window)target).isVisible()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
597 |
updateWindow(true); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
598 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
599 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
600 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
601 |
|
2451 | 602 |
private native void setOpacity(int iOpacity); |
6996 | 603 |
private float opacity = 1.0f; |
2451 | 604 |
|
605 |
public void setOpacity(float opacity) { |
|
606 |
if (!((SunToolkit)((Window)target).getToolkit()). |
|
607 |
isWindowOpacitySupported()) |
|
608 |
{ |
|
609 |
return; |
|
610 |
} |
|
611 |
||
6996 | 612 |
if (opacity < 0.0f || opacity > 1.0f) { |
613 |
throw new IllegalArgumentException( |
|
614 |
"The value of opacity should be in the range [0.0f .. 1.0f]."); |
|
615 |
} |
|
616 |
||
617 |
if (((this.opacity == 1.0f && opacity < 1.0f) || |
|
618 |
(this.opacity < 1.0f && opacity == 1.0f)) && |
|
619 |
!Win32GraphicsEnvironment.isVistaOS()) |
|
620 |
{ |
|
621 |
// non-Vista OS: only replace the surface data if opacity status |
|
622 |
// changed (see WComponentPeer.isAccelCapable() for more) |
|
623 |
replaceSurfaceDataRecursively((Component)getTarget()); |
|
624 |
} |
|
625 |
||
626 |
this.opacity = opacity; |
|
2451 | 627 |
|
628 |
final int maxOpacity = 0xff; |
|
629 |
int iOpacity = (int)(opacity * maxOpacity); |
|
630 |
if (iOpacity < 0) { |
|
631 |
iOpacity = 0; |
|
632 |
} |
|
633 |
if (iOpacity > maxOpacity) { |
|
634 |
iOpacity = maxOpacity; |
|
635 |
} |
|
636 |
||
637 |
setOpacity(iOpacity); |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
638 |
|
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
639 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
640 |
if (!isOpaque && ((Window)target).isVisible()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
641 |
updateWindow(true); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
642 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
643 |
} |
2451 | 644 |
} |
645 |
||
646 |
private native void setOpaqueImpl(boolean isOpaque); |
|
647 |
||
648 |
public void setOpaque(boolean isOpaque) { |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
649 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
650 |
if (this.isOpaque == isOpaque) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
651 |
return; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
652 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
653 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
654 |
|
2451 | 655 |
Window target = (Window)getTarget(); |
656 |
||
2648 | 657 |
if (!isOpaque) { |
658 |
SunToolkit sunToolkit = (SunToolkit)target.getToolkit(); |
|
659 |
if (!sunToolkit.isWindowTranslucencySupported() || |
|
660 |
!sunToolkit.isTranslucencyCapable(target.getGraphicsConfiguration())) |
|
661 |
{ |
|
662 |
return; |
|
663 |
} |
|
2451 | 664 |
} |
665 |
||
666 |
boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS(); |
|
667 |
||
6996 | 668 |
if (this.isOpaque != isOpaque && !isVistaOS) { |
2451 | 669 |
// non-Vista OS: only replace the surface data if the opacity |
670 |
// status changed (see WComponentPeer.isAccelCapable() for more) |
|
671 |
replaceSurfaceDataRecursively(target); |
|
672 |
} |
|
673 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
674 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
675 |
this.isOpaque = isOpaque; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
676 |
setOpaqueImpl(isOpaque); |
2451 | 677 |
if (isOpaque) { |
678 |
TranslucentWindowPainter currentPainter = painter; |
|
679 |
if (currentPainter != null) { |
|
680 |
currentPainter.flush(); |
|
681 |
painter = null; |
|
682 |
} |
|
683 |
} else { |
|
684 |
painter = TranslucentWindowPainter.createInstance(this); |
|
685 |
} |
|
686 |
} |
|
687 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
688 |
if (isVistaOS) { |
2451 | 689 |
// On Vista: setting the window non-opaque makes the window look |
690 |
// rectangular, though still catching the mouse clicks within |
|
691 |
// its shape only. To restore the correct visual appearance |
|
692 |
// of the window (i.e. w/ the correct shape) we have to reset |
|
693 |
// the shape. |
|
2648 | 694 |
Shape shape = ((Window)target).getShape(); |
2451 | 695 |
if (shape != null) { |
2648 | 696 |
((Window)target).setShape(shape); |
2451 | 697 |
} |
698 |
} |
|
699 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
700 |
if (((Window)target).isVisible()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
701 |
updateWindow(true); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
702 |
} |
2451 | 703 |
} |
704 |
||
705 |
public native void updateWindowImpl(int[] data, int width, int height); |
|
706 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
707 |
public void updateWindow() { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
708 |
updateWindow(false); |
2451 | 709 |
} |
710 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
711 |
private void updateWindow(boolean repaint) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
712 |
Window w = (Window)target; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
713 |
synchronized (getStateLock()) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
714 |
if (isOpaque || !w.isVisible() || |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
715 |
(w.getWidth() <= 0) || (w.getHeight() <= 0)) |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
716 |
{ |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
717 |
return; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
718 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
719 |
TranslucentWindowPainter currentPainter = painter; |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
720 |
if (currentPainter != null) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
721 |
currentPainter.updateWindow(repaint); |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
722 |
} else if (log.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
723 |
log.finer("Translucent window painter is null in updateWindow"); |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
724 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
725 |
} |
2451 | 726 |
} |
727 |
||
2 | 728 |
/* |
729 |
* The method maps the list of the active windows to the window's AppContext, |
|
730 |
* then the method registers ActiveWindowListener, GuiDisposedListener listeners; |
|
731 |
* it executes the initilialization only once per AppContext. |
|
732 |
*/ |
|
733 |
private static void initActiveWindowsTracking(Window w) { |
|
734 |
AppContext appContext = AppContext.getAppContext(); |
|
735 |
synchronized (appContext) { |
|
736 |
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); |
|
737 |
if (l == null) { |
|
738 |
l = new LinkedList<WWindowPeer>(); |
|
739 |
appContext.put(ACTIVE_WINDOWS_KEY, l); |
|
740 |
appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener); |
|
741 |
||
742 |
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); |
|
743 |
kfm.addPropertyChangeListener("activeWindow", activeWindowListener); |
|
744 |
} |
|
745 |
} |
|
746 |
} |
|
747 |
||
748 |
/* |
|
749 |
* The GuiDisposedListener class listens for the AppContext.GUI_DISPOSED property, |
|
750 |
* it removes the list of the active windows from the disposed AppContext and |
|
751 |
* unregisters ActiveWindowListener listener. |
|
752 |
*/ |
|
753 |
private static class GuiDisposedListener implements PropertyChangeListener { |
|
754 |
public void propertyChange(PropertyChangeEvent e) { |
|
755 |
boolean isDisposed = (Boolean)e.getNewValue(); |
|
756 |
if (isDisposed != true) { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
757 |
if (log.isLoggable(PlatformLogger.FINE)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3237
diff
changeset
|
758 |
log.fine(" Assertion (newValue != true) failed for AppContext.GUI_DISPOSED "); |
2 | 759 |
} |
760 |
} |
|
761 |
AppContext appContext = AppContext.getAppContext(); |
|
762 |
synchronized (appContext) { |
|
763 |
appContext.remove(ACTIVE_WINDOWS_KEY); |
|
764 |
appContext.removePropertyChangeListener(AppContext.GUI_DISPOSED, this); |
|
765 |
||
766 |
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); |
|
767 |
kfm.removePropertyChangeListener("activeWindow", activeWindowListener); |
|
768 |
} |
|
769 |
} |
|
770 |
} |
|
771 |
||
772 |
/* |
|
773 |
* Static inner class, listens for 'activeWindow' KFM property changes and |
|
774 |
* updates the list of active windows per AppContext, so the latest active |
|
775 |
* window is always at the end of the list. The list is stored in AppContext. |
|
776 |
*/ |
|
777 |
private static class ActiveWindowListener implements PropertyChangeListener { |
|
778 |
public void propertyChange(PropertyChangeEvent e) { |
|
779 |
Window w = (Window)e.getNewValue(); |
|
780 |
if (w == null) { |
|
781 |
return; |
|
782 |
} |
|
783 |
AppContext appContext = SunToolkit.targetToAppContext(w); |
|
784 |
synchronized (appContext) { |
|
785 |
WWindowPeer wp = (WWindowPeer)w.getPeer(); |
|
786 |
// add/move wp to the end of the list |
|
787 |
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); |
|
788 |
if (l != null) { |
|
789 |
l.remove(wp); |
|
790 |
l.add(wp); |
|
791 |
} |
|
792 |
} |
|
793 |
} |
|
794 |
} |
|
795 |
} |