author | bagiras |
Thu, 30 Aug 2012 13:11:23 -0700 | |
changeset 13604 | 31089af1a447 |
parent 11083 | 34aa99149ff2 |
child 13656 | 776ac504ea9b |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9002 | 2 |
* Copyright (c) 2002, 2011, 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.*; |
|
107 | 28 |
import java.awt.event.InputEvent; |
29 |
import java.awt.event.MouseEvent; |
|
1966
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
30 |
import java.awt.event.KeyEvent; |
107 | 31 |
import java.awt.datatransfer.Clipboard; |
2 | 32 |
import java.awt.dnd.DragSource; |
33 |
import java.awt.dnd.DragGestureListener; |
|
34 |
import java.awt.dnd.DragGestureEvent; |
|
35 |
import java.awt.dnd.DragGestureRecognizer; |
|
36 |
import java.awt.dnd.MouseDragGestureRecognizer; |
|
37 |
import java.awt.dnd.InvalidDnDOperationException; |
|
38 |
import java.awt.dnd.peer.DragSourceContextPeer; |
|
39 |
import java.awt.im.InputMethodHighlight; |
|
40 |
import java.awt.im.spi.InputMethodDescriptor; |
|
107 | 41 |
import java.awt.image.ColorModel; |
42 |
import java.awt.peer.*; |
|
43 |
import java.beans.PropertyChangeListener; |
|
44 |
import java.security.AccessController; |
|
45 |
import java.security.PrivilegedAction; |
|
46 |
import java.util.*; |
|
2 | 47 |
import javax.swing.LookAndFeel; |
48 |
import javax.swing.UIDefaults; |
|
107 | 49 |
import sun.awt.*; |
3928 | 50 |
import sun.font.FontConfigManager; |
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
51 |
import sun.java2d.SunGraphicsEnvironment; |
2 | 52 |
import sun.misc.PerformanceLogger; |
53 |
import sun.print.PrintJob2D; |
|
13604 | 54 |
import sun.security.action.GetPropertyAction; |
2471
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
55 |
import sun.security.action.GetBooleanAction; |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
56 |
import sun.util.logging.PlatformLogger; |
2 | 57 |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
58 |
public final class XToolkit extends UNIXToolkit implements Runnable { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
59 |
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XToolkit"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
60 |
private static final PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XToolkit"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
61 |
private static final PlatformLogger timeoutTaskLog = PlatformLogger.getLogger("sun.awt.X11.timeoutTask.XToolkit"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
62 |
private static final PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XToolkit"); |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
63 |
private static final PlatformLogger backingStoreLog = PlatformLogger.getLogger("sun.awt.X11.backingStore.XToolkit"); |
2 | 64 |
|
1969
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
65 |
//There is 400 ms is set by default on Windows and 500 by default on KDE and GNOME. |
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
66 |
//We use the same hardcoded constant. |
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
67 |
private final static int AWT_MULTICLICK_DEFAULT_TIME = 500; |
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
68 |
|
2 | 69 |
static final boolean PRIMARY_LOOP = false; |
70 |
static final boolean SECONDARY_LOOP = true; |
|
71 |
||
72 |
private static String awtAppClassName = null; |
|
73 |
||
74 |
// the system clipboard - CLIPBOARD selection |
|
75 |
XClipboard clipboard; |
|
76 |
// the system selection - PRIMARY selection |
|
77 |
XClipboard selection; |
|
78 |
||
79 |
// Dynamic Layout Resize client code setting |
|
80 |
protected static boolean dynamicLayoutSetting = false; |
|
81 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
82 |
//Is it allowed to generate events assigned to extra mouse buttons. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
83 |
//Set to true by default. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
84 |
private static boolean areExtraMouseButtonsEnabled = true; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
85 |
|
2 | 86 |
/** |
87 |
* True when the x settings have been loaded. |
|
88 |
*/ |
|
89 |
private boolean loadedXSettings; |
|
90 |
||
91 |
/** |
|
92 |
* XSETTINGS for the default screen. |
|
93 |
* <p> |
|
94 |
*/ |
|
95 |
private XSettings xs; |
|
96 |
||
3928 | 97 |
private FontConfigManager fcManager = new FontConfigManager(); |
98 |
||
2 | 99 |
static int arrowCursor; |
100 |
static TreeMap winMap = new TreeMap(); |
|
101 |
static HashMap specialPeerMap = new HashMap(); |
|
102 |
static HashMap winToDispatcher = new HashMap(); |
|
103 |
private static long _display; |
|
104 |
static UIDefaults uidefaults; |
|
105 |
static X11GraphicsEnvironment localEnv; |
|
106 |
static X11GraphicsDevice device; |
|
107 |
static final X11GraphicsConfig config; |
|
108 |
static int awt_multiclick_time; |
|
109 |
static boolean securityWarningEnabled; |
|
110 |
||
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
111 |
private static volatile int screenWidth = -1, screenHeight = -1; // Dimensions of default screen |
2 | 112 |
static long awt_defaultFg; // Pixel |
113 |
private static XMouseInfoPeer xPeer; |
|
114 |
||
115 |
static { |
|
116 |
initSecurityWarning(); |
|
117 |
if (GraphicsEnvironment.isHeadless()) { |
|
118 |
config = null; |
|
119 |
} else { |
|
120 |
localEnv = (X11GraphicsEnvironment) GraphicsEnvironment |
|
121 |
.getLocalGraphicsEnvironment(); |
|
122 |
device = (X11GraphicsDevice) localEnv.getDefaultScreenDevice(); |
|
123 |
config = (X11GraphicsConfig) (device.getDefaultConfiguration()); |
|
124 |
if (device != null) { |
|
125 |
_display = device.getDisplay(); |
|
126 |
} |
|
127 |
setupModifierMap(); |
|
128 |
initIDs(); |
|
129 |
setBackingStoreType(); |
|
130 |
} |
|
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
131 |
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler")); |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
132 |
} |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
133 |
|
9002 | 134 |
/* |
135 |
* Return (potentially) platform specific display timeout for the |
|
136 |
* tray icon |
|
137 |
*/ |
|
138 |
static native long getTrayIconDisplayTimeout(); |
|
139 |
||
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
140 |
//---- ERROR HANDLER CODE ----// |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
141 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
142 |
/* |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
143 |
* Error handler at the moment of XToolkit initialization |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
144 |
*/ |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
145 |
private static long saved_error_handler; |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
146 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
147 |
/* |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
148 |
* XErrorEvent being handled |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
149 |
*/ |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
150 |
static volatile XErrorEvent saved_error; |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
151 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
152 |
/* |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
153 |
* Current error handler or null if no error handler is set |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
154 |
*/ |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
155 |
private static XErrorHandler current_error_handler; |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
156 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
157 |
/* |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
158 |
* Value of sun.awt.noisyerrorhandler system property |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
159 |
*/ |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
160 |
private static boolean noisyAwtHandler; |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
161 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
162 |
public static void WITH_XERROR_HANDLER(XErrorHandler handler) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
163 |
saved_error = null; |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
164 |
current_error_handler = handler; |
2 | 165 |
} |
166 |
||
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
167 |
public static void RESTORE_XERROR_HANDLER() { |
3728
d4b5b18ac3eb
6854898: Frame is located at the negative coordinates instead of origin for Solaris 10 CDE
dcherepanov
parents:
3088
diff
changeset
|
168 |
// wait until all requests are processed by the X server |
d4b5b18ac3eb
6854898: Frame is located at the negative coordinates instead of origin for Solaris 10 CDE
dcherepanov
parents:
3088
diff
changeset
|
169 |
// and only then uninstall the error handler |
d4b5b18ac3eb
6854898: Frame is located at the negative coordinates instead of origin for Solaris 10 CDE
dcherepanov
parents:
3088
diff
changeset
|
170 |
XSync(); |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
171 |
current_error_handler = null; |
2 | 172 |
} |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
173 |
|
2 | 174 |
// Should be called under LOCK |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
175 |
public static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
176 |
if (saved_error_handler != 0) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
177 |
// Default XErrorHandler may just terminate the process. Don't call it. |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
178 |
// return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData); |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
179 |
} |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
180 |
if (log.isLoggable(PlatformLogger.FINE)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
181 |
log.fine("Unhandled XErrorEvent: " + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
182 |
"id=" + error.get_resourceid() + ", " + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
183 |
"serial=" + error.get_serial() + ", " + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
184 |
"ec=" + error.get_error_code() + ", " + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
185 |
"rc=" + error.get_request_code() + ", " + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
186 |
"mc=" + error.get_minor_code()); |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
187 |
} |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
188 |
return 0; |
2 | 189 |
} |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
190 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
191 |
// Called from the native code when an error occurs |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
192 |
private static int globalErrorHandler(long display, long event_ptr) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
193 |
if (noisyAwtHandler) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
194 |
XlibWrapper.PrintXErrorEvent(display, event_ptr); |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
195 |
} |
2 | 196 |
XErrorEvent event = new XErrorEvent(event_ptr); |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
197 |
saved_error = event; |
2 | 198 |
try { |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
199 |
if (current_error_handler != null) { |
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
200 |
return current_error_handler.handleError(display, event); |
2 | 201 |
} else { |
202 |
return SAVED_ERROR_HANDLER(display, event); |
|
203 |
} |
|
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
204 |
} catch (Throwable z) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
205 |
log.fine("Error in GlobalErrorHandler", z); |
2 | 206 |
} |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
207 |
return 0; |
2 | 208 |
} |
209 |
||
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
210 |
//---- END OF ERROR HANDLER CODE ----// |
2 | 211 |
|
212 |
private native static void initIDs(); |
|
213 |
native static void waitForEvents(long nextTaskTime); |
|
214 |
static Thread toolkitThread; |
|
215 |
static boolean isToolkitThread() { |
|
216 |
return Thread.currentThread() == toolkitThread; |
|
217 |
} |
|
218 |
||
219 |
static void initSecurityWarning() { |
|
220 |
// Enable warning only for internal builds |
|
13604 | 221 |
String runtime = AccessController.doPrivileged( |
222 |
new GetPropertyAction("java.runtime.version")); |
|
2 | 223 |
securityWarningEnabled = (runtime != null && runtime.contains("internal")); |
224 |
} |
|
225 |
||
226 |
static boolean isSecurityWarningEnabled() { |
|
227 |
return securityWarningEnabled; |
|
228 |
} |
|
229 |
||
230 |
static native void awt_output_flush(); |
|
231 |
||
232 |
static final void awtFUnlock() { |
|
233 |
awtUnlock(); |
|
234 |
awt_output_flush(); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
public native void nativeLoadSystemColors(int[] systemColors); |
|
239 |
||
240 |
static UIDefaults getUIDefaults() { |
|
241 |
if (uidefaults == null) { |
|
242 |
initUIDefaults(); |
|
243 |
} |
|
244 |
return uidefaults; |
|
245 |
} |
|
246 |
||
247 |
public void loadSystemColors(int[] systemColors) { |
|
248 |
nativeLoadSystemColors(systemColors); |
|
249 |
MotifColorUtilities.loadSystemColors(systemColors); |
|
250 |
} |
|
251 |
||
252 |
||
253 |
||
254 |
static void initUIDefaults() { |
|
255 |
try { |
|
256 |
// Load Defaults from MotifLookAndFeel |
|
257 |
||
258 |
// This dummy load is necessary to get SystemColor initialized. !!!!!! |
|
259 |
Color c = SystemColor.text; |
|
260 |
||
261 |
LookAndFeel lnf = new XAWTLookAndFeel(); |
|
262 |
uidefaults = lnf.getDefaults(); |
|
263 |
} |
|
264 |
catch (Exception e) |
|
265 |
{ |
|
266 |
e.printStackTrace(); |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
static Object displayLock = new Object(); |
|
271 |
||
272 |
public static long getDisplay() { |
|
273 |
return _display; |
|
274 |
} |
|
275 |
||
276 |
public static long getDefaultRootWindow() { |
|
277 |
awtLock(); |
|
278 |
try { |
|
279 |
long res = XlibWrapper.RootWindow(XToolkit.getDisplay(), |
|
280 |
XlibWrapper.DefaultScreen(XToolkit.getDisplay())); |
|
281 |
||
282 |
if (res == 0) { |
|
283 |
throw new IllegalStateException("Root window must not be null"); |
|
284 |
} |
|
285 |
return res; |
|
286 |
} finally { |
|
287 |
awtUnlock(); |
|
288 |
} |
|
289 |
} |
|
290 |
||
291 |
void init() { |
|
292 |
awtLock(); |
|
293 |
try { |
|
294 |
XlibWrapper.XSupportsLocale(); |
|
295 |
if (XlibWrapper.XSetLocaleModifiers("") == null) { |
|
296 |
log.finer("X locale modifiers are not supported, using default"); |
|
297 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
298 |
tryXKB(); |
2 | 299 |
|
300 |
AwtScreenData defaultScreen = new AwtScreenData(XToolkit.getDefaultScreenData()); |
|
301 |
awt_defaultFg = defaultScreen.get_blackpixel(); |
|
302 |
||
303 |
arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(), |
|
304 |
XCursorFontConstants.XC_arrow); |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
305 |
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true")); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
306 |
//set system property if not yet assigned |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
307 |
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled); |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
308 |
|
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
309 |
saved_error_handler = XlibWrapper.SetToolkitErrorHandler(); |
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
310 |
|
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
311 |
// Detect display mode changes |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
312 |
XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
313 |
XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
314 |
@Override |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
315 |
public void dispatchEvent(XEvent ev) { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
316 |
if (ev.get_type() == XConstants.ConfigureNotify) { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
317 |
((X11GraphicsEnvironment)GraphicsEnvironment. |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
318 |
getLocalGraphicsEnvironment()). |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
319 |
displayChanged(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
320 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
321 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
322 |
}); |
2 | 323 |
} finally { |
324 |
awtUnlock(); |
|
325 |
} |
|
5275
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
326 |
PrivilegedAction<Void> a = new PrivilegedAction<Void>() { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
327 |
public Void run() { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
328 |
ThreadGroup mainTG = Thread.currentThread().getThreadGroup(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
329 |
ThreadGroup parentTG = mainTG.getParent(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
330 |
while (parentTG != null) { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
331 |
mainTG = parentTG; |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
332 |
parentTG = mainTG.getParent(); |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
333 |
} |
5275
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
334 |
Thread shutdownThread = new Thread(mainTG, "XToolkt-Shutdown-Thread") { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
335 |
public void run() { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
336 |
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
337 |
if (peer != null) { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
338 |
peer.dispose(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
339 |
} |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
340 |
if (xs != null) { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
341 |
((XAWTXSettings)xs).dispose(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
342 |
} |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
343 |
freeXKB(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
344 |
if (log.isLoggable(PlatformLogger.FINE)) { |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
345 |
dumpPeers(); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
346 |
} |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
347 |
} |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
348 |
}; |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
349 |
shutdownThread.setContextClassLoader(null); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
350 |
Runtime.getRuntime().addShutdownHook(shutdownThread); |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
351 |
return null; |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2660
diff
changeset
|
352 |
} |
5275
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
353 |
}; |
fa9f5ce2006e
6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents:
4376
diff
changeset
|
354 |
AccessController.doPrivileged(a); |
2 | 355 |
} |
356 |
||
357 |
static String getCorrectXIDString(String val) { |
|
358 |
if (val != null) { |
|
359 |
return val.replace('.', '-'); |
|
360 |
} else { |
|
361 |
return val; |
|
362 |
} |
|
363 |
} |
|
364 |
||
365 |
static native String getEnv(String key); |
|
366 |
||
367 |
||
368 |
static String getAWTAppClassName() { |
|
369 |
return awtAppClassName; |
|
370 |
} |
|
371 |
||
372 |
static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer"; |
|
373 |
||
374 |
public XToolkit() { |
|
375 |
super(); |
|
376 |
if (PerformanceLogger.loggingEnabled()) { |
|
377 |
PerformanceLogger.setTime("XToolkit construction"); |
|
378 |
} |
|
379 |
||
380 |
if (!GraphicsEnvironment.isHeadless()) { |
|
381 |
String mainClassName = null; |
|
382 |
||
383 |
StackTraceElement trace[] = (new Throwable()).getStackTrace(); |
|
384 |
int bottom = trace.length - 1; |
|
385 |
if (bottom >= 0) { |
|
386 |
mainClassName = trace[bottom].getClassName(); |
|
387 |
} |
|
388 |
if (mainClassName == null || mainClassName.equals("")) { |
|
389 |
mainClassName = "AWT"; |
|
390 |
} |
|
391 |
awtAppClassName = getCorrectXIDString(mainClassName); |
|
392 |
||
393 |
init(); |
|
394 |
XWM.init(); |
|
395 |
SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME); |
|
6820
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
396 |
|
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
397 |
PrivilegedAction<Thread> action = new PrivilegedAction() { |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
398 |
public Thread run() { |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
399 |
ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
400 |
ThreadGroup parentTG = currentTG.getParent(); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
401 |
while (parentTG != null) { |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
402 |
currentTG = parentTG; |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
403 |
parentTG = currentTG.getParent(); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
404 |
} |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
405 |
Thread thread = new Thread(currentTG, XToolkit.this, "AWT-XAWT"); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
406 |
thread.setPriority(Thread.NORM_PRIORITY + 1); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
407 |
thread.setDaemon(true); |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
408 |
return thread; |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
409 |
} |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
410 |
}; |
bd6e9b4e1460
6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents:
6642
diff
changeset
|
411 |
toolkitThread = AccessController.doPrivileged(action); |
2 | 412 |
toolkitThread.start(); |
413 |
} |
|
414 |
} |
|
415 |
||
416 |
public ButtonPeer createButton(Button target) { |
|
417 |
ButtonPeer peer = new XButtonPeer(target); |
|
418 |
targetCreatedPeer(target, peer); |
|
419 |
return peer; |
|
420 |
} |
|
421 |
||
422 |
public FramePeer createFrame(Frame target) { |
|
423 |
FramePeer peer = new XFramePeer(target); |
|
424 |
targetCreatedPeer(target, peer); |
|
425 |
return peer; |
|
426 |
} |
|
427 |
||
428 |
static void addToWinMap(long window, XBaseWindow xwin) |
|
429 |
{ |
|
430 |
synchronized(winMap) { |
|
431 |
winMap.put(Long.valueOf(window),xwin); |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
static void removeFromWinMap(long window, XBaseWindow xwin) { |
|
436 |
synchronized(winMap) { |
|
437 |
winMap.remove(Long.valueOf(window)); |
|
438 |
} |
|
439 |
} |
|
440 |
static XBaseWindow windowToXWindow(long window) { |
|
441 |
synchronized(winMap) { |
|
442 |
return (XBaseWindow) winMap.get(Long.valueOf(window)); |
|
443 |
} |
|
444 |
} |
|
445 |
||
446 |
static void addEventDispatcher(long window, XEventDispatcher dispatcher) { |
|
447 |
synchronized(winToDispatcher) { |
|
448 |
Long key = Long.valueOf(window); |
|
449 |
Collection dispatchers = (Collection)winToDispatcher.get(key); |
|
450 |
if (dispatchers == null) { |
|
451 |
dispatchers = new Vector(); |
|
452 |
winToDispatcher.put(key, dispatchers); |
|
453 |
} |
|
454 |
dispatchers.add(dispatcher); |
|
455 |
} |
|
456 |
} |
|
457 |
static void removeEventDispatcher(long window, XEventDispatcher dispatcher) { |
|
458 |
synchronized(winToDispatcher) { |
|
459 |
Long key = Long.valueOf(window); |
|
460 |
Collection dispatchers = (Collection)winToDispatcher.get(key); |
|
461 |
if (dispatchers != null) { |
|
462 |
dispatchers.remove(dispatcher); |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
||
467 |
private Point lastCursorPos; |
|
468 |
||
469 |
/** |
|
470 |
* Returns whether there is last remembered cursor position. The |
|
471 |
* position is remembered from X mouse events on our peers. The |
|
472 |
* position is stored in <code>p</code>. |
|
473 |
* @return true, if there is remembered last cursor position, |
|
474 |
* false otherwise |
|
475 |
*/ |
|
476 |
boolean getLastCursorPos(Point p) { |
|
477 |
awtLock(); |
|
478 |
try { |
|
479 |
if (lastCursorPos == null) { |
|
480 |
return false; |
|
481 |
} |
|
482 |
p.setLocation(lastCursorPos); |
|
483 |
return true; |
|
484 |
} finally { |
|
485 |
awtUnlock(); |
|
486 |
} |
|
487 |
} |
|
488 |
||
489 |
private void processGlobalMotionEvent(XEvent e) { |
|
490 |
// Only our windows guaranteely generate MotionNotify, so we |
|
491 |
// should track enter/leave, to catch the moment when to |
|
492 |
// switch to XQueryPointer |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
493 |
if (e.get_type() == XConstants.MotionNotify) { |
2 | 494 |
XMotionEvent ev = e.get_xmotion(); |
495 |
awtLock(); |
|
496 |
try { |
|
497 |
if (lastCursorPos == null) { |
|
498 |
lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root()); |
|
499 |
} else { |
|
500 |
lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root()); |
|
501 |
} |
|
502 |
} finally { |
|
503 |
awtUnlock(); |
|
504 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
505 |
} else if (e.get_type() == XConstants.LeaveNotify) { |
2 | 506 |
// Leave from our window |
507 |
awtLock(); |
|
508 |
try { |
|
509 |
lastCursorPos = null; |
|
510 |
} finally { |
|
511 |
awtUnlock(); |
|
512 |
} |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
513 |
} else if (e.get_type() == XConstants.EnterNotify) { |
2 | 514 |
// Entrance into our window |
515 |
XCrossingEvent ev = e.get_xcrossing(); |
|
516 |
awtLock(); |
|
517 |
try { |
|
518 |
if (lastCursorPos == null) { |
|
519 |
lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root()); |
|
520 |
} else { |
|
521 |
lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root()); |
|
522 |
} |
|
523 |
} finally { |
|
524 |
awtUnlock(); |
|
525 |
} |
|
526 |
} |
|
527 |
} |
|
528 |
||
529 |
public interface XEventListener { |
|
530 |
public void eventProcessed(XEvent e); |
|
531 |
} |
|
532 |
||
533 |
private Collection<XEventListener> listeners = new LinkedList<XEventListener>(); |
|
534 |
||
535 |
public void addXEventListener(XEventListener listener) { |
|
536 |
synchronized (listeners) { |
|
537 |
listeners.add(listener); |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
private void notifyListeners(XEvent xev) { |
|
542 |
synchronized (listeners) { |
|
543 |
if (listeners.size() == 0) return; |
|
544 |
||
545 |
XEvent copy = xev.clone(); |
|
546 |
try { |
|
547 |
for (XEventListener listener : listeners) { |
|
548 |
listener.eventProcessed(copy); |
|
549 |
} |
|
550 |
} finally { |
|
551 |
copy.dispose(); |
|
552 |
} |
|
553 |
} |
|
554 |
} |
|
555 |
||
556 |
private void dispatchEvent(XEvent ev) { |
|
557 |
final XAnyEvent xany = ev.get_xany(); |
|
558 |
||
559 |
if (windowToXWindow(xany.get_window()) != null && |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
560 |
(ev.get_type() == XConstants.MotionNotify || ev.get_type() == XConstants.EnterNotify || ev.get_type() == XConstants.LeaveNotify)) |
2 | 561 |
{ |
562 |
processGlobalMotionEvent(ev); |
|
563 |
} |
|
564 |
||
4370
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
565 |
if( ev.get_type() == XConstants.MappingNotify ) { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
566 |
// The 'window' field in this event is unused. |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
567 |
// This application itself does nothing to initiate such an event |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
568 |
// (no calls of XChangeKeyboardMapping etc.). |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
569 |
// SunRay server sends this event to the application once on every |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
570 |
// keyboard (not just layout) change which means, quite seldom. |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
571 |
XlibWrapper.XRefreshKeyboardMapping(ev.pData); |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
572 |
resetKeyboardSniffer(); |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
573 |
setupModifierMap(); |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
574 |
} |
2 | 575 |
XBaseWindow.dispatchToWindow(ev); |
576 |
||
577 |
Collection dispatchers = null; |
|
578 |
synchronized(winToDispatcher) { |
|
579 |
Long key = Long.valueOf(xany.get_window()); |
|
580 |
dispatchers = (Collection)winToDispatcher.get(key); |
|
581 |
if (dispatchers != null) { // Clone it to avoid synchronization during dispatching |
|
582 |
dispatchers = new Vector(dispatchers); |
|
583 |
} |
|
584 |
} |
|
585 |
if (dispatchers != null) { |
|
586 |
Iterator iter = dispatchers.iterator(); |
|
587 |
while (iter.hasNext()) { |
|
588 |
XEventDispatcher disp = (XEventDispatcher)iter.next(); |
|
589 |
disp.dispatchEvent(ev); |
|
590 |
} |
|
591 |
} |
|
592 |
notifyListeners(ev); |
|
593 |
} |
|
594 |
||
595 |
static void processException(Throwable thr) { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
596 |
if (log.isLoggable(PlatformLogger.WARNING)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
597 |
log.warning("Exception on Toolkit thread", thr); |
2 | 598 |
} |
599 |
} |
|
600 |
||
601 |
static native void awt_toolkit_init(); |
|
602 |
||
603 |
public void run() { |
|
604 |
awt_toolkit_init(); |
|
605 |
run(PRIMARY_LOOP); |
|
606 |
} |
|
607 |
||
608 |
public void run(boolean loop) |
|
609 |
{ |
|
610 |
XEvent ev = new XEvent(); |
|
611 |
while(true) { |
|
2650
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
612 |
// Fix for 6829923: we should gracefully handle toolkit thread interruption |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
613 |
if (Thread.currentThread().isInterrupted()) { |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
614 |
// We expect interruption from the AppContext.dispose() method only. |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
615 |
// If the thread is interrupted from another place, let's skip it |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
616 |
// for compatibility reasons. Probably some time later we'll remove |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
617 |
// the check for AppContext.isDisposed() and will unconditionally |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
618 |
// break the loop here. |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
619 |
if (AppContext.getAppContext().isDisposed()) { |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
620 |
break; |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
621 |
} |
44d88464a573
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
art
parents:
1970
diff
changeset
|
622 |
} |
2 | 623 |
awtLock(); |
624 |
try { |
|
625 |
if (loop == SECONDARY_LOOP) { |
|
626 |
// In the secondary loop we may have already aquired awt_lock |
|
627 |
// several times, so waitForEvents() might be unable to release |
|
628 |
// the awt_lock and this causes lock up. |
|
629 |
// For now, we just avoid waitForEvents in the secondary loop. |
|
630 |
if (!XlibWrapper.XNextSecondaryLoopEvent(getDisplay(),ev.pData)) { |
|
631 |
break; |
|
632 |
} |
|
633 |
} else { |
|
634 |
callTimeoutTasks(); |
|
635 |
// If no events are queued, waitForEvents() causes calls to |
|
636 |
// awtUnlock(), awtJNI_ThreadYield, poll, awtLock(), |
|
637 |
// so it spends most of its time in poll, without holding the lock. |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
638 |
while ((XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterReading) == 0) && |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
639 |
(XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterFlush) == 0)) { |
2 | 640 |
callTimeoutTasks(); |
641 |
waitForEvents(getNextTaskTime()); |
|
642 |
} |
|
643 |
XlibWrapper.XNextEvent(getDisplay(),ev.pData); |
|
644 |
} |
|
645 |
||
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
646 |
if (ev.get_type() != XConstants.NoExpose) { |
2 | 647 |
eventNumber++; |
648 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
649 |
if (awt_UseXKB_Calls && ev.get_type() == awt_XKBBaseEventCode) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
650 |
processXkbChanges(ev); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
651 |
} |
2 | 652 |
|
653 |
if (XDropTargetEventProcessor.processEvent(ev) || |
|
654 |
XDragSourceContextPeer.processEvent(ev)) { |
|
655 |
continue; |
|
656 |
} |
|
657 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
658 |
if (eventLog.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
659 |
eventLog.finer("{0}", ev); |
2 | 660 |
} |
661 |
||
662 |
// Check if input method consumes the event |
|
663 |
long w = 0; |
|
664 |
if (windowToXWindow(ev.get_xany().get_window()) != null) { |
|
665 |
Component owner = |
|
666 |
XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner(); |
|
667 |
if (owner != null) { |
|
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
668 |
XWindow ownerWindow = (XWindow) AWTAccessor.getComponentAccessor().getPeer(owner); |
2 | 669 |
if (ownerWindow != null) { |
670 |
w = ownerWindow.getContentWindow(); |
|
671 |
} |
|
672 |
} |
|
673 |
} |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
674 |
if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { |
2 | 675 |
keyEventLog.fine("before XFilterEvent:"+ev); |
676 |
} |
|
677 |
if (XlibWrapper.XFilterEvent(ev.getPData(), w)) { |
|
678 |
continue; |
|
679 |
} |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
680 |
if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { |
2 | 681 |
keyEventLog.fine("after XFilterEvent:"+ev); // IS THIS CORRECT? |
682 |
} |
|
683 |
||
684 |
dispatchEvent(ev); |
|
685 |
} catch (ThreadDeath td) { |
|
686 |
XBaseWindow.ungrabInput(); |
|
687 |
return; |
|
688 |
} catch (Throwable thr) { |
|
689 |
XBaseWindow.ungrabInput(); |
|
690 |
processException(thr); |
|
691 |
} finally { |
|
692 |
awtUnlock(); |
|
693 |
} |
|
694 |
} |
|
695 |
} |
|
696 |
||
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
697 |
static { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
698 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
699 |
if (ge instanceof SunGraphicsEnvironment) { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
700 |
((SunGraphicsEnvironment)ge).addDisplayChangedListener( |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
701 |
new DisplayChangedListener() { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
702 |
@Override |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
703 |
public void displayChanged() { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
704 |
// 7045370: Reset the cached values |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
705 |
XToolkit.screenWidth = -1; |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
706 |
XToolkit.screenHeight = -1; |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
707 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
708 |
|
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
709 |
@Override |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
710 |
public void paletteChanged() {} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
711 |
}); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
712 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
713 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
714 |
|
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
715 |
private static void initScreenSize() { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
716 |
if (screenWidth == -1 || screenHeight == -1) { |
2 | 717 |
awtLock(); |
718 |
try { |
|
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
719 |
XWindowAttributes pattr = new XWindowAttributes(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
720 |
try { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
721 |
XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
722 |
screenWidth = (int) pattr.get_width(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
723 |
screenHeight = (int) pattr.get_height(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
724 |
} finally { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
725 |
pattr.dispose(); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
726 |
} |
2 | 727 |
} finally { |
728 |
awtUnlock(); |
|
729 |
} |
|
730 |
} |
|
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
731 |
} |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
732 |
|
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
733 |
static int getDefaultScreenWidth() { |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
734 |
initScreenSize(); |
2 | 735 |
return screenWidth; |
736 |
} |
|
737 |
||
738 |
static int getDefaultScreenHeight() { |
|
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
10319
diff
changeset
|
739 |
initScreenSize(); |
2 | 740 |
return screenHeight; |
741 |
} |
|
742 |
||
743 |
protected int getScreenWidth() { |
|
744 |
return getDefaultScreenWidth(); |
|
745 |
} |
|
746 |
||
747 |
protected int getScreenHeight() { |
|
748 |
return getDefaultScreenHeight(); |
|
749 |
} |
|
750 |
||
751 |
private static Rectangle getWorkArea(long root) |
|
752 |
{ |
|
753 |
XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA"); |
|
754 |
||
755 |
long native_ptr = Native.allocateLongArray(4); |
|
756 |
try |
|
757 |
{ |
|
758 |
boolean workareaPresent = XA_NET_WORKAREA.getAtomData(root, |
|
759 |
XAtom.XA_CARDINAL, native_ptr, 4); |
|
760 |
if (workareaPresent) |
|
761 |
{ |
|
762 |
int rootX = (int)Native.getLong(native_ptr, 0); |
|
763 |
int rootY = (int)Native.getLong(native_ptr, 1); |
|
764 |
int rootWidth = (int)Native.getLong(native_ptr, 2); |
|
765 |
int rootHeight = (int)Native.getLong(native_ptr, 3); |
|
766 |
||
767 |
return new Rectangle(rootX, rootY, rootWidth, rootHeight); |
|
768 |
} |
|
769 |
} |
|
770 |
finally |
|
771 |
{ |
|
772 |
XlibWrapper.unsafe.freeMemory(native_ptr); |
|
773 |
} |
|
774 |
||
775 |
return null; |
|
776 |
} |
|
777 |
||
778 |
/* |
|
779 |
* If we're running in non-Xinerama environment and the current |
|
780 |
* window manager supports _NET protocol then the screen insets |
|
781 |
* are calculated using _NET_WM_WORKAREA property of the root |
|
782 |
* window. |
|
783 |
* Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is |
|
784 |
* not set, we try to calculate the insets ourselves using |
|
785 |
* getScreenInsetsManually method. |
|
786 |
*/ |
|
787 |
public Insets getScreenInsets(GraphicsConfiguration gc) |
|
788 |
{ |
|
789 |
XNETProtocol netProto = XWM.getWM().getNETProtocol(); |
|
790 |
if ((netProto == null) || !netProto.active()) |
|
791 |
{ |
|
792 |
return super.getScreenInsets(gc); |
|
793 |
} |
|
794 |
||
795 |
XToolkit.awtLock(); |
|
796 |
try |
|
797 |
{ |
|
798 |
X11GraphicsConfig x11gc = (X11GraphicsConfig)gc; |
|
799 |
X11GraphicsDevice x11gd = (X11GraphicsDevice)x11gc.getDevice(); |
|
800 |
long root = XlibUtil.getRootWindow(x11gd.getScreen()); |
|
801 |
Rectangle rootBounds = XlibUtil.getWindowGeometry(root); |
|
802 |
||
803 |
X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment) |
|
804 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
805 |
if (!x11ge.runningXinerama()) |
|
806 |
{ |
|
807 |
Rectangle workArea = XToolkit.getWorkArea(root); |
|
808 |
if (workArea != null) |
|
809 |
{ |
|
810 |
return new Insets(workArea.y, |
|
811 |
workArea.x, |
|
812 |
rootBounds.height - workArea.height - workArea.y, |
|
813 |
rootBounds.width - workArea.width - workArea.x); |
|
814 |
} |
|
815 |
} |
|
816 |
||
817 |
return getScreenInsetsManually(root, rootBounds, gc.getBounds()); |
|
818 |
} |
|
819 |
finally |
|
820 |
{ |
|
821 |
XToolkit.awtUnlock(); |
|
822 |
} |
|
823 |
} |
|
824 |
||
825 |
/* |
|
826 |
* Manual calculation of screen insets: get all the windows with |
|
827 |
* _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL hints and add these |
|
828 |
* hints' values to screen insets. |
|
829 |
* |
|
830 |
* This method should be called under XToolkit.awtLock() |
|
831 |
*/ |
|
832 |
private Insets getScreenInsetsManually(long root, Rectangle rootBounds, Rectangle screenBounds) |
|
833 |
{ |
|
834 |
/* |
|
835 |
* During the manual calculation of screen insets we iterate |
|
836 |
* all the X windows hierarchy starting from root window. This |
|
837 |
* constant is the max level inspected in this hierarchy. |
|
838 |
* 3 is a heuristic value: I suppose any the toolbar-like |
|
839 |
* window is a child of either root or desktop window. |
|
840 |
*/ |
|
841 |
final int MAX_NESTED_LEVEL = 3; |
|
842 |
||
843 |
XAtom XA_NET_WM_STRUT = XAtom.get("_NET_WM_STRUT"); |
|
844 |
XAtom XA_NET_WM_STRUT_PARTIAL = XAtom.get("_NET_WM_STRUT_PARTIAL"); |
|
845 |
||
846 |
Insets insets = new Insets(0, 0, 0, 0); |
|
847 |
||
848 |
java.util.List search = new LinkedList(); |
|
849 |
search.add(root); |
|
850 |
search.add(0); |
|
851 |
while (!search.isEmpty()) |
|
852 |
{ |
|
853 |
long window = (Long)search.remove(0); |
|
854 |
int windowLevel = (Integer)search.remove(0); |
|
855 |
||
856 |
/* |
|
857 |
* Note that most of the modern window managers unmap |
|
858 |
* application window if it is iconified. Thus, any |
|
859 |
* _NET_WM_STRUT[_PARTIAL] hints for iconified windows |
|
860 |
* are not included to the screen insets. |
|
861 |
*/ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
862 |
if (XlibUtil.getWindowMapState(window) == XConstants.IsUnmapped) |
2 | 863 |
{ |
864 |
continue; |
|
865 |
} |
|
866 |
||
867 |
long native_ptr = Native.allocateLongArray(4); |
|
868 |
try |
|
869 |
{ |
|
870 |
// first, check if _NET_WM_STRUT or _NET_WM_STRUT_PARTIAL are present |
|
871 |
// if both are set on the window, _NET_WM_STRUT_PARTIAL is used (see _NET spec) |
|
872 |
boolean strutPresent = XA_NET_WM_STRUT_PARTIAL.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); |
|
873 |
if (!strutPresent) |
|
874 |
{ |
|
875 |
strutPresent = XA_NET_WM_STRUT.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); |
|
876 |
} |
|
877 |
if (strutPresent) |
|
878 |
{ |
|
879 |
// second, verify that window is located on the proper screen |
|
880 |
Rectangle windowBounds = XlibUtil.getWindowGeometry(window); |
|
881 |
if (windowLevel > 1) |
|
882 |
{ |
|
883 |
windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds); |
|
884 |
} |
|
885 |
// if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect |
|
886 |
// if the struts area intersects with screenBounds, however some window |
|
887 |
// managers don't set this hint correctly, so we just get intersection with windowBounds |
|
5760
4177643566d5
6961754: JCK tests CvsEventTest0001 and CvsEventTest0002 fail under FF 3.5 on OEL 5
anthony
parents:
5758
diff
changeset
|
888 |
if (windowBounds != null && windowBounds.intersects(screenBounds)) |
2 | 889 |
{ |
890 |
insets.left = Math.max((int)Native.getLong(native_ptr, 0), insets.left); |
|
891 |
insets.right = Math.max((int)Native.getLong(native_ptr, 1), insets.right); |
|
892 |
insets.top = Math.max((int)Native.getLong(native_ptr, 2), insets.top); |
|
893 |
insets.bottom = Math.max((int)Native.getLong(native_ptr, 3), insets.bottom); |
|
894 |
} |
|
895 |
} |
|
896 |
} |
|
897 |
finally |
|
898 |
{ |
|
899 |
XlibWrapper.unsafe.freeMemory(native_ptr); |
|
900 |
} |
|
901 |
||
902 |
if (windowLevel < MAX_NESTED_LEVEL) |
|
903 |
{ |
|
904 |
Set<Long> children = XlibUtil.getChildWindows(window); |
|
905 |
for (long child : children) |
|
906 |
{ |
|
907 |
search.add(child); |
|
908 |
search.add(windowLevel + 1); |
|
909 |
} |
|
910 |
} |
|
911 |
} |
|
912 |
||
913 |
return insets; |
|
914 |
} |
|
915 |
||
916 |
/* |
|
917 |
* The current implementation of disabling background erasing for |
|
918 |
* canvases is that we don't set any native background color |
|
919 |
* (with XSetWindowBackground) for the canvas window. However, |
|
920 |
* this color is set in the peer constructor - see |
|
921 |
* XWindow.postInit() for details. That's why this method from |
|
922 |
* SunToolkit is not overridden in XToolkit: it's too late to |
|
923 |
* disable background erasing :( |
|
924 |
*/ |
|
925 |
/* |
|
926 |
@Override |
|
927 |
public void disableBackgroundErase(Canvas canvas) { |
|
928 |
XCanvasPeer peer = (XCanvasPeer)canvas.getPeer(); |
|
929 |
if (peer == null) { |
|
930 |
throw new IllegalStateException("Canvas must have a valid peer"); |
|
931 |
} |
|
932 |
peer.disableBackgroundErase(); |
|
933 |
} |
|
934 |
*/ |
|
935 |
||
936 |
// Need this for XMenuItemPeer. |
|
937 |
protected static final Object targetToPeer(Object target) { |
|
938 |
Object p=null; |
|
939 |
if (target != null && !GraphicsEnvironment.isHeadless()) { |
|
940 |
p = specialPeerMap.get(target); |
|
941 |
} |
|
942 |
if (p != null) return p; |
|
943 |
else |
|
944 |
return SunToolkit.targetToPeer(target); |
|
945 |
} |
|
946 |
||
947 |
// Need this for XMenuItemPeer. |
|
948 |
protected static final void targetDisposedPeer(Object target, Object peer) { |
|
949 |
SunToolkit.targetDisposedPeer(target, peer); |
|
950 |
} |
|
951 |
||
952 |
public RobotPeer createRobot(Robot target, GraphicsDevice screen) { |
|
953 |
return new XRobotPeer(screen.getDefaultConfiguration()); |
|
954 |
} |
|
955 |
||
956 |
||
957 |
/* |
|
958 |
* On X, support for dynamic layout on resizing is governed by the |
|
959 |
* window manager. If the window manager supports it, it happens |
|
960 |
* automatically. The setter method for this property is |
|
961 |
* irrelevant on X. |
|
962 |
*/ |
|
963 |
public void setDynamicLayout(boolean b) { |
|
964 |
dynamicLayoutSetting = b; |
|
965 |
} |
|
966 |
||
967 |
protected boolean isDynamicLayoutSet() { |
|
968 |
return dynamicLayoutSetting; |
|
969 |
} |
|
970 |
||
971 |
/* Called from isDynamicLayoutActive() and from |
|
972 |
* lazilyLoadDynamicLayoutSupportedProperty() |
|
973 |
*/ |
|
974 |
protected boolean isDynamicLayoutSupported() { |
|
975 |
return XWM.getWM().supportsDynamicLayout(); |
|
976 |
} |
|
977 |
||
978 |
public boolean isDynamicLayoutActive() { |
|
979 |
return isDynamicLayoutSupported(); |
|
980 |
} |
|
981 |
||
982 |
||
983 |
public FontPeer getFontPeer(String name, int style){ |
|
984 |
return new XFontPeer(name, style); |
|
985 |
} |
|
986 |
||
987 |
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { |
|
988 |
return XDragSourceContextPeer.createDragSourceContextPeer(dge); |
|
989 |
} |
|
990 |
||
991 |
public <T extends DragGestureRecognizer> T |
|
992 |
createDragGestureRecognizer(Class<T> recognizerClass, |
|
993 |
DragSource ds, |
|
994 |
Component c, |
|
995 |
int srcActions, |
|
996 |
DragGestureListener dgl) |
|
997 |
{ |
|
998 |
if (MouseDragGestureRecognizer.class.equals(recognizerClass)) |
|
999 |
return (T)new XMouseDragGestureRecognizer(ds, c, srcActions, dgl); |
|
1000 |
else |
|
1001 |
return null; |
|
1002 |
} |
|
1003 |
||
1004 |
public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) { |
|
1005 |
XCheckboxMenuItemPeer peer = new XCheckboxMenuItemPeer(target); |
|
1006 |
//vb157120: looks like we don't need to map menu items |
|
1007 |
//in new menus implementation |
|
1008 |
//targetCreatedPeer(target, peer); |
|
1009 |
return peer; |
|
1010 |
} |
|
1011 |
||
1012 |
public MenuItemPeer createMenuItem(MenuItem target) { |
|
1013 |
XMenuItemPeer peer = new XMenuItemPeer(target); |
|
1014 |
//vb157120: looks like we don't need to map menu items |
|
1015 |
//in new menus implementation |
|
1016 |
//targetCreatedPeer(target, peer); |
|
1017 |
return peer; |
|
1018 |
} |
|
1019 |
||
1020 |
public TextFieldPeer createTextField(TextField target) { |
|
1021 |
TextFieldPeer peer = new XTextFieldPeer(target); |
|
1022 |
targetCreatedPeer(target, peer); |
|
1023 |
return peer; |
|
1024 |
} |
|
1025 |
||
1026 |
public LabelPeer createLabel(Label target) { |
|
1027 |
LabelPeer peer = new XLabelPeer(target); |
|
1028 |
targetCreatedPeer(target, peer); |
|
1029 |
return peer; |
|
1030 |
} |
|
1031 |
||
1032 |
public ListPeer createList(java.awt.List target) { |
|
1033 |
ListPeer peer = new XListPeer(target); |
|
1034 |
targetCreatedPeer(target, peer); |
|
1035 |
return peer; |
|
1036 |
} |
|
1037 |
||
1038 |
public CheckboxPeer createCheckbox(Checkbox target) { |
|
1039 |
CheckboxPeer peer = new XCheckboxPeer(target); |
|
1040 |
targetCreatedPeer(target, peer); |
|
1041 |
return peer; |
|
1042 |
} |
|
1043 |
||
1044 |
public ScrollbarPeer createScrollbar(Scrollbar target) { |
|
1045 |
XScrollbarPeer peer = new XScrollbarPeer(target); |
|
1046 |
targetCreatedPeer(target, peer); |
|
1047 |
return peer; |
|
1048 |
} |
|
1049 |
||
1050 |
public ScrollPanePeer createScrollPane(ScrollPane target) { |
|
1051 |
XScrollPanePeer peer = new XScrollPanePeer(target); |
|
1052 |
targetCreatedPeer(target, peer); |
|
1053 |
return peer; |
|
1054 |
} |
|
1055 |
||
1056 |
public TextAreaPeer createTextArea(TextArea target) { |
|
1057 |
TextAreaPeer peer = new XTextAreaPeer(target); |
|
1058 |
targetCreatedPeer(target, peer); |
|
1059 |
return peer; |
|
1060 |
} |
|
1061 |
||
1062 |
public ChoicePeer createChoice(Choice target) { |
|
1063 |
XChoicePeer peer = new XChoicePeer(target); |
|
1064 |
targetCreatedPeer(target, peer); |
|
1065 |
return peer; |
|
1066 |
} |
|
1067 |
||
1068 |
public CanvasPeer createCanvas(Canvas target) { |
|
1069 |
XCanvasPeer peer = (isXEmbedServerRequested() ? new XEmbedCanvasPeer(target) : new XCanvasPeer(target)); |
|
1070 |
targetCreatedPeer(target, peer); |
|
1071 |
return peer; |
|
1072 |
} |
|
1073 |
||
1074 |
public PanelPeer createPanel(Panel target) { |
|
1075 |
PanelPeer peer = new XPanelPeer(target); |
|
1076 |
targetCreatedPeer(target, peer); |
|
1077 |
return peer; |
|
1078 |
} |
|
1079 |
||
1080 |
public WindowPeer createWindow(Window target) { |
|
1081 |
WindowPeer peer = new XWindowPeer(target); |
|
1082 |
targetCreatedPeer(target, peer); |
|
1083 |
return peer; |
|
1084 |
} |
|
1085 |
||
1086 |
public DialogPeer createDialog(Dialog target) { |
|
1087 |
DialogPeer peer = new XDialogPeer(target); |
|
1088 |
targetCreatedPeer(target, peer); |
|
1089 |
return peer; |
|
1090 |
} |
|
1091 |
||
5944
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1092 |
private static Boolean sunAwtDisableGtkFileDialogs = null; |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1093 |
|
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1094 |
/** |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1095 |
* Returns the value of "sun.awt.disableGtkFileDialogs" property. Default |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1096 |
* value is {@code false}. |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1097 |
*/ |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1098 |
public synchronized static boolean getSunAwtDisableGtkFileDialogs() { |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1099 |
if (sunAwtDisableGtkFileDialogs == null) { |
13604 | 1100 |
sunAwtDisableGtkFileDialogs = AccessController.doPrivileged( |
1101 |
new GetBooleanAction("sun.awt.disableGtkFileDialogs")); |
|
5944
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1102 |
} |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1103 |
return sunAwtDisableGtkFileDialogs.booleanValue(); |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1104 |
} |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1105 |
|
2 | 1106 |
public FileDialogPeer createFileDialog(FileDialog target) { |
5944
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1107 |
FileDialogPeer peer = null; |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4376
diff
changeset
|
1108 |
// The current GtkFileChooser is available from GTK+ 2.4 |
5944
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1109 |
if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) { |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1110 |
peer = new GtkFileDialogPeer(target); |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1111 |
} else { |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1112 |
peer = new XFileDialogPeer(target); |
1041870341a8
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
dcherepanov
parents:
5760
diff
changeset
|
1113 |
} |
2 | 1114 |
targetCreatedPeer(target, peer); |
1115 |
return peer; |
|
1116 |
} |
|
1117 |
||
1118 |
public MenuBarPeer createMenuBar(MenuBar target) { |
|
1119 |
XMenuBarPeer peer = new XMenuBarPeer(target); |
|
1120 |
targetCreatedPeer(target, peer); |
|
1121 |
return peer; |
|
1122 |
} |
|
1123 |
||
1124 |
public MenuPeer createMenu(Menu target) { |
|
1125 |
XMenuPeer peer = new XMenuPeer(target); |
|
1126 |
//vb157120: looks like we don't need to map menu items |
|
1127 |
//in new menus implementation |
|
1128 |
//targetCreatedPeer(target, peer); |
|
1129 |
return peer; |
|
1130 |
} |
|
1131 |
||
1132 |
public PopupMenuPeer createPopupMenu(PopupMenu target) { |
|
1133 |
XPopupMenuPeer peer = new XPopupMenuPeer(target); |
|
1134 |
targetCreatedPeer(target, peer); |
|
1135 |
return peer; |
|
1136 |
} |
|
1137 |
||
1138 |
public synchronized MouseInfoPeer getMouseInfoPeer() { |
|
1139 |
if (xPeer == null) { |
|
1140 |
xPeer = new XMouseInfoPeer(); |
|
1141 |
} |
|
1142 |
return xPeer; |
|
1143 |
} |
|
1144 |
||
1145 |
public XEmbeddedFramePeer createEmbeddedFrame(XEmbeddedFrame target) |
|
1146 |
{ |
|
1147 |
XEmbeddedFramePeer peer = new XEmbeddedFramePeer(target); |
|
1148 |
targetCreatedPeer(target, peer); |
|
1149 |
return peer; |
|
1150 |
} |
|
1151 |
||
1152 |
XEmbedChildProxyPeer createEmbedProxy(XEmbedChildProxy target) { |
|
1153 |
XEmbedChildProxyPeer peer = new XEmbedChildProxyPeer(target); |
|
1154 |
targetCreatedPeer(target, peer); |
|
1155 |
return peer; |
|
1156 |
} |
|
1157 |
||
1158 |
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) throws HeadlessException { |
|
1159 |
XKeyboardFocusManagerPeer peer = new XKeyboardFocusManagerPeer(manager); |
|
1160 |
return peer; |
|
1161 |
} |
|
1162 |
||
1163 |
/** |
|
1164 |
* Returns a new custom cursor. |
|
1165 |
*/ |
|
1166 |
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) |
|
1167 |
throws IndexOutOfBoundsException { |
|
1168 |
return new XCustomCursor(cursor, hotSpot, name); |
|
1169 |
} |
|
1170 |
||
1171 |
public TrayIconPeer createTrayIcon(TrayIcon target) |
|
1172 |
throws HeadlessException, AWTException |
|
1173 |
{ |
|
1174 |
TrayIconPeer peer = new XTrayIconPeer(target); |
|
1175 |
targetCreatedPeer(target, peer); |
|
1176 |
return peer; |
|
1177 |
} |
|
1178 |
||
1179 |
public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException { |
|
1180 |
SystemTrayPeer peer = new XSystemTrayPeer(target); |
|
1181 |
return peer; |
|
1182 |
} |
|
1183 |
||
1184 |
public boolean isTraySupported() { |
|
1185 |
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance(); |
|
1186 |
if (peer != null) { |
|
1187 |
return peer.isAvailable(); |
|
1188 |
} |
|
1189 |
return false; |
|
1190 |
} |
|
1191 |
||
1192 |
/** |
|
1193 |
* Returns the supported cursor size |
|
1194 |
*/ |
|
1195 |
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) { |
|
1196 |
return XCustomCursor.getBestCursorSize( |
|
1197 |
java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight)); |
|
1198 |
} |
|
1199 |
||
1200 |
||
1201 |
public int getMaximumCursorColors() { |
|
1202 |
return 2; // Black and white. |
|
1203 |
} |
|
1204 |
||
1205 |
public Map mapInputMethodHighlight(InputMethodHighlight highlight) { |
|
1206 |
return XInputMethod.mapInputMethodHighlight(highlight); |
|
1207 |
} |
|
1966
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1208 |
@Override |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1209 |
public boolean getLockingKeyState(int key) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1210 |
if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK || |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1211 |
key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1212 |
throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState"); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1213 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1214 |
awtLock(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1215 |
try { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1216 |
return getModifierState( key ); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1217 |
} finally { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1218 |
awtUnlock(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1219 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1220 |
} |
2 | 1221 |
|
1222 |
public Clipboard getSystemClipboard() { |
|
1223 |
SecurityManager security = System.getSecurityManager(); |
|
1224 |
if (security != null) { |
|
1225 |
security.checkSystemClipboardAccess(); |
|
1226 |
} |
|
1227 |
synchronized (this) { |
|
1228 |
if (clipboard == null) { |
|
1229 |
clipboard = new XClipboard("System", "CLIPBOARD"); |
|
1230 |
} |
|
1231 |
} |
|
1232 |
return clipboard; |
|
1233 |
} |
|
1234 |
||
1235 |
public Clipboard getSystemSelection() { |
|
1236 |
SecurityManager security = System.getSecurityManager(); |
|
1237 |
if (security != null) { |
|
1238 |
security.checkSystemClipboardAccess(); |
|
1239 |
} |
|
1240 |
synchronized (this) { |
|
1241 |
if (selection == null) { |
|
1242 |
selection = new XClipboard("Selection", "PRIMARY"); |
|
1243 |
} |
|
1244 |
} |
|
1245 |
return selection; |
|
1246 |
} |
|
1247 |
||
1248 |
public void beep() { |
|
1249 |
awtLock(); |
|
1250 |
try { |
|
1251 |
XlibWrapper.XBell(getDisplay(), 0); |
|
3083 | 1252 |
XlibWrapper.XFlush(getDisplay()); |
2 | 1253 |
} finally { |
1254 |
awtUnlock(); |
|
1255 |
} |
|
1256 |
} |
|
1257 |
||
1258 |
public PrintJob getPrintJob(final Frame frame, final String doctitle, |
|
1259 |
final Properties props) { |
|
1260 |
||
8947
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1261 |
if (frame == null) { |
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1262 |
throw new NullPointerException("frame must not be null"); |
2 | 1263 |
} |
1264 |
||
1265 |
PrintJob2D printJob = new PrintJob2D(frame, doctitle, props); |
|
1266 |
||
1267 |
if (printJob.printDialog() == false) { |
|
1268 |
printJob = null; |
|
1269 |
} |
|
1270 |
return printJob; |
|
1271 |
} |
|
1272 |
||
1273 |
public PrintJob getPrintJob(final Frame frame, final String doctitle, |
|
1274 |
final JobAttributes jobAttributes, |
|
8947
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1275 |
final PageAttributes pageAttributes) |
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1276 |
{ |
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1277 |
if (frame == null) { |
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
6820
diff
changeset
|
1278 |
throw new NullPointerException("frame must not be null"); |
2 | 1279 |
} |
1280 |
||
1281 |
PrintJob2D printJob = new PrintJob2D(frame, doctitle, |
|
1282 |
jobAttributes, pageAttributes); |
|
1283 |
||
1284 |
if (printJob.printDialog() == false) { |
|
1285 |
printJob = null; |
|
1286 |
} |
|
1287 |
||
1288 |
return printJob; |
|
1289 |
} |
|
1290 |
||
1291 |
static void XSync() { |
|
1292 |
awtLock(); |
|
1293 |
try { |
|
1294 |
XlibWrapper.XSync(getDisplay(),0); |
|
1295 |
} finally { |
|
1296 |
awtUnlock(); |
|
1297 |
} |
|
1298 |
} |
|
1299 |
||
1300 |
public int getScreenResolution() { |
|
1301 |
long display = getDisplay(); |
|
1302 |
awtLock(); |
|
1303 |
try { |
|
1304 |
return (int) ((XlibWrapper.DisplayWidth(display, |
|
1305 |
XlibWrapper.DefaultScreen(display)) * 25.4) / |
|
1306 |
XlibWrapper.DisplayWidthMM(display, |
|
1307 |
XlibWrapper.DefaultScreen(display))); |
|
1308 |
} finally { |
|
1309 |
awtUnlock(); |
|
1310 |
} |
|
1311 |
} |
|
1312 |
||
1313 |
static native long getDefaultXColormap(); |
|
1314 |
static native long getDefaultScreenData(); |
|
1315 |
||
1316 |
static ColorModel screenmodel; |
|
1317 |
||
1318 |
static ColorModel getStaticColorModel() { |
|
1319 |
if (screenmodel == null) { |
|
1320 |
screenmodel = config.getColorModel (); |
|
1321 |
} |
|
1322 |
return screenmodel; |
|
1323 |
} |
|
1324 |
||
1325 |
public ColorModel getColorModel() { |
|
1326 |
return getStaticColorModel(); |
|
1327 |
} |
|
1328 |
||
1329 |
/** |
|
1330 |
* Returns a new input method adapter descriptor for native input methods. |
|
1331 |
*/ |
|
1332 |
public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException { |
|
1333 |
return new XInputMethodDescriptor(); |
|
1334 |
} |
|
1335 |
||
1336 |
static int getMultiClickTime() { |
|
1337 |
if (awt_multiclick_time == 0) { |
|
1338 |
initializeMultiClickTime(); |
|
1339 |
} |
|
1340 |
return awt_multiclick_time; |
|
1341 |
} |
|
1342 |
static void initializeMultiClickTime() { |
|
1343 |
awtLock(); |
|
1344 |
try { |
|
1345 |
try { |
|
1346 |
String multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), "*", "multiClickTime"); |
|
1347 |
if (multiclick_time_query != null) { |
|
1348 |
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query); |
|
1349 |
} else { |
|
1350 |
multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), |
|
1351 |
"OpenWindows", "MultiClickTimeout"); |
|
1352 |
if (multiclick_time_query != null) { |
|
1353 |
/* Note: OpenWindows.MultiClickTimeout is in tenths of |
|
1354 |
a second, so we need to multiply by 100 to convert to |
|
1355 |
milliseconds */ |
|
1356 |
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query) * 100; |
|
1357 |
} else { |
|
1969
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
1358 |
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME; |
2 | 1359 |
} |
1360 |
} |
|
1361 |
} catch (NumberFormatException nf) { |
|
1969
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
1362 |
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME; |
2 | 1363 |
} catch (NullPointerException npe) { |
1969
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
1364 |
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME; |
2 | 1365 |
} |
1366 |
} finally { |
|
1367 |
awtUnlock(); |
|
1368 |
} |
|
1369 |
if (awt_multiclick_time == 0) { |
|
1969
07500c30ab46
5076635: Double click speed is not honored in KDE linux
dav
parents:
439
diff
changeset
|
1370 |
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME; |
2 | 1371 |
} |
1372 |
} |
|
1373 |
||
1374 |
public boolean isFrameStateSupported(int state) |
|
1375 |
throws HeadlessException |
|
1376 |
{ |
|
1377 |
if (state == Frame.NORMAL || state == Frame.ICONIFIED) { |
|
1378 |
return true; |
|
1379 |
} else { |
|
1380 |
return XWM.getWM().supportsExtendedState(state); |
|
1381 |
} |
|
1382 |
} |
|
1383 |
||
1384 |
static void dumpPeers() { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1385 |
if (log.isLoggable(PlatformLogger.FINE)) { |
2 | 1386 |
log.fine("Mapped windows:"); |
1387 |
Iterator iter = winMap.entrySet().iterator(); |
|
1388 |
while (iter.hasNext()) { |
|
1389 |
Map.Entry entry = (Map.Entry)iter.next(); |
|
1390 |
log.fine(entry.getKey() + "->" + entry.getValue()); |
|
1391 |
if (entry.getValue() instanceof XComponentPeer) { |
|
1392 |
Component target = (Component)((XComponentPeer)entry.getValue()).getTarget(); |
|
1393 |
log.fine("\ttarget: " + target); |
|
1394 |
} |
|
1395 |
} |
|
1396 |
||
1397 |
SunToolkit.dumpPeers(log); |
|
1398 |
||
1399 |
log.fine("Mapped special peers:"); |
|
1400 |
iter = specialPeerMap.entrySet().iterator(); |
|
1401 |
while (iter.hasNext()) { |
|
1402 |
Map.Entry entry = (Map.Entry)iter.next(); |
|
1403 |
log.fine(entry.getKey() + "->" + entry.getValue()); |
|
1404 |
} |
|
1405 |
||
1406 |
log.fine("Mapped dispatchers:"); |
|
1407 |
iter = winToDispatcher.entrySet().iterator(); |
|
1408 |
while (iter.hasNext()) { |
|
1409 |
Map.Entry entry = (Map.Entry)iter.next(); |
|
1410 |
log.fine(entry.getKey() + "->" + entry.getValue()); |
|
1411 |
} |
|
1412 |
} |
|
1413 |
} |
|
1414 |
||
1415 |
/* Protected with awt_lock. */ |
|
1416 |
private static boolean initialized; |
|
1417 |
private static boolean timeStampUpdated; |
|
1418 |
private static long timeStamp; |
|
1419 |
||
1420 |
private static final XEventDispatcher timeFetcher = |
|
1421 |
new XEventDispatcher() { |
|
1422 |
public void dispatchEvent(XEvent ev) { |
|
1423 |
switch (ev.get_type()) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
1424 |
case XConstants.PropertyNotify: |
2 | 1425 |
XPropertyEvent xpe = ev.get_xproperty(); |
1426 |
||
1427 |
awtLock(); |
|
1428 |
try { |
|
1429 |
timeStamp = xpe.get_time(); |
|
1430 |
timeStampUpdated = true; |
|
1431 |
awtLockNotifyAll(); |
|
1432 |
} finally { |
|
1433 |
awtUnlock(); |
|
1434 |
} |
|
1435 |
||
1436 |
break; |
|
1437 |
} |
|
1438 |
} |
|
1439 |
}; |
|
1440 |
||
1441 |
private static XAtom _XA_JAVA_TIME_PROPERTY_ATOM; |
|
1442 |
||
1443 |
static long getCurrentServerTime() { |
|
1444 |
awtLock(); |
|
1445 |
try { |
|
1446 |
try { |
|
1447 |
if (!initialized) { |
|
1448 |
XToolkit.addEventDispatcher(XBaseWindow.getXAWTRootWindow().getWindow(), |
|
1449 |
timeFetcher); |
|
1450 |
_XA_JAVA_TIME_PROPERTY_ATOM = XAtom.get("_SUNW_JAVA_AWT_TIME"); |
|
1451 |
initialized = true; |
|
1452 |
} |
|
1453 |
timeStampUpdated = false; |
|
1454 |
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), |
|
1455 |
XBaseWindow.getXAWTRootWindow().getWindow(), |
|
1456 |
_XA_JAVA_TIME_PROPERTY_ATOM.getAtom(), XAtom.XA_ATOM, 32, |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
1457 |
XConstants.PropModeAppend, |
2 | 1458 |
0, 0); |
1459 |
XlibWrapper.XFlush(XToolkit.getDisplay()); |
|
1460 |
||
1461 |
if (isToolkitThread()) { |
|
1462 |
XEvent event = new XEvent(); |
|
1463 |
try { |
|
1464 |
XlibWrapper.XWindowEvent(XToolkit.getDisplay(), |
|
1465 |
XBaseWindow.getXAWTRootWindow().getWindow(), |
|
1466 |
XConstants.PropertyChangeMask, |
|
1467 |
event.pData); |
|
1468 |
timeFetcher.dispatchEvent(event); |
|
1469 |
} |
|
1470 |
finally { |
|
1471 |
event.dispose(); |
|
1472 |
} |
|
1473 |
} |
|
1474 |
else { |
|
1475 |
while (!timeStampUpdated) { |
|
1476 |
awtLockWait(); |
|
1477 |
} |
|
1478 |
} |
|
1479 |
} catch (InterruptedException ie) { |
|
1480 |
// Note: the returned timeStamp can be incorrect in this case. |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1481 |
if (log.isLoggable(PlatformLogger.FINE)) log.fine("Catched exception, timeStamp may not be correct (ie = " + ie + ")"); |
2 | 1482 |
} |
1483 |
} finally { |
|
1484 |
awtUnlock(); |
|
1485 |
} |
|
1486 |
return timeStamp; |
|
1487 |
} |
|
1488 |
protected void initializeDesktopProperties() { |
|
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1489 |
desktopProperties.put("DnD.Autoscroll.initialDelay", |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1490 |
Integer.valueOf(50)); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1491 |
desktopProperties.put("DnD.Autoscroll.interval", |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1492 |
Integer.valueOf(50)); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1493 |
desktopProperties.put("DnD.Autoscroll.cursorHysteresis", |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1494 |
Integer.valueOf(5)); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1495 |
desktopProperties.put("Shell.shellFolderManager", |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
3083
diff
changeset
|
1496 |
"sun.awt.shell.ShellFolderManager"); |
2 | 1497 |
// Don't want to call getMultiClickTime() if we are headless |
1498 |
if (!GraphicsEnvironment.isHeadless()) { |
|
1499 |
desktopProperties.put("awt.multiClickInterval", |
|
1500 |
Integer.valueOf(getMultiClickTime())); |
|
1501 |
desktopProperties.put("awt.mouse.numButtons", |
|
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1502 |
Integer.valueOf(getNumberOfButtons())); |
2 | 1503 |
} |
1504 |
} |
|
1505 |
||
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1506 |
/** |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1507 |
* This method runs through the XPointer and XExtendedPointer array. |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1508 |
* XExtendedPointer has priority because on some systems XPointer |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1509 |
* (which is assigned to the virtual pointer) reports the maximum |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1510 |
* capabilities of the mouse pointer (i.e. 32 physical buttons). |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1511 |
*/ |
4376
61cb05d6efa2
6903893: Fix failed for CR 6834576: RemoveChild/ test fail with deadlock on rhel and sles
dav
parents:
4372
diff
changeset
|
1512 |
private native int getNumberOfButtonsImpl(); |
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1513 |
|
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1514 |
@Override |
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1515 |
public int getNumberOfButtons(){ |
2 | 1516 |
awtLock(); |
1517 |
try { |
|
1967
a103c7d1eea6
6750288: Regression after 6315717. ArrayIndexOutOfBoundsException.
dav
parents:
1962
diff
changeset
|
1518 |
if (numberOfButtons == 0) { |
2810
fa49c6a06baf
6799099: All automatic regression tests that create Robot fail on X11
dav
parents:
2803
diff
changeset
|
1519 |
numberOfButtons = getNumberOfButtonsImpl(); |
6642
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1520 |
numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons; |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1521 |
//4th and 5th buttons are for wheel and shouldn't be reported as buttons. |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1522 |
//If we have more than 3 physical buttons and a wheel, we report N-2 buttons. |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1523 |
//If we have 3 physical buttons and a wheel, we report 3 buttons. |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1524 |
//If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively. |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1525 |
if (numberOfButtons >=5) { |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1526 |
numberOfButtons -= 2; |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1527 |
} else if (numberOfButtons == 4 || numberOfButtons ==5){ |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1528 |
numberOfButtons = 3; |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1529 |
} |
1967
a103c7d1eea6
6750288: Regression after 6315717. ArrayIndexOutOfBoundsException.
dav
parents:
1962
diff
changeset
|
1530 |
} |
6642
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1531 |
//Assume don't have to re-query the number again and again. |
9d6f6dbb16a4
6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5
dav
parents:
5944
diff
changeset
|
1532 |
return numberOfButtons; |
2 | 1533 |
} finally { |
1534 |
awtUnlock(); |
|
1535 |
} |
|
1536 |
} |
|
1537 |
||
1538 |
private final static String prefix = "DnD.Cursor."; |
|
1539 |
private final static String postfix = ".32x32"; |
|
1540 |
private static final String dndPrefix = "DnD."; |
|
1541 |
||
1542 |
protected Object lazilyLoadDesktopProperty(String name) { |
|
1543 |
if (name.startsWith(prefix)) { |
|
1544 |
String cursorName = name.substring(prefix.length(), name.length()) + postfix; |
|
1545 |
||
1546 |
try { |
|
1547 |
return Cursor.getSystemCustomCursor(cursorName); |
|
1548 |
} catch (AWTException awte) { |
|
1549 |
throw new RuntimeException("cannot load system cursor: " + cursorName, awte); |
|
1550 |
} |
|
1551 |
} |
|
1552 |
||
1553 |
if (name.equals("awt.dynamicLayoutSupported")) { |
|
1554 |
return Boolean.valueOf(isDynamicLayoutSupported()); |
|
1555 |
} |
|
1556 |
||
1557 |
if (initXSettingsIfNeeded(name)) { |
|
1558 |
return desktopProperties.get(name); |
|
1559 |
} |
|
1560 |
||
1561 |
return super.lazilyLoadDesktopProperty(name); |
|
1562 |
} |
|
1563 |
||
1564 |
public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { |
|
10319
dbbded066362
7072645: Toolkit.addPropertyChangeListener(name, pcl) throws NPE for null name
denis
parents:
9030
diff
changeset
|
1565 |
if (name == null) { |
dbbded066362
7072645: Toolkit.addPropertyChangeListener(name, pcl) throws NPE for null name
denis
parents:
9030
diff
changeset
|
1566 |
// See JavaDoc for the Toolkit.addPropertyChangeListener() method |
dbbded066362
7072645: Toolkit.addPropertyChangeListener(name, pcl) throws NPE for null name
denis
parents:
9030
diff
changeset
|
1567 |
return; |
dbbded066362
7072645: Toolkit.addPropertyChangeListener(name, pcl) throws NPE for null name
denis
parents:
9030
diff
changeset
|
1568 |
} |
2 | 1569 |
initXSettingsIfNeeded(name); |
1570 |
super.addPropertyChangeListener(name, pcl); |
|
1571 |
} |
|
1572 |
||
1573 |
/** |
|
1574 |
* Initializes XAWTXSettings if a property for a given property name is provided by |
|
1575 |
* XSettings and they are not initialized yet. |
|
1576 |
* |
|
1577 |
* @return true if the method has initialized XAWTXSettings. |
|
1578 |
*/ |
|
1579 |
private boolean initXSettingsIfNeeded(final String propName) { |
|
1580 |
if (!loadedXSettings && |
|
1581 |
(propName.startsWith("gnome.") || |
|
1582 |
propName.equals(SunToolkit.DESKTOPFONTHINTS) || |
|
1583 |
propName.startsWith(dndPrefix))) |
|
1584 |
{ |
|
1585 |
loadedXSettings = true; |
|
1586 |
if (!GraphicsEnvironment.isHeadless()) { |
|
1587 |
loadXSettings(); |
|
1588 |
/* If no desktop font hint could be retrieved, check for |
|
1589 |
* KDE running KWin and retrieve settings from fontconfig. |
|
1590 |
* If that isn't found let SunToolkit will see if there's a |
|
1591 |
* system property set by a user. |
|
1592 |
*/ |
|
1593 |
if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) { |
|
1594 |
if (XWM.isKDE2()) { |
|
3928 | 1595 |
Object hint = fcManager.getFontConfigAAHint(); |
2 | 1596 |
if (hint != null) { |
1597 |
/* set the fontconfig/KDE property so that |
|
1598 |
* getDesktopHints() below will see it |
|
1599 |
* and set the public property. |
|
1600 |
*/ |
|
1601 |
desktopProperties.put(UNIXToolkit.FONTCONFIGAAHINT, |
|
1602 |
hint); |
|
1603 |
} |
|
1604 |
} |
|
1605 |
desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, |
|
1606 |
SunToolkit.getDesktopFontHints()); |
|
1607 |
} |
|
1608 |
||
1609 |
return true; |
|
1610 |
} |
|
1611 |
} |
|
1612 |
return false; |
|
1613 |
} |
|
1614 |
||
1615 |
private void loadXSettings() { |
|
1616 |
xs = new XAWTXSettings(); |
|
1617 |
} |
|
1618 |
||
1619 |
/** |
|
1620 |
* Callback from the native side indicating some, or all, of the |
|
1621 |
* desktop properties have changed and need to be reloaded. |
|
1622 |
* <code>data</code> is the byte array directly from the x server and |
|
1623 |
* may be in little endian format. |
|
1624 |
* <p> |
|
1625 |
* NB: This could be called from any thread if triggered by |
|
1626 |
* <code>loadXSettings</code>. It is called from the System EDT |
|
1627 |
* if triggered by an XSETTINGS change. |
|
1628 |
*/ |
|
1629 |
void parseXSettings(int screen_XXX_ignored,Map updatedSettings) { |
|
1630 |
||
1631 |
if (updatedSettings == null || updatedSettings.isEmpty()) { |
|
1632 |
return; |
|
1633 |
} |
|
1634 |
||
1635 |
Iterator i = updatedSettings.entrySet().iterator(); |
|
1636 |
while (i.hasNext()) { |
|
1637 |
Map.Entry e = (Map.Entry)i.next(); |
|
1638 |
String name = (String)e.getKey(); |
|
1639 |
||
1640 |
name = "gnome." + name; |
|
1641 |
setDesktopProperty(name, e.getValue()); |
|
1642 |
log.fine("name = " + name + " value = " + e.getValue()); |
|
1643 |
||
1644 |
// XXX: we probably want to do something smarter. In |
|
1645 |
// particular, "Net" properties are of interest to the |
|
1646 |
// "core" AWT itself. E.g. |
|
1647 |
// |
|
1648 |
// Net/DndDragThreshold -> ??? |
|
1649 |
// Net/DoubleClickTime -> awt.multiClickInterval |
|
1650 |
} |
|
1651 |
||
1652 |
setDesktopProperty(SunToolkit.DESKTOPFONTHINTS, |
|
1653 |
SunToolkit.getDesktopFontHints()); |
|
1654 |
||
1655 |
Integer dragThreshold = null; |
|
1656 |
synchronized (this) { |
|
1657 |
dragThreshold = (Integer)desktopProperties.get("gnome.Net/DndDragThreshold"); |
|
1658 |
} |
|
1659 |
if (dragThreshold != null) { |
|
1660 |
setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold); |
|
1661 |
} |
|
1662 |
||
1663 |
} |
|
1664 |
||
1665 |
||
1666 |
||
1667 |
static int altMask; |
|
1668 |
static int metaMask; |
|
1669 |
static int numLockMask; |
|
1670 |
static int modeSwitchMask; |
|
1671 |
static int modLockIsShiftLock; |
|
1672 |
||
1673 |
/* Like XKeysymToKeycode, but ensures that keysym is the primary |
|
1674 |
* symbol on the keycode returned. Returns zero otherwise. |
|
1675 |
*/ |
|
1676 |
static int keysymToPrimaryKeycode(long sym) { |
|
1677 |
awtLock(); |
|
1678 |
try { |
|
1679 |
int code = XlibWrapper.XKeysymToKeycode(getDisplay(), sym); |
|
1680 |
if (code == 0) { |
|
1681 |
return 0; |
|
1682 |
} |
|
1683 |
long primary = XlibWrapper.XKeycodeToKeysym(getDisplay(), code, 0); |
|
1684 |
if (sym != primary) { |
|
1685 |
return 0; |
|
1686 |
} |
|
1687 |
return code; |
|
1688 |
} finally { |
|
1689 |
awtUnlock(); |
|
1690 |
} |
|
1691 |
} |
|
1966
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1692 |
static boolean getModifierState( int jkc ) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1693 |
int iKeyMask = 0; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1694 |
long ks = XKeysym.javaKeycode2Keysym( jkc ); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1695 |
int kc = XlibWrapper.XKeysymToKeycode(getDisplay(), ks); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1696 |
if (kc == 0) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1697 |
return false; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1698 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1699 |
awtLock(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1700 |
try { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1701 |
XModifierKeymap modmap = new XModifierKeymap( |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1702 |
XlibWrapper.XGetModifierMapping(getDisplay())); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1703 |
|
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1704 |
int nkeys = modmap.get_max_keypermod(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1705 |
|
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1706 |
long map_ptr = modmap.get_modifiermap(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1707 |
for( int k = 0; k < 8; k++ ) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1708 |
for (int i = 0; i < nkeys; ++i) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1709 |
int keycode = Native.getUByte(map_ptr, k * nkeys + i); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1710 |
if (keycode == 0) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1711 |
continue; // ignore zero keycode |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1712 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1713 |
if (kc == keycode) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1714 |
iKeyMask = 1 << k; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1715 |
break; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1716 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1717 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1718 |
if( iKeyMask != 0 ) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1719 |
break; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1720 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1721 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1722 |
XlibWrapper.XFreeModifiermap(modmap.pData); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1723 |
if (iKeyMask == 0 ) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1724 |
return false; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1725 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1726 |
// Now we know to which modifier is assigned the keycode |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1727 |
// correspondent to the keysym correspondent to the java |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1728 |
// keycode. We are going to check a state of this modifier. |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1729 |
// If a modifier is a weird one, we cannot help it. |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1730 |
long window = 0; |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1731 |
try{ |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1732 |
// get any application window |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1733 |
window = ((Long)(winMap.firstKey())).longValue(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1734 |
}catch(NoSuchElementException nex) { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1735 |
// get root window |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1736 |
window = getDefaultRootWindow(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1737 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1738 |
boolean res = XlibWrapper.XQueryPointer(getDisplay(), window, |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1739 |
XlibWrapper.larg1, //root |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1740 |
XlibWrapper.larg2, //child |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1741 |
XlibWrapper.larg3, //root_x |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1742 |
XlibWrapper.larg4, //root_y |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1743 |
XlibWrapper.larg5, //child_x |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1744 |
XlibWrapper.larg6, //child_y |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1745 |
XlibWrapper.larg7);//mask |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1746 |
int mask = Native.getInt(XlibWrapper.larg7); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1747 |
return ((mask & iKeyMask) != 0); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1748 |
} finally { |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1749 |
awtUnlock(); |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1750 |
} |
12a51fb0db0d
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents:
1962
diff
changeset
|
1751 |
} |
2 | 1752 |
|
1753 |
/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5. |
|
1754 |
* Only consider primary symbols on keycodes attached to modifiers. |
|
1755 |
*/ |
|
1756 |
static void setupModifierMap() { |
|
1757 |
final int metaL = keysymToPrimaryKeycode(XKeySymConstants.XK_Meta_L); |
|
1758 |
final int metaR = keysymToPrimaryKeycode(XKeySymConstants.XK_Meta_R); |
|
1759 |
final int altL = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_L); |
|
1760 |
final int altR = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_R); |
|
1761 |
final int numLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Num_Lock); |
|
1762 |
final int modeSwitch = keysymToPrimaryKeycode(XKeySymConstants.XK_Mode_switch); |
|
1763 |
final int shiftLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Shift_Lock); |
|
1764 |
final int capsLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Caps_Lock); |
|
1765 |
||
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
1766 |
final int modmask[] = { XConstants.ShiftMask, XConstants.LockMask, XConstants.ControlMask, XConstants.Mod1Mask, |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
1767 |
XConstants.Mod2Mask, XConstants.Mod3Mask, XConstants.Mod4Mask, XConstants.Mod5Mask }; |
2 | 1768 |
|
1769 |
log.fine("In setupModifierMap"); |
|
1770 |
awtLock(); |
|
1771 |
try { |
|
1772 |
XModifierKeymap modmap = new XModifierKeymap( |
|
1773 |
XlibWrapper.XGetModifierMapping(getDisplay())); |
|
1774 |
||
1775 |
int nkeys = modmap.get_max_keypermod(); |
|
1776 |
||
1777 |
long map_ptr = modmap.get_modifiermap(); |
|
1778 |
||
1779 |
for (int modn = XConstants.Mod1MapIndex; |
|
1780 |
modn <= XConstants.Mod5MapIndex; |
|
1781 |
++modn) |
|
1782 |
{ |
|
1783 |
for (int i = 0; i < nkeys; ++i) { |
|
1784 |
/* for each keycode attached to this modifier */ |
|
1785 |
int keycode = Native.getUByte(map_ptr, modn * nkeys + i); |
|
1786 |
||
1787 |
if (keycode == 0) { |
|
1788 |
break; |
|
1789 |
} |
|
1790 |
if (metaMask == 0 && |
|
1791 |
(keycode == metaL || keycode == metaR)) |
|
1792 |
{ |
|
1793 |
metaMask = modmask[modn]; |
|
1794 |
break; |
|
1795 |
} |
|
1796 |
if (altMask == 0 && (keycode == altL || keycode == altR)) { |
|
1797 |
altMask = modmask[modn]; |
|
1798 |
break; |
|
1799 |
} |
|
1800 |
if (numLockMask == 0 && keycode == numLock) { |
|
1801 |
numLockMask = modmask[modn]; |
|
1802 |
break; |
|
1803 |
} |
|
1804 |
if (modeSwitchMask == 0 && keycode == modeSwitch) { |
|
1805 |
modeSwitchMask = modmask[modn]; |
|
1806 |
break; |
|
1807 |
} |
|
1808 |
continue; |
|
1809 |
} |
|
1810 |
} |
|
1811 |
modLockIsShiftLock = 0; |
|
1812 |
for (int j = 0; j < nkeys; ++j) { |
|
1813 |
int keycode = Native.getUByte(map_ptr, XConstants.LockMapIndex * nkeys + j); |
|
1814 |
if (keycode == 0) { |
|
1815 |
break; |
|
1816 |
} |
|
1817 |
if (keycode == shiftLock) { |
|
1818 |
modLockIsShiftLock = 1; |
|
1819 |
break; |
|
1820 |
} |
|
1821 |
if (keycode == capsLock) { |
|
1822 |
break; |
|
1823 |
} |
|
1824 |
} |
|
1825 |
XlibWrapper.XFreeModifiermap(modmap.pData); |
|
1826 |
} finally { |
|
1827 |
awtUnlock(); |
|
1828 |
} |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1829 |
if (log.isLoggable(PlatformLogger.FINE)) { |
2 | 1830 |
log.fine("metaMask = " + metaMask); |
1831 |
log.fine("altMask = " + altMask); |
|
1832 |
log.fine("numLockMask = " + numLockMask); |
|
1833 |
log.fine("modeSwitchMask = " + modeSwitchMask); |
|
1834 |
log.fine("modLockIsShiftLock = " + modLockIsShiftLock); |
|
1835 |
} |
|
1836 |
} |
|
1837 |
||
1838 |
||
1839 |
private static SortedMap timeoutTasks; |
|
1840 |
||
1841 |
/** |
|
1842 |
* Removed the task from the list of waiting-to-be called tasks. |
|
1843 |
* If the task has been scheduled several times removes only first one. |
|
1844 |
*/ |
|
1845 |
static void remove(Runnable task) { |
|
1846 |
if (task == null) { |
|
1847 |
throw new NullPointerException("task is null"); |
|
1848 |
} |
|
1849 |
awtLock(); |
|
1850 |
try { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1851 |
if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) { |
2 | 1852 |
timeoutTaskLog.finer("Removing task " + task); |
1853 |
} |
|
1854 |
if (timeoutTasks == null) { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1855 |
if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) { |
2 | 1856 |
timeoutTaskLog.finer("Task is not scheduled"); |
1857 |
} |
|
1858 |
return; |
|
1859 |
} |
|
1860 |
Collection values = timeoutTasks.values(); |
|
1861 |
Iterator iter = values.iterator(); |
|
1862 |
while (iter.hasNext()) { |
|
1863 |
java.util.List list = (java.util.List)iter.next(); |
|
1864 |
boolean removed = false; |
|
1865 |
if (list.contains(task)) { |
|
1866 |
list.remove(task); |
|
1867 |
if (list.isEmpty()) { |
|
1868 |
iter.remove(); |
|
1869 |
} |
|
1870 |
break; |
|
1871 |
} |
|
1872 |
} |
|
1873 |
} finally { |
|
1874 |
awtUnlock(); |
|
1875 |
} |
|
1876 |
} |
|
1877 |
||
1878 |
static native void wakeup_poll(); |
|
1879 |
||
1880 |
/** |
|
1881 |
* Registers a Runnable which <code>run()</code> method will be called |
|
1882 |
* once on the toolkit thread when a specified interval of time elapses. |
|
1883 |
* |
|
1884 |
* @param task a Runnable which <code>run</code> method will be called |
|
1885 |
* on the toolkit thread when <code>interval</code> milliseconds |
|
1886 |
* elapse |
|
1887 |
* @param interval an interal in milliseconds |
|
1888 |
* |
|
1889 |
* @throws NullPointerException if <code>task</code> is <code>null</code> |
|
1890 |
* @throws IllegalArgumentException if <code>interval</code> is not positive |
|
1891 |
*/ |
|
1892 |
static void schedule(Runnable task, long interval) { |
|
1893 |
if (task == null) { |
|
1894 |
throw new NullPointerException("task is null"); |
|
1895 |
} |
|
1896 |
if (interval <= 0) { |
|
1897 |
throw new IllegalArgumentException("interval " + interval + " is not positive"); |
|
1898 |
} |
|
1899 |
||
1900 |
awtLock(); |
|
1901 |
try { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1902 |
if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1903 |
timeoutTaskLog.finer("XToolkit.schedule(): current time={0}" + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1904 |
"; interval={1}" + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1905 |
"; task being added={2}" + "; tasks before addition={3}", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1906 |
Long.valueOf(System.currentTimeMillis()), Long.valueOf(interval), task, timeoutTasks); |
2 | 1907 |
} |
1908 |
||
1909 |
if (timeoutTasks == null) { |
|
1910 |
timeoutTasks = new TreeMap(); |
|
1911 |
} |
|
1912 |
||
1913 |
Long time = Long.valueOf(System.currentTimeMillis() + interval); |
|
1914 |
java.util.List tasks = (java.util.List)timeoutTasks.get(time); |
|
1915 |
if (tasks == null) { |
|
1916 |
tasks = new ArrayList(1); |
|
1917 |
timeoutTasks.put(time, tasks); |
|
1918 |
} |
|
1919 |
tasks.add(task); |
|
1920 |
||
1921 |
||
1922 |
if (timeoutTasks.get(timeoutTasks.firstKey()) == tasks && tasks.size() == 1) { |
|
1923 |
// Added task became first task - poll won't know |
|
1924 |
// about it so we need to wake it up |
|
1925 |
wakeup_poll(); |
|
1926 |
} |
|
1927 |
} finally { |
|
1928 |
awtUnlock(); |
|
1929 |
} |
|
1930 |
} |
|
1931 |
||
1932 |
private long getNextTaskTime() { |
|
1933 |
awtLock(); |
|
1934 |
try { |
|
1935 |
if (timeoutTasks == null || timeoutTasks.isEmpty()) { |
|
1936 |
return -1L; |
|
1937 |
} |
|
1938 |
return (Long)timeoutTasks.firstKey(); |
|
1939 |
} finally { |
|
1940 |
awtUnlock(); |
|
1941 |
} |
|
1942 |
} |
|
1943 |
||
1944 |
/** |
|
1945 |
* Executes mature timeout tasks registered with schedule(). |
|
1946 |
* Called from run() under awtLock. |
|
1947 |
*/ |
|
1948 |
private static void callTimeoutTasks() { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1949 |
if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1950 |
timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1951 |
"; tasks={1}", Long.valueOf(System.currentTimeMillis()), timeoutTasks); |
2 | 1952 |
} |
1953 |
||
1954 |
if (timeoutTasks == null || timeoutTasks.isEmpty()) { |
|
1955 |
return; |
|
1956 |
} |
|
1957 |
||
1958 |
Long currentTime = Long.valueOf(System.currentTimeMillis()); |
|
1959 |
Long time = (Long)timeoutTasks.firstKey(); |
|
1960 |
||
1961 |
while (time.compareTo(currentTime) <= 0) { |
|
1962 |
java.util.List tasks = (java.util.List)timeoutTasks.remove(time); |
|
1963 |
||
1964 |
for (Iterator iter = tasks.iterator(); iter.hasNext();) { |
|
1965 |
Runnable task = (Runnable)iter.next(); |
|
1966 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1967 |
if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) { |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1968 |
timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" + |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
1969 |
"; about to run task={1}", Long.valueOf(currentTime), task); |
2 | 1970 |
} |
1971 |
||
1972 |
try { |
|
1973 |
task.run(); |
|
1974 |
} catch (ThreadDeath td) { |
|
1975 |
throw td; |
|
1976 |
} catch (Throwable thr) { |
|
1977 |
processException(thr); |
|
1978 |
} |
|
1979 |
} |
|
1980 |
||
1981 |
if (timeoutTasks.isEmpty()) { |
|
1982 |
break; |
|
1983 |
} |
|
1984 |
time = (Long)timeoutTasks.firstKey(); |
|
1985 |
} |
|
1986 |
} |
|
1987 |
||
1988 |
static long getAwtDefaultFg() { |
|
1989 |
return awt_defaultFg; |
|
1990 |
} |
|
1991 |
||
1992 |
static boolean isLeftMouseButton(MouseEvent me) { |
|
1993 |
switch (me.getID()) { |
|
1994 |
case MouseEvent.MOUSE_PRESSED: |
|
1995 |
case MouseEvent.MOUSE_RELEASED: |
|
1996 |
return (me.getButton() == MouseEvent.BUTTON1); |
|
1997 |
case MouseEvent.MOUSE_ENTERED: |
|
1998 |
case MouseEvent.MOUSE_EXITED: |
|
1999 |
case MouseEvent.MOUSE_CLICKED: |
|
2000 |
case MouseEvent.MOUSE_DRAGGED: |
|
2001 |
return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0); |
|
2002 |
} |
|
2003 |
return false; |
|
2004 |
} |
|
2005 |
||
2006 |
static boolean isRightMouseButton(MouseEvent me) { |
|
2007 |
int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue(); |
|
2008 |
switch (me.getID()) { |
|
2009 |
case MouseEvent.MOUSE_PRESSED: |
|
2010 |
case MouseEvent.MOUSE_RELEASED: |
|
2011 |
return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) || |
|
2012 |
(numButtons > 2 && me.getButton() == MouseEvent.BUTTON3)); |
|
2013 |
case MouseEvent.MOUSE_ENTERED: |
|
2014 |
case MouseEvent.MOUSE_EXITED: |
|
2015 |
case MouseEvent.MOUSE_CLICKED: |
|
2016 |
case MouseEvent.MOUSE_DRAGGED: |
|
2017 |
return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) || |
|
2018 |
(numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)); |
|
2019 |
} |
|
2020 |
return false; |
|
2021 |
} |
|
2022 |
||
2023 |
static long reset_time_utc; |
|
5758 | 2024 |
static final long WRAP_TIME_MILLIS = 0x00000000FFFFFFFFL; |
2 | 2025 |
|
2026 |
/* |
|
2027 |
* This function converts between the X server time (number of milliseconds |
|
2028 |
* since the last server reset) and the UTC time for the 'when' field of an |
|
2029 |
* InputEvent (or another event type with a timestamp). |
|
2030 |
*/ |
|
2031 |
static long nowMillisUTC_offset(long server_offset) { |
|
2032 |
// ported from awt_util.c |
|
2033 |
/* |
|
2034 |
* Because Time is of type 'unsigned long', it is possible that Time will |
|
2035 |
* never wrap when using 64-bit Xlib. However, if a 64-bit client |
|
2036 |
* connects to a 32-bit server, I suspect the values will still wrap. So |
|
2037 |
* we should not attempt to remove the wrap checking even if _LP64 is |
|
2038 |
* true. |
|
2039 |
*/ |
|
2040 |
||
2041 |
long current_time_utc = System.currentTimeMillis(); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2042 |
if (log.isLoggable(PlatformLogger.FINER)) { |
2 | 2043 |
log.finer("reset_time=" + reset_time_utc + ", current_time=" + current_time_utc |
2044 |
+ ", server_offset=" + server_offset + ", wrap_time=" + WRAP_TIME_MILLIS); |
|
2045 |
} |
|
2046 |
||
2047 |
if ((current_time_utc - reset_time_utc) > WRAP_TIME_MILLIS) { |
|
2048 |
reset_time_utc = System.currentTimeMillis() - getCurrentServerTime(); |
|
2049 |
} |
|
2050 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2051 |
if (log.isLoggable(PlatformLogger.FINER)) { |
2 | 2052 |
log.finer("result = " + (reset_time_utc + server_offset)); |
2053 |
} |
|
2054 |
return reset_time_utc + server_offset; |
|
2055 |
} |
|
2056 |
||
2057 |
/** |
|
2058 |
* @see sun.awt.SunToolkit#needsXEmbedImpl |
|
2059 |
*/ |
|
2060 |
protected boolean needsXEmbedImpl() { |
|
2061 |
// XToolkit implements supports for XEmbed-client protocol and |
|
2062 |
// requires the supports from the embedding host for it to work. |
|
2063 |
return true; |
|
2064 |
} |
|
2065 |
||
2066 |
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { |
|
2067 |
return (modalityType == null) || |
|
2068 |
(modalityType == Dialog.ModalityType.MODELESS) || |
|
2069 |
(modalityType == Dialog.ModalityType.DOCUMENT_MODAL) || |
|
2070 |
(modalityType == Dialog.ModalityType.APPLICATION_MODAL) || |
|
2071 |
(modalityType == Dialog.ModalityType.TOOLKIT_MODAL); |
|
2072 |
} |
|
2073 |
||
2074 |
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) { |
|
2075 |
return (exclusionType == null) || |
|
2076 |
(exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) || |
|
2077 |
(exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) || |
|
2078 |
(exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE); |
|
2079 |
} |
|
2080 |
||
2081 |
static EventQueue getEventQueue(Object target) { |
|
2082 |
AppContext appContext = targetToAppContext(target); |
|
2083 |
if (appContext != null) { |
|
2084 |
return (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY); |
|
2085 |
} |
|
2086 |
return null; |
|
2087 |
} |
|
2088 |
||
13604 | 2089 |
static void removeSourceEvents(EventQueue queue, |
2090 |
Object source, |
|
2091 |
boolean removeAllEvents) { |
|
2092 |
AWTAccessor.getEventQueueAccessor() |
|
2093 |
.removeSourceEvents(queue, source, removeAllEvents); |
|
2 | 2094 |
} |
2095 |
||
2096 |
public boolean isAlwaysOnTopSupported() { |
|
107 | 2097 |
for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) { |
2 | 2098 |
if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) { |
2099 |
return true; |
|
2100 |
} |
|
2101 |
} |
|
2102 |
return false; |
|
2103 |
} |
|
2104 |
||
2105 |
public boolean useBufferPerWindow() { |
|
2106 |
return XToolkit.getBackingStoreType() == XConstants.NotUseful; |
|
2107 |
} |
|
2108 |
||
2109 |
/** |
|
2110 |
* Returns one of XConstants: NotUseful, WhenMapped or Always. |
|
2111 |
* If backing store is not available on at least one screen, or |
|
2112 |
* java2d uses DGA(which conflicts with backing store) on at least one screen, |
|
2113 |
* or the string system property "sun.awt.backingStore" is neither "Always" |
|
2114 |
* nor "WhenMapped", then the method returns XConstants.NotUseful. |
|
2115 |
* Otherwise, if the system property "sun.awt.backingStore" is "WhenMapped", |
|
2116 |
* then the method returns XConstants.WhenMapped. |
|
2117 |
* Otherwise (i.e., if the system property "sun.awt.backingStore" is "Always"), |
|
2118 |
* the method returns XConstants.Always. |
|
2119 |
*/ |
|
2120 |
static int getBackingStoreType() { |
|
2121 |
return backingStoreType; |
|
2122 |
} |
|
2123 |
||
2124 |
private static void setBackingStoreType() { |
|
2125 |
String prop = (String)AccessController.doPrivileged( |
|
2126 |
new sun.security.action.GetPropertyAction("sun.awt.backingStore")); |
|
2127 |
||
2128 |
if (prop == null) { |
|
2129 |
backingStoreType = XConstants.NotUseful; |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2130 |
if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) { |
2 | 2131 |
backingStoreLog.config("The system property sun.awt.backingStore is not set" + |
2132 |
", by default backingStore=NotUseful"); |
|
2133 |
} |
|
2134 |
return; |
|
2135 |
} |
|
2136 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2137 |
if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) { |
2 | 2138 |
backingStoreLog.config("The system property sun.awt.backingStore is " + prop); |
2139 |
} |
|
2140 |
prop = prop.toLowerCase(); |
|
2141 |
if (prop.equals("always")) { |
|
2142 |
backingStoreType = XConstants.Always; |
|
2143 |
} else if (prop.equals("whenmapped")) { |
|
2144 |
backingStoreType = XConstants.WhenMapped; |
|
2145 |
} else { |
|
2146 |
backingStoreType = XConstants.NotUseful; |
|
2147 |
} |
|
2148 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2149 |
if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) { |
2 | 2150 |
backingStoreLog.config("backingStore(as provided by the system property)=" + |
2151 |
( backingStoreType == XConstants.NotUseful ? "NotUseful" |
|
2152 |
: backingStoreType == XConstants.WhenMapped ? |
|
2153 |
"WhenMapped" : "Always") ); |
|
2154 |
} |
|
2155 |
||
2156 |
if (sun.java2d.x11.X11SurfaceData.isDgaAvailable()) { |
|
2157 |
backingStoreType = XConstants.NotUseful; |
|
2158 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2159 |
if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) { |
2 | 2160 |
backingStoreLog.config("DGA is available, backingStore=NotUseful"); |
2161 |
} |
|
2162 |
||
2163 |
return; |
|
2164 |
} |
|
2165 |
||
2166 |
awtLock(); |
|
2167 |
try { |
|
2168 |
int screenCount = XlibWrapper.ScreenCount(getDisplay()); |
|
2169 |
for (int i = 0; i < screenCount; i++) { |
|
2170 |
if (XlibWrapper.DoesBackingStore(XlibWrapper.ScreenOfDisplay(getDisplay(), i)) |
|
2171 |
== XConstants.NotUseful) { |
|
2172 |
backingStoreType = XConstants.NotUseful; |
|
2173 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2174 |
if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) { |
2 | 2175 |
backingStoreLog.config("Backing store is not available on the screen " + |
2176 |
i + ", backingStore=NotUseful"); |
|
2177 |
} |
|
2178 |
||
2179 |
return; |
|
2180 |
} |
|
2181 |
} |
|
2182 |
} finally { |
|
2183 |
awtUnlock(); |
|
2184 |
} |
|
2185 |
} |
|
2186 |
||
2187 |
/** |
|
2188 |
* One of XConstants: NotUseful, WhenMapped or Always. |
|
2189 |
*/ |
|
2190 |
private static int backingStoreType; |
|
2191 |
||
3088 | 2192 |
static final int XSUN_KP_BEHAVIOR = 1; |
2193 |
static final int XORG_KP_BEHAVIOR = 2; |
|
4370
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2194 |
static final int IS_SUN_KEYBOARD = 1; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2195 |
static final int IS_NONSUN_KEYBOARD = 2; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2196 |
static final int IS_KANA_KEYBOARD = 1; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2197 |
static final int IS_NONKANA_KEYBOARD = 2; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2198 |
|
3088 | 2199 |
|
2200 |
static int awt_IsXsunKPBehavior = 0; |
|
2 | 2201 |
static boolean awt_UseXKB = false; |
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2202 |
static boolean awt_UseXKB_Calls = false; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2203 |
static int awt_XKBBaseEventCode = 0; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2204 |
static int awt_XKBEffectiveGroup = 0; // so far, I don't use it leaving all calculations |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2205 |
// to XkbTranslateKeyCode |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2206 |
static long awt_XKBDescPtr = 0; |
3088 | 2207 |
|
2 | 2208 |
/** |
3088 | 2209 |
* Check for Xsun convention regarding numpad keys. |
2210 |
* Xsun and some other servers (i.e. derived from Xsun) |
|
2211 |
* under certain conditions process numpad keys unlike Xorg. |
|
2212 |
*/ |
|
2213 |
static boolean isXsunKPBehavior() { |
|
2 | 2214 |
awtLock(); |
2215 |
try { |
|
3088 | 2216 |
if( awt_IsXsunKPBehavior == 0 ) { |
2217 |
if( XlibWrapper.IsXsunKPBehavior(getDisplay()) ) { |
|
2218 |
awt_IsXsunKPBehavior = XSUN_KP_BEHAVIOR; |
|
2219 |
}else{ |
|
2220 |
awt_IsXsunKPBehavior = XORG_KP_BEHAVIOR; |
|
2221 |
} |
|
2 | 2222 |
} |
3088 | 2223 |
return awt_IsXsunKPBehavior == XSUN_KP_BEHAVIOR ? true : false; |
2 | 2224 |
} finally { |
2225 |
awtUnlock(); |
|
2226 |
} |
|
2227 |
} |
|
4370
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2228 |
|
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2229 |
static int sunOrNotKeyboard = 0; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2230 |
static int kanaOrNotKeyboard = 0; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2231 |
static void resetKeyboardSniffer() { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2232 |
sunOrNotKeyboard = 0; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2233 |
kanaOrNotKeyboard = 0; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2234 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2235 |
static boolean isSunKeyboard() { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2236 |
if( sunOrNotKeyboard == 0 ) { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2237 |
if( XlibWrapper.IsSunKeyboard( getDisplay() )) { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2238 |
sunOrNotKeyboard = IS_SUN_KEYBOARD; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2239 |
}else{ |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2240 |
sunOrNotKeyboard = IS_NONSUN_KEYBOARD; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2241 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2242 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2243 |
return (sunOrNotKeyboard == IS_SUN_KEYBOARD); |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2244 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2245 |
static boolean isKanaKeyboard() { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2246 |
if( kanaOrNotKeyboard == 0 ) { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2247 |
if( XlibWrapper.IsKanaKeyboard( getDisplay() )) { |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2248 |
kanaOrNotKeyboard = IS_KANA_KEYBOARD; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2249 |
}else{ |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2250 |
kanaOrNotKeyboard = IS_NONKANA_KEYBOARD; |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2251 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2252 |
} |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2253 |
return (kanaOrNotKeyboard == IS_KANA_KEYBOARD); |
cc409c51b108
5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents:
4366
diff
changeset
|
2254 |
} |
2 | 2255 |
static boolean isXKBenabled() { |
2256 |
awtLock(); |
|
2257 |
try { |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2258 |
return awt_UseXKB; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2259 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2260 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2261 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2262 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2263 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2264 |
/** |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2265 |
Query XKEYBOARD extension. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2266 |
If possible, initialize xkb library. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2267 |
*/ |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2268 |
static boolean tryXKB() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2269 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2270 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2271 |
String name = "XKEYBOARD"; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2272 |
// First, if there is extension at all. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2273 |
awt_UseXKB = XlibWrapper.XQueryExtension( getDisplay(), name, XlibWrapper.larg1, XlibWrapper.larg2, XlibWrapper.larg3); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2274 |
if( awt_UseXKB ) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2275 |
// There is a keyboard extension. Check if a client library is compatible. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2276 |
// If not, don't use xkb calls. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2277 |
// In this case we still may be Xkb-capable application. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2278 |
awt_UseXKB_Calls = XlibWrapper.XkbLibraryVersion( XlibWrapper.larg1, XlibWrapper.larg2); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2279 |
if( awt_UseXKB_Calls ) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2280 |
awt_UseXKB_Calls = XlibWrapper.XkbQueryExtension( getDisplay(), XlibWrapper.larg1, XlibWrapper.larg2, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2281 |
XlibWrapper.larg3, XlibWrapper.larg4, XlibWrapper.larg5); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2282 |
if( awt_UseXKB_Calls ) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2283 |
awt_XKBBaseEventCode = Native.getInt(XlibWrapper.larg2); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2284 |
XlibWrapper.XkbSelectEvents (getDisplay(), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2285 |
XConstants.XkbUseCoreKbd, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2286 |
XConstants.XkbNewKeyboardNotifyMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2287 |
XConstants.XkbMapNotifyMask ,//| |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2288 |
//XConstants.XkbStateNotifyMask, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2289 |
XConstants.XkbNewKeyboardNotifyMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2290 |
XConstants.XkbMapNotifyMask );//| |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2291 |
//XConstants.XkbStateNotifyMask); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2292 |
|
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2293 |
XlibWrapper.XkbSelectEventDetails(getDisplay(), XConstants.XkbUseCoreKbd, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2294 |
XConstants.XkbStateNotify, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2295 |
XConstants.XkbGroupStateMask, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2296 |
XConstants.XkbGroupStateMask); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2297 |
//XXX ? XkbGroupLockMask last, XkbAllStateComponentsMask before last? |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2298 |
awt_XKBDescPtr = XlibWrapper.XkbGetMap(getDisplay(), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2299 |
XConstants.XkbKeyTypesMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2300 |
XConstants.XkbKeySymsMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2301 |
XConstants.XkbModifierMapMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2302 |
XConstants.XkbVirtualModsMask, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2303 |
XConstants.XkbUseCoreKbd); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2304 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2305 |
} |
2 | 2306 |
} |
2307 |
return awt_UseXKB; |
|
2308 |
} finally { |
|
2309 |
awtUnlock(); |
|
2310 |
} |
|
2311 |
} |
|
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2312 |
static boolean canUseXKBCalls() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2313 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2314 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2315 |
return awt_UseXKB_Calls; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2316 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2317 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2318 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2319 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2320 |
static int getXKBEffectiveGroup() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2321 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2322 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2323 |
return awt_XKBEffectiveGroup; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2324 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2325 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2326 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2327 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2328 |
static int getXKBBaseEventCode() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2329 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2330 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2331 |
return awt_XKBBaseEventCode; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2332 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2333 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2334 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2335 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2336 |
static long getXKBKbdDesc() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2337 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2338 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2339 |
return awt_XKBDescPtr; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2340 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2341 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2342 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2343 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2344 |
void freeXKB() { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2345 |
awtLock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2346 |
try { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2347 |
if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2348 |
XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true); |
2803
e0fa1a27f1c1
6834525: PIT: RowToleranceTransitivityTest test fail with crash on rhel4 x86 and rhel 5x86
yan
parents:
2802
diff
changeset
|
2349 |
awt_XKBDescPtr = 0; |
2473
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2350 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2351 |
} finally { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2352 |
awtUnlock(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2353 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2354 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2355 |
private void processXkbChanges(XEvent ev) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2356 |
// mapping change --> refresh kbd map |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2357 |
// state change --> get a new effective group; do I really need it |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2358 |
// or that should be left for XkbTranslateKeyCode? |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2359 |
XkbEvent xke = new XkbEvent( ev.getPData() ); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2360 |
int xkb_type = xke.get_any().get_xkb_type(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2361 |
switch( xkb_type ) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2362 |
case XConstants.XkbNewKeyboardNotify : |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2363 |
if( awt_XKBDescPtr != 0 ) { |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2364 |
freeXKB(); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2365 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2366 |
awt_XKBDescPtr = XlibWrapper.XkbGetMap(getDisplay(), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2367 |
XConstants.XkbKeyTypesMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2368 |
XConstants.XkbKeySymsMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2369 |
XConstants.XkbModifierMapMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2370 |
XConstants.XkbVirtualModsMask, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2371 |
XConstants.XkbUseCoreKbd); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2372 |
//System.out.println("XkbNewKeyboard:"+(xke.get_new_kbd())); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2373 |
break; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2374 |
case XConstants.XkbMapNotify : |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2375 |
//TODO: provide a simple unit test. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2376 |
XlibWrapper.XkbGetUpdatedMap(getDisplay(), |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2377 |
XConstants.XkbKeyTypesMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2378 |
XConstants.XkbKeySymsMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2379 |
XConstants.XkbModifierMapMask | |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2380 |
XConstants.XkbVirtualModsMask, |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2381 |
awt_XKBDescPtr); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2382 |
//System.out.println("XkbMap:"+(xke.get_map())); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2383 |
break; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2384 |
case XConstants.XkbStateNotify : |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2385 |
// May use it later e.g. to obtain an effective group etc. |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2386 |
//System.out.println("XkbState:"+(xke.get_state())); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2387 |
break; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2388 |
default: |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2389 |
//System.out.println("XkbEvent of xkb_type "+xkb_type); |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2390 |
break; |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2391 |
} |
3f4bbd3be2f1
6680988: KeyEvent is still missing VK values for many keyboards
yan
parents:
2471
diff
changeset
|
2392 |
} |
2 | 2393 |
|
2394 |
private static long eventNumber; |
|
2395 |
public static long getEventNumber() { |
|
2396 |
awtLock(); |
|
2397 |
try { |
|
2398 |
return eventNumber; |
|
2399 |
} finally { |
|
2400 |
awtUnlock(); |
|
2401 |
} |
|
2402 |
} |
|
2403 |
||
2404 |
private static XEventDispatcher oops_waiter; |
|
2405 |
private static boolean oops_updated; |
|
2406 |
private static boolean oops_failed; |
|
2407 |
private XAtom oops; |
|
2408 |
private static final long WORKAROUND_SLEEP = 100; |
|
2409 |
||
2410 |
/** |
|
2411 |
* @inheritDoc |
|
2412 |
*/ |
|
2413 |
protected boolean syncNativeQueue(final long timeout) { |
|
2414 |
XBaseWindow win = XBaseWindow.getXAWTRootWindow(); |
|
2415 |
||
2416 |
if (oops_waiter == null) { |
|
2417 |
oops_waiter = new XEventDispatcher() { |
|
2418 |
public void dispatchEvent(XEvent e) { |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
2419 |
if (e.get_type() == XConstants.SelectionNotify) { |
2 | 2420 |
XSelectionEvent pe = e.get_xselection(); |
2421 |
if (pe.get_property() == oops.getAtom()) { |
|
2422 |
oops_updated = true; |
|
2423 |
awtLockNotifyAll(); |
|
2424 |
} else if (pe.get_selection() == XAtom.get("WM_S0").getAtom() && |
|
2425 |
pe.get_target() == XAtom.get("VERSION").getAtom() && |
|
2426 |
pe.get_property() == 0 && |
|
2427 |
XlibWrapper.XGetSelectionOwner(getDisplay(), XAtom.get("WM_S0").getAtom()) == 0) |
|
2428 |
{ |
|
2429 |
// WM forgot to acquire selection or there is no WM |
|
2430 |
oops_failed = true; |
|
2431 |
awtLockNotifyAll(); |
|
2432 |
} |
|
2433 |
||
2434 |
} |
|
2435 |
} |
|
2436 |
}; |
|
2437 |
} |
|
2438 |
||
2439 |
if (oops == null) { |
|
2440 |
oops = XAtom.get("OOPS"); |
|
2441 |
} |
|
2442 |
||
2443 |
awtLock(); |
|
2444 |
try { |
|
2445 |
addEventDispatcher(win.getWindow(), oops_waiter); |
|
2446 |
||
2447 |
oops_updated = false; |
|
2448 |
oops_failed = false; |
|
2449 |
// Wait for selection notify for oops on win |
|
2450 |
long event_number = getEventNumber(); |
|
2451 |
XAtom atom = XAtom.get("WM_S0"); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2452 |
eventLog.finer("WM_S0 selection owner {0}", XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom())); |
2 | 2453 |
XlibWrapper.XConvertSelection(getDisplay(), atom.getAtom(), |
2454 |
XAtom.get("VERSION").getAtom(), oops.getAtom(), |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
107
diff
changeset
|
2455 |
win.getWindow(), XConstants.CurrentTime); |
2 | 2456 |
XSync(); |
2457 |
||
2458 |
||
2459 |
eventLog.finer("Requested OOPS"); |
|
2460 |
||
2461 |
long start = System.currentTimeMillis(); |
|
2462 |
while (!oops_updated && !oops_failed) { |
|
2463 |
try { |
|
2464 |
awtLockWait(timeout); |
|
2465 |
} catch (InterruptedException e) { |
|
2466 |
throw new RuntimeException(e); |
|
2467 |
} |
|
2468 |
// This "while" is a protection from spurious |
|
2469 |
// wake-ups. However, we shouldn't wait for too long |
|
2470 |
if ((System.currentTimeMillis() - start > timeout) && timeout >= 0) { |
|
2471 |
throw new OperationTimedOut(Long.toString(System.currentTimeMillis() - start)); |
|
2472 |
} |
|
2473 |
} |
|
2474 |
if (oops_failed && getEventNumber() - event_number == 1) { |
|
2475 |
// If selection update failed we can simply wait some time |
|
2476 |
// hoping some events will arrive |
|
2477 |
awtUnlock(); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2478 |
eventLog.finest("Emergency sleep"); |
2 | 2479 |
try { |
2480 |
Thread.sleep(WORKAROUND_SLEEP); |
|
2481 |
} catch (InterruptedException ie) { |
|
2482 |
throw new RuntimeException(ie); |
|
2483 |
} finally { |
|
2484 |
awtLock(); |
|
2485 |
} |
|
2486 |
} |
|
2487 |
return getEventNumber() - event_number > 2; |
|
2488 |
} finally { |
|
2489 |
removeEventDispatcher(win.getWindow(), oops_waiter); |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3932
diff
changeset
|
2490 |
eventLog.finer("Exiting syncNativeQueue"); |
2 | 2491 |
awtUnlock(); |
2492 |
} |
|
2493 |
} |
|
2494 |
public void grab(Window w) { |
|
2495 |
if (w.getPeer() != null) { |
|
2496 |
((XWindowPeer)w.getPeer()).setGrab(true); |
|
2497 |
} |
|
2498 |
} |
|
2499 |
||
2500 |
public void ungrab(Window w) { |
|
2501 |
if (w.getPeer() != null) { |
|
2502 |
((XWindowPeer)w.getPeer()).setGrab(false); |
|
2503 |
} |
|
2504 |
} |
|
2505 |
/** |
|
2506 |
* Returns if the java.awt.Desktop class is supported on the current |
|
2507 |
* desktop. |
|
2508 |
* <p> |
|
2509 |
* The methods of java.awt.Desktop class are supported on the Gnome desktop. |
|
2510 |
* Check if the running desktop is Gnome by checking the window manager. |
|
2511 |
*/ |
|
2512 |
public boolean isDesktopSupported(){ |
|
2513 |
return XDesktopPeer.isDesktopSupported(); |
|
2514 |
} |
|
2515 |
||
2516 |
public DesktopPeer createDesktopPeer(Desktop target){ |
|
2517 |
return new XDesktopPeer(); |
|
2518 |
} |
|
2519 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
2520 |
public boolean areExtraMouseButtonsEnabled() throws HeadlessException { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
2521 |
return areExtraMouseButtonsEnabled; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1190
diff
changeset
|
2522 |
} |
2451 | 2523 |
|
2524 |
@Override |
|
2525 |
public boolean isWindowOpacitySupported() { |
|
2526 |
XNETProtocol net_protocol = XWM.getWM().getNETProtocol(); |
|
2527 |
||
2528 |
if (net_protocol == null) { |
|
2529 |
return false; |
|
2530 |
} |
|
2531 |
||
2532 |
return net_protocol.doOpacityProtocol(); |
|
2533 |
} |
|
2534 |
||
2535 |
@Override |
|
2536 |
public boolean isWindowShapingSupported() { |
|
2537 |
return XlibUtil.isShapingSupported(); |
|
2538 |
} |
|
2539 |
||
2540 |
@Override |
|
2541 |
public boolean isWindowTranslucencySupported() { |
|
2542 |
//NOTE: it may not be supported. The actual check is being performed |
|
2543 |
// at com.sun.awt.AWTUtilities(). In X11 we need to check |
|
2544 |
// whether there's any translucency-capable GC available. |
|
2545 |
return true; |
|
2546 |
} |
|
2547 |
||
2548 |
@Override |
|
2549 |
public boolean isTranslucencyCapable(GraphicsConfiguration gc) { |
|
2550 |
if (!(gc instanceof X11GraphicsConfig)) { |
|
2551 |
return false; |
|
2552 |
} |
|
2553 |
return ((X11GraphicsConfig)gc).isTranslucencyCapable(); |
|
2554 |
} |
|
2471
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2555 |
|
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2556 |
/** |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2557 |
* Returns the value of "sun.awt.disablegrab" property. Default |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2558 |
* value is {@code false}. |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2559 |
*/ |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2560 |
public static boolean getSunAwtDisableGrab() { |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2561 |
return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disablegrab")); |
71401ceec494
6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents:
2451
diff
changeset
|
2562 |
} |
2 | 2563 |
} |