author | alexsch |
Fri, 13 Nov 2015 18:36:14 +0400 | |
changeset 34395 | 2ac7e99f7f4a |
parent 32865 | f9cb6e427f9e |
child 35667 | ed476aba94de |
permissions | -rw-r--r-- |
2 | 1 |
/* |
30469 | 2 |
* Copyright (c) 2002, 2015, 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.AWTEvent; |
|
28 |
import java.awt.AWTException; |
|
29 |
import java.awt.BufferCapabilities; |
|
30 |
import java.awt.Color; |
|
31 |
import java.awt.Component; |
|
32 |
import java.awt.Container; |
|
33 |
import java.awt.Cursor; |
|
34 |
import java.awt.Dimension; |
|
35 |
import java.awt.Font; |
|
36 |
import java.awt.FontMetrics; |
|
37 |
import java.awt.Graphics; |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2458
diff
changeset
|
38 |
import java.awt.GraphicsConfiguration; |
2 | 39 |
import java.awt.Image; |
40 |
import java.awt.Insets; |
|
41 |
import java.awt.Rectangle; |
|
42 |
import java.awt.SystemColor; |
|
43 |
import java.awt.Toolkit; |
|
44 |
import java.awt.Window; |
|
45 |
import java.awt.dnd.DropTarget; |
|
46 |
import java.awt.dnd.peer.DropTargetPeer; |
|
47 |
import java.awt.event.FocusEvent; |
|
48 |
import java.awt.event.InputEvent; |
|
49 |
import java.awt.event.InputMethodEvent; |
|
50 |
import java.awt.event.KeyEvent; |
|
51 |
import java.awt.event.MouseEvent; |
|
52 |
import java.awt.event.MouseWheelEvent; |
|
53 |
import java.awt.event.PaintEvent; |
|
54 |
import java.awt.event.WindowEvent; |
|
55 |
import java.awt.image.ImageObserver; |
|
56 |
import java.awt.image.ImageProducer; |
|
57 |
import java.awt.image.VolatileImage; |
|
58 |
import java.awt.peer.ComponentPeer; |
|
59 |
import java.awt.peer.ContainerPeer; |
|
60 |
import java.lang.reflect.*; |
|
61 |
import java.security.*; |
|
62 |
import java.util.Collection; |
|
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
63 |
import java.util.Objects; |
2 | 64 |
import java.util.Set; |
30469 | 65 |
|
66 |
import sun.awt.AWTAccessor.ComponentAccessor; |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
67 |
import sun.util.logging.PlatformLogger; |
2 | 68 |
import sun.awt.*; |
69 |
import sun.awt.event.IgnorePaintEvent; |
|
70 |
import sun.awt.image.SunVolatileImage; |
|
71 |
import sun.awt.image.ToolkitImage; |
|
887 | 72 |
import sun.java2d.BackBufferCapsProvider; |
2 | 73 |
import sun.java2d.pipe.Region; |
74 |
||
12813
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
12406
diff
changeset
|
75 |
|
887 | 76 |
public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer, |
77 |
BackBufferCapsProvider |
|
78 |
{ |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
79 |
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XComponentPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
80 |
private static final PlatformLogger buffersLog = PlatformLogger.getLogger("sun.awt.X11.XComponentPeer.multibuffer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
81 |
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XComponentPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
82 |
private static final PlatformLogger fontLog = PlatformLogger.getLogger("sun.awt.X11.font.XComponentPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
83 |
private static final PlatformLogger enableLog = PlatformLogger.getLogger("sun.awt.X11.enable.XComponentPeer"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2805
diff
changeset
|
84 |
private static final PlatformLogger shapeLog = PlatformLogger.getLogger("sun.awt.X11.shape.XComponentPeer"); |
2 | 85 |
|
86 |
boolean paintPending = false; |
|
87 |
boolean isLayouting = false; |
|
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
88 |
private boolean enabled; |
2 | 89 |
|
90 |
// Actually used only by XDecoratedPeer |
|
91 |
protected int boundsOperation; |
|
92 |
||
93 |
Color foreground; |
|
94 |
Color background; |
|
95 |
||
96 |
// Colors calculated as on Motif using MotifColorUtilties. |
|
97 |
// If you use these, call updateMotifColors() in the peer's Constructor and |
|
98 |
// setBackground(). Examples are XCheckboxPeer and XButtonPeer. |
|
99 |
Color darkShadow; |
|
100 |
Color lightShadow; |
|
101 |
Color selectColor; |
|
102 |
||
103 |
Font font; |
|
104 |
private long backBuffer = 0; |
|
105 |
private VolatileImage xBackBuffer = null; |
|
106 |
||
107 |
static Color[] systemColors; |
|
108 |
||
109 |
XComponentPeer() { |
|
110 |
} |
|
111 |
||
112 |
XComponentPeer (XCreateWindowParams params) { |
|
113 |
super(params); |
|
114 |
} |
|
115 |
||
116 |
XComponentPeer(Component target, long parentWindow, Rectangle bounds) { |
|
117 |
super(target, parentWindow, bounds); |
|
118 |
} |
|
119 |
||
120 |
/** |
|
121 |
* Standard peer constructor, with corresponding Component |
|
122 |
*/ |
|
123 |
XComponentPeer(Component target) { |
|
124 |
super(target); |
|
125 |
} |
|
126 |
||
127 |
||
128 |
void preInit(XCreateWindowParams params) { |
|
129 |
super.preInit(params); |
|
130 |
boundsOperation = DEFAULT_OPERATION; |
|
131 |
} |
|
132 |
void postInit(XCreateWindowParams params) { |
|
133 |
super.postInit(params); |
|
134 |
||
135 |
pSetCursor(target.getCursor()); |
|
136 |
||
137 |
foreground = target.getForeground(); |
|
138 |
background = target.getBackground(); |
|
139 |
font = target.getFont(); |
|
140 |
||
141 |
if (isInitialReshape()) { |
|
142 |
Rectangle r = target.getBounds(); |
|
143 |
reshape(r.x, r.y, r.width, r.height); |
|
144 |
} |
|
145 |
||
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
146 |
setEnabled(target.isEnabled()); |
2 | 147 |
|
148 |
if (target.isVisible()) { |
|
2458
f4bee3ba17ee
6806224: PIT : Getting java.lang.NullPointerException while opening Filedialog
dcherepanov
parents:
1978
diff
changeset
|
149 |
setVisible(true); |
2 | 150 |
} |
151 |
} |
|
152 |
||
153 |
protected boolean isInitialReshape() { |
|
154 |
return true; |
|
155 |
} |
|
156 |
||
157 |
public void reparent(ContainerPeer newNativeParent) { |
|
158 |
XComponentPeer newPeer = (XComponentPeer)newNativeParent; |
|
159 |
XToolkit.awtLock(); |
|
160 |
try { |
|
34395 | 161 |
XlibWrapper.XReparentWindow(XToolkit.getDisplay(), |
162 |
getWindow(), newPeer.getContentWindow(), |
|
163 |
scaleUp(x), scaleUp(y)); |
|
2 | 164 |
parentWindow = newPeer; |
165 |
} finally { |
|
166 |
XToolkit.awtUnlock(); |
|
167 |
} |
|
168 |
} |
|
169 |
public boolean isReparentSupported() { |
|
170 |
return System.getProperty("sun.awt.X11.XComponentPeer.reparentNotSupported", "false").equals("false"); |
|
171 |
} |
|
172 |
||
28231
b608ffcaed74
8066621: Suppress deprecation warnings in java.desktop module
darcy
parents:
25859
diff
changeset
|
173 |
@SuppressWarnings("deprecation") |
2 | 174 |
public boolean isObscured() { |
175 |
Container container = (target instanceof Container) ? |
|
176 |
(Container)target : target.getParent(); |
|
177 |
||
178 |
if (container == null) { |
|
179 |
return true; |
|
180 |
} |
|
181 |
||
182 |
Container parent; |
|
183 |
while ((parent = container.getParent()) != null) { |
|
184 |
container = parent; |
|
185 |
} |
|
186 |
||
187 |
if (container instanceof Window) { |
|
30469 | 188 |
XWindowPeer wpeer = AWTAccessor.getComponentAccessor() |
189 |
.getPeer(container); |
|
2 | 190 |
if (wpeer != null) { |
191 |
return (wpeer.winAttr.visibilityState != |
|
22567
5816a47fa4dd
8032047: Fix static lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
192 |
XWindowAttributesData.AWT_UNOBSCURED); |
2 | 193 |
} |
194 |
} |
|
195 |
return true; |
|
196 |
} |
|
197 |
||
198 |
public boolean canDetermineObscurity() { |
|
199 |
return true; |
|
200 |
} |
|
201 |
||
202 |
/************************************************* |
|
203 |
* FOCUS STUFF |
|
204 |
*************************************************/ |
|
205 |
||
206 |
/** |
|
207 |
* Keeps the track of focused state of the _NATIVE_ window |
|
208 |
*/ |
|
209 |
boolean bHasFocus = false; |
|
210 |
||
211 |
/** |
|
212 |
* Descendants should use this method to determine whether or not native window |
|
213 |
* has focus. |
|
214 |
*/ |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
30948
diff
changeset
|
215 |
public final boolean hasFocus() { |
2 | 216 |
return bHasFocus; |
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* Called when component receives focus |
|
221 |
*/ |
|
222 |
public void focusGained(FocusEvent e) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
223 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
224 |
focusLog.fine("{0}", e); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
225 |
} |
2 | 226 |
bHasFocus = true; |
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* Called when component loses focus |
|
231 |
*/ |
|
232 |
public void focusLost(FocusEvent e) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
233 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
234 |
focusLog.fine("{0}", e); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
235 |
} |
2 | 236 |
bHasFocus = false; |
237 |
} |
|
238 |
||
239 |
public boolean isFocusable() { |
|
240 |
/* should be implemented by other sub-classes */ |
|
241 |
return false; |
|
242 |
} |
|
243 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
244 |
private static Class<?> seClass; |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
245 |
private static Constructor<?> seCtor; |
2 | 246 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
30948
diff
changeset
|
247 |
static final AWTEvent wrapInSequenced(AWTEvent event) { |
2 | 248 |
try { |
249 |
if (seClass == null) { |
|
250 |
seClass = Class.forName("java.awt.SequencedEvent"); |
|
251 |
} |
|
252 |
||
253 |
if (seCtor == null) { |
|
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
254 |
seCtor = AccessController.doPrivileged(new |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
255 |
PrivilegedExceptionAction<Constructor<?>>() { |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
256 |
public Constructor<?> run() throws Exception { |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
257 |
Constructor<?> ctor = seClass.getConstructor( |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
258 |
new Class<?>[] { AWTEvent.class }); |
2 | 259 |
ctor.setAccessible(true); |
260 |
return ctor; |
|
261 |
} |
|
262 |
}); |
|
263 |
} |
|
264 |
||
265 |
return (AWTEvent) seCtor.newInstance(new Object[] { event }); |
|
266 |
} |
|
267 |
catch (ClassNotFoundException e) { |
|
268 |
throw new NoClassDefFoundError("java.awt.SequencedEvent."); |
|
269 |
} |
|
270 |
catch (PrivilegedActionException ex) { |
|
271 |
throw new NoClassDefFoundError("java.awt.SequencedEvent."); |
|
272 |
} |
|
273 |
catch (InstantiationException e) { |
|
274 |
assert false; |
|
275 |
} |
|
276 |
catch (IllegalAccessException e) { |
|
277 |
assert false; |
|
278 |
} |
|
279 |
catch (InvocationTargetException e) { |
|
280 |
assert false; |
|
281 |
} |
|
282 |
||
283 |
return null; |
|
284 |
} |
|
285 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
286 |
// TODO: consider moving it to KeyboardFocusManagerPeerImpl |
28231
b608ffcaed74
8066621: Suppress deprecation warnings in java.desktop module
darcy
parents:
25859
diff
changeset
|
287 |
@SuppressWarnings("deprecation") |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
30948
diff
changeset
|
288 |
public final boolean requestFocus(Component lightweightChild, boolean temporary, |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
289 |
boolean focusedWindowChangeAllowed, long time, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
290 |
CausedFocusEvent.Cause cause) |
2 | 291 |
{ |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
292 |
if (XKeyboardFocusManagerPeer. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
293 |
processSynchronousLightweightTransfer(target, lightweightChild, temporary, |
2 | 294 |
focusedWindowChangeAllowed, time)) |
295 |
{ |
|
296 |
return true; |
|
297 |
} |
|
298 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
299 |
int result = XKeyboardFocusManagerPeer. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
300 |
shouldNativelyFocusHeavyweight(target, lightweightChild, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
301 |
temporary, focusedWindowChangeAllowed, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
302 |
time, cause); |
2 | 303 |
|
304 |
switch (result) { |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
305 |
case XKeyboardFocusManagerPeer.SNFH_FAILURE: |
2 | 306 |
return false; |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
307 |
case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED: |
2 | 308 |
// Currently we just generate focus events like we deal with lightweight instead of calling |
309 |
// XSetInputFocus on native window |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
310 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
311 |
focusLog.finer("Proceeding with request to " + |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
312 |
lightweightChild + " in " + target); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
313 |
} |
2 | 314 |
/** |
315 |
* The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight |
|
316 |
* checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet |
|
317 |
* been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
318 |
* in requests list - and it breaks our requests sequence as first record on WGF should be the last |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
319 |
* focus owner which had focus before WLF. So, we should not add request record for such requests |
2 | 320 |
* but store this component in mostRecent - and return true as before for compatibility. |
321 |
*/ |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
322 |
Window parentWindow = SunToolkit.getContainingWindow(target); |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
323 |
if (parentWindow == null) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
324 |
return rejectFocusRequestHelper("WARNING: Parent window is null"); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
325 |
} |
30469 | 326 |
XWindowPeer wpeer = AWTAccessor.getComponentAccessor() |
327 |
.getPeer(parentWindow); |
|
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
328 |
if (wpeer == null) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
329 |
return rejectFocusRequestHelper("WARNING: Parent window's peer is null"); |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
330 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
331 |
/* |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
332 |
* Passing null 'actualFocusedWindow' as we don't want to restore focus on it |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
333 |
* when a component inside a Frame is requesting focus. |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
334 |
* See 6314575 for details. |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
335 |
*/ |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
336 |
boolean res = wpeer.requestWindowFocus(null); |
2 | 337 |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
338 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
339 |
focusLog.finer("Requested window focus: " + res); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
340 |
} |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
341 |
// If parent window can be made focused and has been made focused(synchronously) |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
342 |
// then we can proceed with children, otherwise we retreat. |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
343 |
if (!(res && parentWindow.isFocused())) { |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
344 |
return rejectFocusRequestHelper("Waiting for asynchronous processing of the request"); |
2 | 345 |
} |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
346 |
return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild, |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
22567
diff
changeset
|
347 |
target, |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
348 |
temporary, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
349 |
focusedWindowChangeAllowed, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
350 |
time, cause); |
2 | 351 |
// Motif compatibility code |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
352 |
case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED: |
2 | 353 |
// Either lightweight or excessive request - all events are generated. |
354 |
return true; |
|
355 |
} |
|
356 |
return false; |
|
357 |
} |
|
358 |
||
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
359 |
private boolean rejectFocusRequestHelper(String logMsg) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
360 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
361 |
focusLog.finer(logMsg); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
362 |
} |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
363 |
XKeyboardFocusManagerPeer.removeLastFocusRequest(target); |
442
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
364 |
return false; |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
365 |
} |
687798d7d7b6
6522725: Component in a minimized Frame has focus and receives key events
ant
parents:
439
diff
changeset
|
366 |
|
2 | 367 |
void handleJavaFocusEvent(AWTEvent e) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
368 |
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
369 |
focusLog.finer(e.toString()); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
370 |
} |
2 | 371 |
if (e.getID() == FocusEvent.FOCUS_GAINED) { |
372 |
focusGained((FocusEvent)e); |
|
373 |
} else { |
|
374 |
focusLost((FocusEvent)e); |
|
375 |
} |
|
376 |
} |
|
377 |
||
378 |
void handleJavaWindowFocusEvent(AWTEvent e) { |
|
379 |
} |
|
380 |
||
381 |
/************************************************* |
|
382 |
* END OF FOCUS STUFF |
|
383 |
*************************************************/ |
|
384 |
||
385 |
||
386 |
||
387 |
public void setVisible(boolean b) { |
|
388 |
xSetVisible(b); |
|
389 |
} |
|
390 |
||
391 |
public void hide() { |
|
392 |
setVisible(false); |
|
393 |
} |
|
394 |
||
395 |
/** |
|
396 |
* @see java.awt.peer.ComponentPeer |
|
397 |
*/ |
|
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
398 |
public void setEnabled(final boolean value) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
399 |
if (enableLog.isLoggable(PlatformLogger.Level.FINE)) { |
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
400 |
enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this); |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
401 |
} |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
402 |
boolean status = value; |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
403 |
// If any of our heavyweight ancestors are disable, we should be too |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
404 |
// See 6176875 for more information |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
405 |
final Container cp = SunToolkit.getNativeContainer(target); |
30469 | 406 |
final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
407 |
if (cp != null) { |
30469 | 408 |
status &= acc.<XComponentPeer>getPeer(cp).isEnabled(); |
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
409 |
} |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
410 |
synchronized (getStateLock()) { |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
411 |
if (enabled == status) { |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
412 |
return; |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
413 |
} |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
414 |
enabled = status; |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
415 |
} |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
416 |
|
2 | 417 |
if (target instanceof Container) { |
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
418 |
final Component[] list = ((Container) target).getComponents(); |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
419 |
for (final Component child : list) { |
30469 | 420 |
final ComponentPeer p = acc.getPeer(child); |
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
421 |
if (p != null) { |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
422 |
p.setEnabled(status && child.isEnabled()); |
2 | 423 |
} |
424 |
} |
|
425 |
} |
|
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
426 |
repaint(); |
2 | 427 |
} |
428 |
||
429 |
// |
|
430 |
// public so aw/Window can call it |
|
431 |
// |
|
12406
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
432 |
public final boolean isEnabled() { |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
433 |
synchronized (getStateLock()) { |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
434 |
return enabled; |
fc209a5d3c85
7097771: setEnabled does not work for components in disabled containers.
serb
parents:
10871
diff
changeset
|
435 |
} |
2 | 436 |
} |
437 |
||
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
438 |
@Override |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
439 |
public void paint(final Graphics g) { |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
440 |
super.paint(g); |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
441 |
// allow target to change the picture |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
442 |
target.paint(g); |
2 | 443 |
} |
444 |
||
445 |
public Graphics getGraphics() { |
|
446 |
return getGraphics(surfaceData, getPeerForeground(), getPeerBackground(), getPeerFont()); |
|
447 |
} |
|
448 |
public void print(Graphics g) { |
|
449 |
// clear rect here to emulate X clears rect before Expose |
|
450 |
g.setColor(target.getBackground()); |
|
451 |
g.fillRect(0, 0, target.getWidth(), target.getHeight()); |
|
452 |
g.setColor(target.getForeground()); |
|
453 |
// paint peer |
|
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
9035
diff
changeset
|
454 |
paintPeer(g); |
2 | 455 |
// allow target to change the picture |
456 |
target.print(g); |
|
457 |
} |
|
458 |
||
459 |
public void setBounds(int x, int y, int width, int height, int op) { |
|
460 |
this.x = x; |
|
461 |
this.y = y; |
|
462 |
this.width = width; |
|
463 |
this.height = height; |
|
464 |
xSetBounds(x,y,width,height); |
|
465 |
validateSurface(); |
|
466 |
layout(); |
|
467 |
} |
|
468 |
||
469 |
public void reshape(int x, int y, int width, int height) { |
|
470 |
setBounds(x, y, width, height, SET_BOUNDS); |
|
471 |
} |
|
472 |
||
473 |
public void coalescePaintEvent(PaintEvent e) { |
|
474 |
Rectangle r = e.getUpdateRect(); |
|
475 |
if (!(e instanceof IgnorePaintEvent)) { |
|
476 |
paintArea.add(r, e.getID()); |
|
477 |
} |
|
478 |
if (true) { |
|
479 |
switch(e.getID()) { |
|
480 |
case PaintEvent.UPDATE: |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
481 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
482 |
log.finer("XCP coalescePaintEvent : UPDATE : add : x = " + |
2 | 483 |
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
484 |
} |
2 | 485 |
return; |
486 |
case PaintEvent.PAINT: |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
487 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
488 |
log.finer("XCP coalescePaintEvent : PAINT : add : x = " + |
2 | 489 |
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
490 |
} |
2 | 491 |
return; |
492 |
} |
|
493 |
} |
|
494 |
} |
|
495 |
||
496 |
XWindowPeer getParentTopLevel() { |
|
30469 | 497 |
ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
498 |
Container parent = (target instanceof Container) ? ((Container)target) : (compAccessor.getParent(target)); |
2 | 499 |
// Search for parent window |
500 |
while (parent != null && !(parent instanceof Window)) { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
501 |
parent = compAccessor.getParent(parent); |
2 | 502 |
} |
503 |
if (parent != null) { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
504 |
return (XWindowPeer)compAccessor.getPeer(parent); |
2 | 505 |
} else { |
506 |
return null; |
|
507 |
} |
|
508 |
} |
|
509 |
||
510 |
/* This method is intended to be over-ridden by peers to perform user interaction */ |
|
511 |
void handleJavaMouseEvent(MouseEvent e) { |
|
512 |
switch (e.getID()) { |
|
513 |
case MouseEvent.MOUSE_PRESSED: |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
514 |
if (target == e.getSource() && |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
515 |
!target.isFocusOwner() && |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
516 |
XKeyboardFocusManagerPeer.shouldFocusOnClick(target)) |
2 | 517 |
{ |
518 |
XWindowPeer parentXWindow = getParentTopLevel(); |
|
519 |
Window parentWindow = ((Window)parentXWindow.getTarget()); |
|
520 |
// Simple windows are non-focusable in X terms but focusable in Java terms. |
|
521 |
// As X-non-focusable they don't receive any focus events - we should generate them |
|
522 |
// by ourselfves. |
|
523 |
// if (parentXWindow.isFocusableWindow() /*&& parentXWindow.isSimpleWindow()*/ && |
|
524 |
// !(getCurrentNativeFocusedWindow() == parentWindow)) |
|
525 |
// { |
|
526 |
// setCurrentNativeFocusedWindow(parentWindow); |
|
527 |
// WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS); |
|
528 |
// parentWindow.dispatchEvent(wfg); |
|
529 |
// } |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2462
diff
changeset
|
530 |
XKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT); |
2 | 531 |
} |
532 |
break; |
|
533 |
} |
|
534 |
} |
|
535 |
||
536 |
/* This method is intended to be over-ridden by peers to perform user interaction */ |
|
537 |
void handleJavaKeyEvent(KeyEvent e) { |
|
538 |
} |
|
539 |
||
540 |
/* This method is intended to be over-ridden by peers to perform user interaction */ |
|
541 |
void handleJavaMouseWheelEvent(MouseWheelEvent e) { |
|
542 |
} |
|
543 |
||
544 |
||
545 |
/* This method is intended to be over-ridden by peers to perform user interaction */ |
|
546 |
void handleJavaInputMethodEvent(InputMethodEvent e) { |
|
547 |
} |
|
548 |
||
549 |
void handleF10JavaKeyEvent(KeyEvent e) { |
|
550 |
if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_F10) { |
|
551 |
XWindowPeer winPeer = this.getToplevelXWindow(); |
|
552 |
if (winPeer instanceof XFramePeer) { |
|
553 |
XMenuBarPeer mPeer = ((XFramePeer)winPeer).getMenubarPeer(); |
|
554 |
if (mPeer != null) { |
|
555 |
mPeer.handleF10KeyPress(e); |
|
556 |
} |
|
557 |
} |
|
558 |
} |
|
559 |
} |
|
560 |
||
24191 | 561 |
@SuppressWarnings("fallthrough") |
2 | 562 |
public void handleEvent(java.awt.AWTEvent e) { |
563 |
if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled()) { |
|
564 |
if (e instanceof MouseEvent) { |
|
565 |
if (e instanceof MouseWheelEvent) { |
|
566 |
handleJavaMouseWheelEvent((MouseWheelEvent) e); |
|
567 |
} |
|
568 |
else |
|
569 |
handleJavaMouseEvent((MouseEvent) e); |
|
570 |
} |
|
571 |
else if (e instanceof KeyEvent) { |
|
572 |
handleF10JavaKeyEvent((KeyEvent)e); |
|
573 |
handleJavaKeyEvent((KeyEvent)e); |
|
574 |
} |
|
575 |
} |
|
576 |
else if (e instanceof KeyEvent && !((InputEvent)e).isConsumed()) { |
|
577 |
// even if target is disabled. |
|
578 |
handleF10JavaKeyEvent((KeyEvent)e); |
|
579 |
} |
|
580 |
else if (e instanceof InputMethodEvent) { |
|
581 |
handleJavaInputMethodEvent((InputMethodEvent) e); |
|
582 |
} |
|
583 |
||
584 |
int id = e.getID(); |
|
585 |
||
586 |
switch(id) { |
|
587 |
case PaintEvent.PAINT: |
|
588 |
// Got native painting |
|
589 |
paintPending = false; |
|
590 |
// Fallthrough to next statement |
|
591 |
case PaintEvent.UPDATE: |
|
592 |
// Skip all painting while layouting and all UPDATEs |
|
593 |
// while waiting for native paint |
|
594 |
if (!isLayouting && !paintPending) { |
|
595 |
paintArea.paint(target,false); |
|
596 |
} |
|
597 |
return; |
|
598 |
case FocusEvent.FOCUS_LOST: |
|
599 |
case FocusEvent.FOCUS_GAINED: |
|
600 |
handleJavaFocusEvent(e); |
|
601 |
break; |
|
602 |
case WindowEvent.WINDOW_LOST_FOCUS: |
|
603 |
case WindowEvent.WINDOW_GAINED_FOCUS: |
|
604 |
handleJavaWindowFocusEvent(e); |
|
605 |
break; |
|
606 |
default: |
|
607 |
break; |
|
608 |
} |
|
609 |
||
610 |
} |
|
611 |
||
612 |
public Dimension getMinimumSize() { |
|
613 |
return target.getSize(); |
|
614 |
} |
|
615 |
||
616 |
public Dimension getPreferredSize() { |
|
617 |
return getMinimumSize(); |
|
618 |
} |
|
619 |
||
620 |
public void layout() {} |
|
621 |
||
622 |
void updateMotifColors(Color bg) { |
|
623 |
int red = bg.getRed(); |
|
624 |
int green = bg.getGreen(); |
|
625 |
int blue = bg.getBlue(); |
|
626 |
||
627 |
darkShadow = new Color(MotifColorUtilities.calculateBottomShadowFromBackground(red,green,blue)); |
|
628 |
lightShadow = new Color(MotifColorUtilities.calculateTopShadowFromBackground(red,green,blue)); |
|
629 |
selectColor= new Color(MotifColorUtilities.calculateSelectFromBackground(red,green,blue)); |
|
630 |
} |
|
631 |
||
632 |
/* |
|
633 |
* Draw a 3D rectangle using the Motif colors. |
|
634 |
* "Normal" rectangles have shadows on the bottom. |
|
635 |
* "Depressed" rectangles (such as pressed buttons) have shadows on the top, |
|
636 |
* in which case true should be passed for topShadow. |
|
637 |
*/ |
|
638 |
public void drawMotif3DRect(Graphics g, |
|
639 |
int x, int y, int width, int height, |
|
640 |
boolean topShadow) { |
|
641 |
g.setColor(topShadow ? darkShadow : lightShadow); |
|
642 |
g.drawLine(x, y, x+width, y); // top |
|
643 |
g.drawLine(x, y+height, x, y); // left |
|
644 |
||
645 |
g.setColor(topShadow ? lightShadow : darkShadow ); |
|
646 |
g.drawLine(x+1, y+height, x+width, y+height); // bottom |
|
647 |
g.drawLine(x+width, y+height, x+width, y+1); // right |
|
648 |
} |
|
649 |
||
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
650 |
@Override |
2 | 651 |
public void setBackground(Color c) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
652 |
if (log.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
653 |
log.fine("Set background to " + c); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
654 |
} |
2 | 655 |
synchronized (getStateLock()) { |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
656 |
if (Objects.equals(background, c)) { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
657 |
return; |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
658 |
} |
2 | 659 |
background = c; |
660 |
} |
|
661 |
super.setBackground(c); |
|
662 |
repaint(); |
|
663 |
} |
|
664 |
||
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
665 |
@Override |
2 | 666 |
public void setForeground(Color c) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
667 |
if (log.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
668 |
log.fine("Set foreground to " + c); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
669 |
} |
2 | 670 |
synchronized (getStateLock()) { |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
671 |
if (Objects.equals(foreground, c)) { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
672 |
return; |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
673 |
} |
2 | 674 |
foreground = c; |
675 |
} |
|
676 |
repaint(); |
|
677 |
} |
|
678 |
||
679 |
/** |
|
680 |
* Gets the font metrics for the specified font. |
|
681 |
* @param font the font for which font metrics is to be |
|
682 |
* obtained |
|
683 |
* @return the font metrics for <code>font</code> |
|
684 |
* @see #getFont |
|
685 |
* @see java.awt.peer.ComponentPeer#getFontMetrics(Font) |
|
686 |
* @see Toolkit#getFontMetrics(Font) |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
24538
diff
changeset
|
687 |
* @since 1.0 |
2 | 688 |
*/ |
689 |
public FontMetrics getFontMetrics(Font font) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
690 |
if (fontLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
691 |
fontLog.fine("Getting font metrics for " + font); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
13652
diff
changeset
|
692 |
} |
2 | 693 |
return sun.font.FontDesignMetrics.getMetrics(font); |
694 |
} |
|
695 |
||
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
696 |
@Override |
2 | 697 |
public void setFont(Font f) { |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
698 |
if (f == null) { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
699 |
f = XWindow.getDefaultFont(); |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
700 |
} |
2 | 701 |
synchronized (getStateLock()) { |
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
702 |
if (f.equals(font)) { |
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
703 |
return; |
2 | 704 |
} |
705 |
font = f; |
|
706 |
} |
|
21278 | 707 |
// as it stands currently we don't need to do layout since |
2 | 708 |
// layout is done in the Component upon setFont. |
709 |
//layout(); |
|
21270
8a0fc12b81a2
7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents:
20465
diff
changeset
|
710 |
repaint(); |
2 | 711 |
} |
712 |
||
713 |
public Font getFont() { |
|
714 |
return font; |
|
715 |
} |
|
716 |
||
717 |
public void updateCursorImmediately() { |
|
718 |
XGlobalCursorManager.getCursorManager().updateCursorImmediately(); |
|
719 |
} |
|
720 |
||
8133
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
721 |
public final void pSetCursor(Cursor cursor) { |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
722 |
this.pSetCursor(cursor, true); |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
723 |
} |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
724 |
|
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
725 |
/* |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
726 |
* The method changes the cursor. |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
727 |
* @param cursor - a new cursor to change to. |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
728 |
* @param ignoreSubComponents - if {@code true} is passed then |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
729 |
* the new cursor will be installed on window. |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
730 |
* if {@code false} is passed then |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
731 |
* subsequent components will try to handle |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
732 |
* this request and install their cursor. |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
733 |
*/ |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
734 |
//ignoreSubComponents not used here |
c7e4a02e928e
6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents:
5506
diff
changeset
|
735 |
public void pSetCursor(Cursor cursor, boolean ignoreSubComponents) { |
2 | 736 |
XToolkit.awtLock(); |
737 |
try { |
|
738 |
long xcursor = XGlobalCursorManager.getCursor(cursor); |
|
739 |
||
740 |
XSetWindowAttributes xwa = new XSetWindowAttributes(); |
|
741 |
xwa.set_cursor(xcursor); |
|
742 |
||
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
743 |
long valuemask = XConstants.CWCursor; |
2 | 744 |
|
745 |
XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),getWindow(),valuemask,xwa.pData); |
|
746 |
XlibWrapper.XFlush(XToolkit.getDisplay()); |
|
747 |
xwa.dispose(); |
|
748 |
} finally { |
|
749 |
XToolkit.awtUnlock(); |
|
750 |
} |
|
751 |
} |
|
752 |
||
753 |
public Image createImage(ImageProducer producer) { |
|
754 |
return new ToolkitImage(producer); |
|
755 |
} |
|
756 |
||
757 |
public Image createImage(int width, int height) { |
|
758 |
return graphicsConfig.createAcceleratedImage(target, width, height); |
|
759 |
} |
|
760 |
||
761 |
public VolatileImage createVolatileImage(int width, int height) { |
|
762 |
return new SunVolatileImage(target, width, height); |
|
763 |
} |
|
764 |
||
765 |
public boolean prepareImage(Image img, int w, int h, ImageObserver o) { |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
18178
diff
changeset
|
766 |
return Toolkit.getDefaultToolkit().prepareImage(img, w, h, o); |
2 | 767 |
} |
768 |
||
769 |
public int checkImage(Image img, int w, int h, ImageObserver o) { |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
18178
diff
changeset
|
770 |
return Toolkit.getDefaultToolkit().checkImage(img, w, h, o); |
2 | 771 |
} |
772 |
||
773 |
public Dimension preferredSize() { |
|
774 |
return getPreferredSize(); |
|
775 |
} |
|
776 |
||
777 |
public Dimension minimumSize() { |
|
778 |
return getMinimumSize(); |
|
779 |
} |
|
780 |
||
781 |
public Insets getInsets() { |
|
782 |
return new Insets(0, 0, 0, 0); |
|
783 |
} |
|
784 |
||
785 |
public void beginValidate() { |
|
786 |
} |
|
787 |
||
788 |
public void endValidate() { |
|
789 |
} |
|
790 |
||
791 |
||
792 |
/** |
|
793 |
* DEPRECATED: Replaced by getInsets(). |
|
794 |
*/ |
|
795 |
||
796 |
public Insets insets() { |
|
797 |
return getInsets(); |
|
798 |
} |
|
799 |
||
800 |
// Returns true if we are inside begin/endLayout and |
|
801 |
// are waiting for native painting |
|
802 |
public boolean isPaintPending() { |
|
803 |
return paintPending && isLayouting; |
|
804 |
} |
|
805 |
||
806 |
public boolean handlesWheelScrolling() { |
|
807 |
return false; |
|
808 |
} |
|
809 |
||
810 |
public void beginLayout() { |
|
811 |
// Skip all painting till endLayout |
|
812 |
isLayouting = true; |
|
813 |
||
814 |
} |
|
815 |
||
816 |
public void endLayout() { |
|
817 |
if (!paintPending && !paintArea.isEmpty() |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
818 |
&& !AWTAccessor.getComponentAccessor().getIgnoreRepaint(target)) |
2 | 819 |
{ |
820 |
// if not waiting for native painting repaint damaged area |
|
821 |
postEvent(new PaintEvent(target, PaintEvent.PAINT, |
|
822 |
new Rectangle())); |
|
823 |
} |
|
824 |
isLayouting = false; |
|
825 |
} |
|
826 |
||
827 |
public Color getWinBackground() { |
|
828 |
return getPeerBackground(); |
|
829 |
} |
|
830 |
||
831 |
static int[] getRGBvals(Color c) { |
|
832 |
||
833 |
int rgbvals[] = new int[3]; |
|
834 |
||
835 |
rgbvals[0] = c.getRed(); |
|
836 |
rgbvals[1] = c.getGreen(); |
|
837 |
rgbvals[2] = c.getBlue(); |
|
838 |
||
839 |
return rgbvals; |
|
840 |
} |
|
841 |
||
842 |
static final int BACKGROUND_COLOR = 0; |
|
843 |
static final int HIGHLIGHT_COLOR = 1; |
|
844 |
static final int SHADOW_COLOR = 2; |
|
845 |
static final int FOREGROUND_COLOR = 3; |
|
846 |
||
847 |
public Color[] getGUIcolors() { |
|
848 |
Color c[] = new Color[4]; |
|
849 |
float backb, highb, shadowb, hue, saturation; |
|
850 |
c[BACKGROUND_COLOR] = getWinBackground(); |
|
851 |
if (c[BACKGROUND_COLOR] == null) { |
|
852 |
c[BACKGROUND_COLOR] = super.getWinBackground(); |
|
853 |
} |
|
854 |
if (c[BACKGROUND_COLOR] == null) { |
|
855 |
c[BACKGROUND_COLOR] = Color.lightGray; |
|
856 |
} |
|
857 |
||
858 |
int[] rgb = getRGBvals(c[BACKGROUND_COLOR]); |
|
859 |
||
860 |
float[] hsb = Color.RGBtoHSB(rgb[0],rgb[1],rgb[2],null); |
|
861 |
||
862 |
hue = hsb[0]; |
|
863 |
saturation = hsb[1]; |
|
864 |
backb = hsb[2]; |
|
865 |
||
866 |
||
867 |
/* Calculate Highlight Brightness */ |
|
868 |
||
869 |
highb = backb + 0.2f; |
|
870 |
shadowb = backb - 0.4f; |
|
871 |
if ((highb > 1.0) ) { |
|
872 |
if ((1.0 - backb) < 0.05) { |
|
873 |
highb = shadowb + 0.25f; |
|
874 |
} else { |
|
875 |
highb = 1.0f; |
|
876 |
} |
|
877 |
} else { |
|
878 |
if (shadowb < 0.0) { |
|
879 |
if ((backb - 0.0) < 0.25) { |
|
880 |
highb = backb + 0.75f; |
|
881 |
shadowb = highb - 0.2f; |
|
882 |
} else { |
|
883 |
shadowb = 0.0f; |
|
884 |
} |
|
885 |
} |
|
886 |
} |
|
887 |
c[HIGHLIGHT_COLOR] = Color.getHSBColor(hue,saturation,highb); |
|
888 |
c[SHADOW_COLOR] = Color.getHSBColor(hue,saturation,shadowb); |
|
889 |
||
890 |
||
891 |
/* |
|
892 |
c[SHADOW_COLOR] = c[BACKGROUND_COLOR].darker(); |
|
893 |
int r2 = c[SHADOW_COLOR].getRed(); |
|
894 |
int g2 = c[SHADOW_COLOR].getGreen(); |
|
895 |
int b2 = c[SHADOW_COLOR].getBlue(); |
|
896 |
*/ |
|
897 |
||
898 |
c[FOREGROUND_COLOR] = getPeerForeground(); |
|
899 |
if (c[FOREGROUND_COLOR] == null) { |
|
900 |
c[FOREGROUND_COLOR] = Color.black; |
|
901 |
} |
|
902 |
/* |
|
903 |
if ((c[BACKGROUND_COLOR].equals(c[HIGHLIGHT_COLOR])) |
|
904 |
&& (c[BACKGROUND_COLOR].equals(c[SHADOW_COLOR]))) { |
|
905 |
c[SHADOW_COLOR] = new Color(c[BACKGROUND_COLOR].getRed() + 75, |
|
906 |
c[BACKGROUND_COLOR].getGreen() + 75, |
|
907 |
c[BACKGROUND_COLOR].getBlue() + 75); |
|
908 |
c[HIGHLIGHT_COLOR] = c[SHADOW_COLOR].brighter(); |
|
909 |
} else if (c[BACKGROUND_COLOR].equals(c[HIGHLIGHT_COLOR])) { |
|
910 |
c[HIGHLIGHT_COLOR] = c[SHADOW_COLOR]; |
|
911 |
c[SHADOW_COLOR] = c[SHADOW_COLOR].darker(); |
|
912 |
} |
|
913 |
*/ |
|
914 |
if (! isEnabled()) { |
|
915 |
c[BACKGROUND_COLOR] = c[BACKGROUND_COLOR].darker(); |
|
916 |
// Reduce the contrast |
|
917 |
// Calculate the NTSC gray (NB: REC709 L* might be better!) |
|
918 |
// for foreground and background; then multiply the foreground |
|
919 |
// by the average lightness |
|
920 |
||
921 |
||
922 |
Color tc = c[BACKGROUND_COLOR]; |
|
923 |
int bg = tc.getRed() * 30 + tc.getGreen() * 59 + tc.getBlue() * 11; |
|
924 |
||
925 |
tc = c[FOREGROUND_COLOR]; |
|
926 |
int fg = tc.getRed() * 30 + tc.getGreen() * 59 + tc.getBlue() * 11; |
|
927 |
||
928 |
float ave = (float) ((fg + bg) / 51000.0); |
|
929 |
// 255 * 100 * 2 |
|
930 |
||
931 |
Color newForeground = new Color((int) (tc.getRed() * ave), |
|
932 |
(int) (tc.getGreen() * ave), |
|
933 |
(int) (tc.getBlue() * ave)); |
|
934 |
||
935 |
if (newForeground.equals(c[FOREGROUND_COLOR])) { |
|
936 |
// This probably means the foreground color is black or white |
|
937 |
newForeground = new Color(ave, ave, ave); |
|
938 |
} |
|
939 |
c[FOREGROUND_COLOR] = newForeground; |
|
940 |
||
941 |
} |
|
942 |
||
943 |
||
944 |
return c; |
|
945 |
} |
|
946 |
||
947 |
/** |
|
948 |
* Returns an array of Colors similar to getGUIcolors(), but using the |
|
949 |
* System colors. This is useful if pieces of a Component (such as |
|
950 |
* the integrated scrollbars of a List) should retain the System color |
|
951 |
* instead of the background color set by Component.setBackground(). |
|
952 |
*/ |
|
953 |
static Color[] getSystemColors() { |
|
954 |
if (systemColors == null) { |
|
955 |
systemColors = new Color[4]; |
|
956 |
systemColors[BACKGROUND_COLOR] = SystemColor.window; |
|
957 |
systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight; |
|
958 |
systemColors[SHADOW_COLOR] = SystemColor.controlShadow; |
|
959 |
systemColors[FOREGROUND_COLOR] = SystemColor.windowText; |
|
960 |
} |
|
961 |
return systemColors; |
|
962 |
} |
|
963 |
||
964 |
/** |
|
965 |
* Draw a 3D oval. |
|
966 |
*/ |
|
967 |
public void draw3DOval(Graphics g, Color colors[], |
|
968 |
int x, int y, int w, int h, boolean raised) |
|
969 |
{ |
|
970 |
Color c = g.getColor(); |
|
971 |
g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); |
|
972 |
g.drawArc(x, y, w, h, 45, 180); |
|
973 |
g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); |
|
974 |
g.drawArc(x, y, w, h, 225, 180); |
|
975 |
g.setColor(c); |
|
976 |
} |
|
977 |
||
978 |
public void draw3DRect(Graphics g, Color colors[], |
|
979 |
int x, int y, int width, int height, boolean raised) |
|
980 |
{ |
|
981 |
Color c = g.getColor(); |
|
982 |
g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); |
|
983 |
g.drawLine(x, y, x, y + height); |
|
984 |
g.drawLine(x + 1, y, x + width - 1, y); |
|
985 |
g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); |
|
986 |
g.drawLine(x + 1, y + height, x + width, y + height); |
|
987 |
g.drawLine(x + width, y, x + width, y + height - 1); |
|
988 |
g.setColor(c); |
|
989 |
} |
|
990 |
||
991 |
/* |
|
992 |
* drawXXX() methods are used to print the native components by |
|
993 |
* rendering the Motif look ourselves. |
|
994 |
* ToDo(aim): needs to query native motif for more accurate color |
|
995 |
* information. |
|
996 |
*/ |
|
997 |
void draw3DOval(Graphics g, Color bg, |
|
998 |
int x, int y, int w, int h, boolean raised) |
|
999 |
{ |
|
1000 |
Color c = g.getColor(); |
|
1001 |
Color shadow = bg.darker(); |
|
1002 |
Color highlight = bg.brighter(); |
|
1003 |
||
1004 |
g.setColor(raised ? highlight : shadow); |
|
1005 |
g.drawArc(x, y, w, h, 45, 180); |
|
1006 |
g.setColor(raised ? shadow : highlight); |
|
1007 |
g.drawArc(x, y, w, h, 225, 180); |
|
1008 |
g.setColor(c); |
|
1009 |
} |
|
1010 |
||
1011 |
void draw3DRect(Graphics g, Color bg, |
|
1012 |
int x, int y, int width, int height, |
|
1013 |
boolean raised) { |
|
1014 |
Color c = g.getColor(); |
|
1015 |
Color shadow = bg.darker(); |
|
1016 |
Color highlight = bg.brighter(); |
|
1017 |
||
1018 |
g.setColor(raised ? highlight : shadow); |
|
1019 |
g.drawLine(x, y, x, y + height); |
|
1020 |
g.drawLine(x + 1, y, x + width - 1, y); |
|
1021 |
g.setColor(raised ? shadow : highlight); |
|
1022 |
g.drawLine(x + 1, y + height, x + width, y + height); |
|
1023 |
g.drawLine(x + width, y, x + width, y + height - 1); |
|
1024 |
g.setColor(c); |
|
1025 |
} |
|
1026 |
||
1027 |
void drawScrollbar(Graphics g, Color bg, int thickness, int length, |
|
1028 |
int min, int max, int val, int vis, boolean horizontal) { |
|
1029 |
Color c = g.getColor(); |
|
1030 |
double f = (double)(length - 2*(thickness-1)) / Math.max(1, ((max - min) + vis)); |
|
1031 |
int v1 = thickness + (int)(f * (val - min)); |
|
1032 |
int v2 = (int)(f * vis); |
|
1033 |
int w2 = thickness-4; |
|
1034 |
int tpts_x[] = new int[3]; |
|
1035 |
int tpts_y[] = new int[3]; |
|
1036 |
||
1037 |
if (length < 3*w2 ) { |
|
1038 |
v1 = v2 = 0; |
|
1039 |
if (length < 2*w2 + 2) { |
|
1040 |
w2 = (length-2)/2; |
|
1041 |
} |
|
1042 |
} else if (v2 < 7) { |
|
1043 |
// enforce a minimum handle size |
|
1044 |
v1 = Math.max(0, v1 - ((7 - v2)>>1)); |
|
1045 |
v2 = 7; |
|
1046 |
} |
|
1047 |
||
1048 |
int ctr = thickness/2; |
|
1049 |
int sbmin = ctr - w2/2; |
|
1050 |
int sbmax = ctr + w2/2; |
|
1051 |
||
1052 |
// paint the background slightly darker |
|
1053 |
{ |
|
1054 |
Color d = new Color((int) (bg.getRed() * 0.85), |
|
1055 |
(int) (bg.getGreen() * 0.85), |
|
1056 |
(int) (bg.getBlue() * 0.85)); |
|
1057 |
||
1058 |
g.setColor(d); |
|
1059 |
if (horizontal) { |
|
1060 |
g.fillRect(0, 0, length, thickness); |
|
1061 |
} else { |
|
1062 |
g.fillRect(0, 0, thickness, length); |
|
1063 |
} |
|
1064 |
} |
|
1065 |
||
1066 |
// paint the thumb and arrows in the normal background color |
|
1067 |
g.setColor(bg); |
|
1068 |
if (v1 > 0) { |
|
1069 |
if (horizontal) { |
|
1070 |
g.fillRect(v1, 3, v2, thickness-3); |
|
1071 |
} else { |
|
1072 |
g.fillRect(3, v1, thickness-3, v2); |
|
1073 |
} |
|
1074 |
} |
|
1075 |
||
1076 |
tpts_x[0] = ctr; tpts_y[0] = 2; |
|
1077 |
tpts_x[1] = sbmin; tpts_y[1] = w2; |
|
1078 |
tpts_x[2] = sbmax; tpts_y[2] = w2; |
|
1079 |
if (horizontal) { |
|
1080 |
g.fillPolygon(tpts_y, tpts_x, 3); |
|
1081 |
} else { |
|
1082 |
g.fillPolygon(tpts_x, tpts_y, 3); |
|
1083 |
} |
|
1084 |
||
1085 |
tpts_y[0] = length-2; |
|
1086 |
tpts_y[1] = length-w2; |
|
1087 |
tpts_y[2] = length-w2; |
|
1088 |
if (horizontal) { |
|
1089 |
g.fillPolygon(tpts_y, tpts_x, 3); |
|
1090 |
} else { |
|
1091 |
g.fillPolygon(tpts_x, tpts_y, 3); |
|
1092 |
} |
|
1093 |
||
1094 |
Color highlight = bg.brighter(); |
|
1095 |
||
1096 |
// // // // draw the "highlighted" edges |
|
1097 |
g.setColor(highlight); |
|
1098 |
||
1099 |
// outline & arrows |
|
1100 |
if (horizontal) { |
|
1101 |
g.drawLine(1, thickness, length - 1, thickness); |
|
1102 |
g.drawLine(length - 1, 1, length - 1, thickness); |
|
1103 |
||
1104 |
// arrows |
|
1105 |
g.drawLine(1, ctr, w2, sbmin); |
|
1106 |
g.drawLine(length - w2, sbmin, length - w2, sbmax); |
|
1107 |
g.drawLine(length - w2, sbmin, length - 2, ctr); |
|
1108 |
||
1109 |
} else { |
|
1110 |
g.drawLine(thickness, 1, thickness, length - 1); |
|
1111 |
g.drawLine(1, length - 1, thickness, length - 1); |
|
1112 |
||
1113 |
// arrows |
|
1114 |
g.drawLine(ctr, 1, sbmin, w2); |
|
1115 |
g.drawLine(sbmin, length - w2, sbmax, length - w2); |
|
1116 |
g.drawLine(sbmin, length - w2, ctr, length - 2); |
|
1117 |
} |
|
1118 |
||
1119 |
// thumb |
|
1120 |
if (v1 > 0) { |
|
1121 |
if (horizontal) { |
|
1122 |
g.drawLine(v1, 2, v1 + v2, 2); |
|
1123 |
g.drawLine(v1, 2, v1, thickness-3); |
|
1124 |
} else { |
|
1125 |
g.drawLine(2, v1, 2, v1 + v2); |
|
1126 |
g.drawLine(2, v1, thickness-3, v1); |
|
1127 |
} |
|
1128 |
} |
|
1129 |
||
1130 |
Color shadow = bg.darker(); |
|
1131 |
||
1132 |
// // // // draw the "shadowed" edges |
|
1133 |
g.setColor(shadow); |
|
1134 |
||
1135 |
// outline && arrows |
|
1136 |
if (horizontal) { |
|
1137 |
g.drawLine(0, 0, 0, thickness); |
|
1138 |
g.drawLine(0, 0, length - 1, 0); |
|
1139 |
||
1140 |
// arrows |
|
1141 |
g.drawLine(w2, sbmin, w2, sbmax); |
|
1142 |
g.drawLine(w2, sbmax, 1, ctr); |
|
1143 |
g.drawLine(length-2, ctr, length-w2, sbmax); |
|
1144 |
||
1145 |
} else { |
|
1146 |
g.drawLine(0, 0, thickness, 0); |
|
1147 |
g.drawLine(0, 0, 0, length - 1); |
|
1148 |
||
1149 |
// arrows |
|
1150 |
g.drawLine(sbmin, w2, sbmax, w2); |
|
1151 |
g.drawLine(sbmax, w2, ctr, 1); |
|
1152 |
g.drawLine(ctr, length-2, sbmax, length-w2); |
|
1153 |
} |
|
1154 |
||
1155 |
// thumb |
|
1156 |
if (v1 > 0) { |
|
1157 |
if (horizontal) { |
|
1158 |
g.drawLine(v1 + v2, 2, v1 + v2, thickness-2); |
|
1159 |
g.drawLine(v1, thickness-2, v1 + v2, thickness-2); |
|
1160 |
} else { |
|
1161 |
g.drawLine(2, v1 + v2, thickness-2, v1 + v2); |
|
1162 |
g.drawLine(thickness-2, v1, thickness-2, v1 + v2); |
|
1163 |
} |
|
1164 |
} |
|
1165 |
g.setColor(c); |
|
1166 |
} |
|
1167 |
||
1168 |
/** |
|
1169 |
* The following multibuffering-related methods delegate to our |
|
1170 |
* associated GraphicsConfig (X11 or GLX) to handle the appropriate |
|
1171 |
* native windowing system specific actions. |
|
1172 |
*/ |
|
1173 |
||
887 | 1174 |
private BufferCapabilities backBufferCaps; |
1175 |
||
2 | 1176 |
public void createBuffers(int numBuffers, BufferCapabilities caps) |
1177 |
throws AWTException |
|
1178 |
{ |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1179 |
if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1180 |
buffersLog.fine("createBuffers(" + numBuffers + ", " + caps + ")"); |
1181 |
} |
|
887 | 1182 |
// set the caps first, they're used when creating the bb |
1183 |
backBufferCaps = caps; |
|
2 | 1184 |
backBuffer = graphicsConfig.createBackBuffer(this, numBuffers, caps); |
1185 |
xBackBuffer = graphicsConfig.createBackBufferImage(target, |
|
1186 |
backBuffer); |
|
1187 |
} |
|
1188 |
||
887 | 1189 |
@Override |
1190 |
public BufferCapabilities getBackBufferCaps() { |
|
1191 |
return backBufferCaps; |
|
1192 |
} |
|
1193 |
||
1194 |
public void flip(int x1, int y1, int x2, int y2, |
|
1195 |
BufferCapabilities.FlipContents flipAction) |
|
1196 |
{ |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1197 |
if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1198 |
buffersLog.fine("flip(" + flipAction + ")"); |
1199 |
} |
|
1200 |
if (backBuffer == 0) { |
|
1201 |
throw new IllegalStateException("Buffers have not been created"); |
|
1202 |
} |
|
887 | 1203 |
graphicsConfig.flip(this, target, xBackBuffer, |
1204 |
x1, y1, x2, y2, flipAction); |
|
2 | 1205 |
} |
1206 |
||
1207 |
public Image getBackBuffer() { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1208 |
if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1209 |
buffersLog.fine("getBackBuffer()"); |
1210 |
} |
|
1211 |
if (backBuffer == 0) { |
|
1212 |
throw new IllegalStateException("Buffers have not been created"); |
|
1213 |
} |
|
1214 |
return xBackBuffer; |
|
1215 |
} |
|
1216 |
||
1217 |
public void destroyBuffers() { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1218 |
if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) { |
2 | 1219 |
buffersLog.fine("destroyBuffers()"); |
1220 |
} |
|
1221 |
graphicsConfig.destroyBackBuffer(backBuffer); |
|
1222 |
backBuffer = 0; |
|
1223 |
xBackBuffer = null; |
|
1224 |
} |
|
1225 |
||
1226 |
// End of multi-buffering |
|
1227 |
||
1228 |
public void notifyTextComponentChange(boolean add){ |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
1229 |
Container parent = AWTAccessor.getComponentAccessor().getParent(target); |
2 | 1230 |
while(!(parent == null || |
1231 |
parent instanceof java.awt.Frame || |
|
1232 |
parent instanceof java.awt.Dialog)) { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4214
diff
changeset
|
1233 |
parent = AWTAccessor.getComponentAccessor().getParent(parent); |
2 | 1234 |
} |
1235 |
||
1236 |
/* FIX ME - FIX ME need to implement InputMethods |
|
1237 |
if (parent instanceof java.awt.Frame || |
|
1238 |
parent instanceof java.awt.Dialog) { |
|
1239 |
if (add) |
|
1240 |
((MInputMethodControl)parent.getPeer()).addTextComponent((MComponentPeer)this); |
|
1241 |
else |
|
1242 |
((MInputMethodControl)parent.getPeer()).removeTextComponent((MComponentPeer)this); |
|
1243 |
} |
|
1244 |
*/ |
|
1245 |
} |
|
1246 |
||
1247 |
/** |
|
1248 |
* Returns true if this event is disabled and shouldn't be processed by window |
|
1249 |
* Currently if target component is disabled the following event will be disabled on window: |
|
1250 |
* ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify |
|
1251 |
*/ |
|
1252 |
protected boolean isEventDisabled(XEvent e) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1253 |
if (enableLog.isLoggable(PlatformLogger.Level.FINEST)) { |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
1254 |
enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable")); |
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
1255 |
} |
2 | 1256 |
if (!isEnabled()) { |
1257 |
switch (e.get_type()) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1258 |
case XConstants.ButtonPress: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1259 |
case XConstants.ButtonRelease: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1260 |
case XConstants.KeyPress: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1261 |
case XConstants.KeyRelease: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1262 |
case XConstants.EnterNotify: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1263 |
case XConstants.LeaveNotify: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1264 |
case XConstants.MotionNotify: |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1265 |
if (enableLog.isLoggable(PlatformLogger.Level.FINER)) { |
10871
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
1266 |
enableLog.finer("Event {0} is disable", e); |
c0aeb0b14df1
7104625: sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
anthony
parents:
10096
diff
changeset
|
1267 |
} |
2 | 1268 |
return true; |
1269 |
} |
|
1270 |
} |
|
1271 |
switch(e.get_type()) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1272 |
case XConstants.MapNotify: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
116
diff
changeset
|
1273 |
case XConstants.UnmapNotify: |
2 | 1274 |
return true; |
1275 |
} |
|
1276 |
return super.isEventDisabled(e); |
|
1277 |
} |
|
1278 |
||
1279 |
Color getPeerBackground() { |
|
1280 |
return background; |
|
1281 |
} |
|
1282 |
||
1283 |
Color getPeerForeground() { |
|
1284 |
return foreground; |
|
1285 |
} |
|
1286 |
||
1287 |
Font getPeerFont() { |
|
1288 |
return font; |
|
1289 |
} |
|
1290 |
||
1291 |
Dimension getPeerSize() { |
|
1292 |
return new Dimension(width,height); |
|
1293 |
} |
|
1294 |
||
1295 |
public void setBoundsOperation(int operation) { |
|
1296 |
synchronized(getStateLock()) { |
|
1297 |
if (boundsOperation == DEFAULT_OPERATION) { |
|
1298 |
boundsOperation = operation; |
|
1299 |
} else if (operation == RESET_OPERATION) { |
|
1300 |
boundsOperation = DEFAULT_OPERATION; |
|
1301 |
} |
|
1302 |
} |
|
1303 |
} |
|
1304 |
||
1305 |
static String operationToString(int operation) { |
|
1306 |
switch (operation) { |
|
1307 |
case SET_LOCATION: |
|
1308 |
return "SET_LOCATION"; |
|
1309 |
case SET_SIZE: |
|
1310 |
return "SET_SIZE"; |
|
1311 |
case SET_CLIENT_SIZE: |
|
1312 |
return "SET_CLIENT_SIZE"; |
|
1313 |
default: |
|
1314 |
case SET_BOUNDS: |
|
1315 |
return "SET_BOUNDS"; |
|
1316 |
} |
|
1317 |
} |
|
1318 |
||
2462
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1319 |
/** |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1320 |
* Lowers this component at the bottom of the above HW peer. If the above parameter |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1321 |
* is null then the method places this component at the top of the Z-order. |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1322 |
*/ |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1323 |
public void setZOrder(ComponentPeer above) { |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1324 |
long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0; |
2 | 1325 |
|
2462
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1326 |
XToolkit.awtLock(); |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1327 |
try{ |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1328 |
XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow); |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1329 |
}finally{ |
192552ca8292
6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents:
2459
diff
changeset
|
1330 |
XToolkit.awtUnlock(); |
2 | 1331 |
} |
1332 |
} |
|
1333 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
24191
diff
changeset
|
1334 |
private void addTree(Collection<Long> order, Set<Long> set, Container cont) { |
2 | 1335 |
for (int i = 0; i < cont.getComponentCount(); i++) { |
1336 |
Component comp = cont.getComponent(i); |
|
30469 | 1337 |
Object peer = AWTAccessor.getComponentAccessor().getPeer(comp); |
2 | 1338 |
if (peer instanceof XComponentPeer) { |
1339 |
Long window = Long.valueOf(((XComponentPeer)peer).getWindow()); |
|
1340 |
if (!set.contains(window)) { |
|
1341 |
set.add(window); |
|
1342 |
order.add(window); |
|
1343 |
} |
|
1344 |
} else if (comp instanceof Container) { |
|
1345 |
// It is lightweight container, it might contain heavyweight components attached to this |
|
1346 |
// peer |
|
1347 |
addTree(order, set, (Container)comp); |
|
1348 |
} |
|
1349 |
} |
|
1350 |
} |
|
1351 |
||
1352 |
/****** DropTargetPeer implementation ********************/ |
|
1353 |
||
1354 |
public void addDropTarget(DropTarget dt) { |
|
1355 |
Component comp = target; |
|
1356 |
while(!(comp == null || comp instanceof Window)) { |
|
1357 |
comp = comp.getParent(); |
|
1358 |
} |
|
1359 |
||
1360 |
if (comp instanceof Window) { |
|
30469 | 1361 |
XWindowPeer wpeer = AWTAccessor.getComponentAccessor().getPeer(comp); |
2 | 1362 |
if (wpeer != null) { |
1363 |
wpeer.addDropTarget(); |
|
1364 |
} |
|
1365 |
} |
|
1366 |
} |
|
1367 |
||
1368 |
public void removeDropTarget(DropTarget dt) { |
|
1369 |
Component comp = target; |
|
1370 |
while(!(comp == null || comp instanceof Window)) { |
|
1371 |
comp = comp.getParent(); |
|
1372 |
} |
|
1373 |
||
1374 |
if (comp instanceof Window) { |
|
30469 | 1375 |
XWindowPeer wpeer = AWTAccessor.getComponentAccessor() |
1376 |
.getPeer(comp); |
|
2 | 1377 |
if (wpeer != null) { |
1378 |
wpeer.removeDropTarget(); |
|
1379 |
} |
|
1380 |
} |
|
1381 |
} |
|
1382 |
||
1383 |
/** |
|
1384 |
* Applies the shape to the X-window. |
|
1385 |
* @since 1.7 |
|
1386 |
*/ |
|
1387 |
public void applyShape(Region shape) { |
|
1388 |
if (XlibUtil.isShapingSupported()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1389 |
if (shapeLog.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 1390 |
shapeLog.finer( |
1391 |
"*** INFO: Setting shape: PEER: " + this |
|
1392 |
+ "; WINDOW: " + getWindow() |
|
1393 |
+ "; TARGET: " + target |
|
1394 |
+ "; SHAPE: " + shape); |
|
1395 |
} |
|
1396 |
XToolkit.awtLock(); |
|
1397 |
try { |
|
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1398 |
if (shape != null) { |
34395 | 1399 |
|
1400 |
int scale = getScale(); |
|
1401 |
if (scale != 1) { |
|
1402 |
shape = shape.getScaledRegion(scale, scale); |
|
1403 |
} |
|
1404 |
||
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1405 |
XlibWrapper.SetRectangularShape( |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1406 |
XToolkit.getDisplay(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1407 |
getWindow(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1408 |
shape.getLoX(), shape.getLoY(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1409 |
shape.getHiX(), shape.getHiY(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1410 |
(shape.isRectangular() ? null : shape) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1411 |
); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1412 |
} else { |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1413 |
XlibWrapper.SetRectangularShape( |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1414 |
XToolkit.getDisplay(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1415 |
getWindow(), |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1416 |
0, 0, |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1417 |
0, 0, |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1418 |
null |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1419 |
); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
887
diff
changeset
|
1420 |
} |
2 | 1421 |
} finally { |
1422 |
XToolkit.awtUnlock(); |
|
1423 |
} |
|
1424 |
} else { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16843
diff
changeset
|
1425 |
if (shapeLog.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 1426 |
shapeLog.finer("*** WARNING: Shaping is NOT supported!"); |
1427 |
} |
|
1428 |
} |
|
1429 |
} |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2458
diff
changeset
|
1430 |
|
2805
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1431 |
public boolean updateGraphicsData(GraphicsConfiguration gc) { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1432 |
int oldVisual = -1, newVisual = -1; |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1433 |
|
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1434 |
if (graphicsConfig != null) { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1435 |
oldVisual = graphicsConfig.getVisual(); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1436 |
} |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1437 |
if (gc != null && gc instanceof X11GraphicsConfig) { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1438 |
newVisual = ((X11GraphicsConfig)gc).getVisual(); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1439 |
} |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1440 |
|
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1441 |
// If the new visual differs from the old one, the peer must be |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1442 |
// recreated because X11 does not allow changing the visual on the fly. |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1443 |
// So we even skip the initGraphicsConfiguration() call. |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1444 |
// The initial assignment should happen though, hence the != -1 thing. |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1445 |
if (oldVisual != -1 && oldVisual != newVisual) { |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1446 |
return true; |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1447 |
} |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1448 |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2458
diff
changeset
|
1449 |
initGraphicsConfiguration(); |
2805
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1450 |
doValidateSurface(); |
9f18d7e66042
6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents:
2464
diff
changeset
|
1451 |
return false; |
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2458
diff
changeset
|
1452 |
} |
2 | 1453 |
} |