2
|
1 |
/*
|
|
2 |
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
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
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
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 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.awt.X11;
|
|
27 |
|
|
28 |
import java.security.AccessController;
|
|
29 |
import java.security.PrivilegedAction;
|
|
30 |
import sun.misc.*;
|
|
31 |
|
|
32 |
public class XlibWrapper implements XConstants, XUtilConstants, XProtocolConstants,
|
|
33 |
XCursorFontConstants
|
|
34 |
{
|
|
35 |
static Unsafe unsafe = Unsafe.getUnsafe();
|
|
36 |
// strange constants
|
|
37 |
static final int MAXSIZE = 32767;
|
|
38 |
static final int MINSIZE = 1;
|
|
39 |
|
|
40 |
// define a private constructor here to prevent this class and all
|
|
41 |
// its descendants from being created
|
|
42 |
private XlibWrapper()
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
/*
|
|
47 |
Display *XOpenDisplay(display_name)
|
|
48 |
char *display_name;
|
|
49 |
|
|
50 |
*/
|
|
51 |
public final static String eventToString[]=
|
|
52 |
{"<none:0>", "<none:1>", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
|
|
53 |
"MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut",
|
|
54 |
"KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify",
|
|
55 |
"CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",
|
|
56 |
"ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify",
|
|
57 |
"ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify",
|
|
58 |
"SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify",
|
|
59 |
"ClientMessage", "MappingNotify", "LASTEvent"};
|
|
60 |
|
|
61 |
static native void XFree(long ptr);
|
|
62 |
static native void memcpy(long dest_ptr, long src_ptr, long length);
|
|
63 |
static native long getAddress(Object o);
|
|
64 |
static native void copyIntArray(long dest_ptr, Object array, int size_bytes);
|
|
65 |
static native void copyLongArray(long dest_ptr, Object array, int size_bytes);
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Gets byte string from str_ptr and copies it into byte array
|
|
69 |
* String should be NULL terminated
|
|
70 |
*/
|
|
71 |
static native byte[] getStringBytes(long str_ptr);
|
|
72 |
|
|
73 |
static native long XOpenDisplay(long display);
|
|
74 |
|
|
75 |
static native void XCloseDisplay(long display);
|
|
76 |
|
|
77 |
static native long XDisplayString(long display);
|
|
78 |
|
|
79 |
static native void XSetCloseDownMode(long display, int close_mode);
|
|
80 |
|
|
81 |
static native long DefaultScreen(long display);
|
|
82 |
|
|
83 |
static native long ScreenOfDisplay(long display, long screen_number);
|
|
84 |
|
|
85 |
static native int DoesBackingStore(long screen);
|
|
86 |
|
|
87 |
static native long DisplayWidth(long display, long screen);
|
|
88 |
static native long DisplayWidthMM(long display, long screen);
|
|
89 |
|
|
90 |
static native long DisplayHeight(long display, long screen);
|
|
91 |
static native long DisplayHeightMM(long display, long screen);
|
|
92 |
|
|
93 |
static native long RootWindow(long display, long screen_number);
|
|
94 |
static native int ScreenCount(long display);
|
|
95 |
|
|
96 |
|
|
97 |
/*
|
|
98 |
Window XCreateWindow(display, parent, x, y, width, height,
|
|
99 |
border_width, depth,
|
|
100 |
class, visual, valuemask, attributes)
|
|
101 |
Display *display;
|
|
102 |
Window parent;
|
|
103 |
int x, y;
|
|
104 |
unsigned int width, height;
|
|
105 |
unsigned int border_width;
|
|
106 |
int depth;
|
|
107 |
unsigned int class;
|
|
108 |
Visual *visual
|
|
109 |
unsigned long valuemask;
|
|
110 |
XSetWindowAttributes *attributes;
|
|
111 |
*/
|
|
112 |
|
|
113 |
static native long XCreateWindow(long display, long parent, int x,int y, int width, int height, int border_width, int depth, long wclass, long visual, long valuemask, long attributes);
|
|
114 |
|
|
115 |
static native void XDestroyWindow(long display, long window);
|
|
116 |
|
|
117 |
static native int XGrabPointer(long display, long grab_window,
|
|
118 |
int owner_events, int event_mask, int pointer_mode,
|
|
119 |
int keyboard_mode, long confine_to, long cursor, long time);
|
|
120 |
|
|
121 |
static native void XUngrabPointer(long display, long time);
|
|
122 |
|
|
123 |
static native int XGrabKeyboard(long display, long grab_window,
|
|
124 |
int owner_events, int pointer_mode,
|
|
125 |
int keyboard_mode, long time);
|
|
126 |
|
|
127 |
static native void XUngrabKeyboard(long display, long time);
|
|
128 |
|
|
129 |
static native void XGrabServer(long display);
|
|
130 |
static native void XUngrabServer(long display);
|
|
131 |
|
|
132 |
/*
|
|
133 |
|
|
134 |
void XSetWMProperties(display, w, window_name, icon_name,
|
|
135 |
argv, argc, normal_hints, wm_hints, class_hints)
|
|
136 |
Display *display;
|
|
137 |
Window w;
|
|
138 |
XTextProperty *window_name;
|
|
139 |
XTextProperty *icon_name;
|
|
140 |
char **argv;
|
|
141 |
int argc;
|
|
142 |
XSizeHints *normal_hints;
|
|
143 |
XWMHints *wm_hints;
|
|
144 |
XClassHint *class_hints;
|
|
145 |
*/
|
|
146 |
|
|
147 |
/*
|
|
148 |
|
|
149 |
XMapWindow(display, w)
|
|
150 |
Display *display;
|
|
151 |
Window w;
|
|
152 |
*/
|
|
153 |
|
|
154 |
static native void XMapWindow(long display, long window);
|
|
155 |
static native void XMapRaised(long display, long window);
|
|
156 |
static native void XRaiseWindow(long display, long window);
|
|
157 |
|
|
158 |
static native void XLowerWindow(long display, long window);
|
|
159 |
static native void XRestackWindows(long display, long windows, int length);
|
|
160 |
static native void XSetInputFocus(long display, long window);
|
|
161 |
static native void XSetInputFocus2(long display, long window, long time);
|
|
162 |
static native long XGetInputFocus(long display);
|
|
163 |
|
|
164 |
/*
|
|
165 |
|
|
166 |
XUnmapWindow(display, w)
|
|
167 |
Display *display;
|
|
168 |
Window w;
|
|
169 |
*/
|
|
170 |
|
|
171 |
static native void XUnmapWindow(long display, long window);
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
/*
|
|
177 |
XSelectInput(display, w, event_mask)
|
|
178 |
Display *display;
|
|
179 |
Window w;
|
|
180 |
long event_mask;
|
|
181 |
|
|
182 |
*/
|
|
183 |
static native void XSelectInput(long display, long window, long event_mask);
|
|
184 |
|
|
185 |
/*
|
|
186 |
XNextEvent(display, event_return)
|
|
187 |
Display *display;
|
|
188 |
XEvent *event_return;
|
|
189 |
|
|
190 |
*/
|
|
191 |
|
|
192 |
static native void XNextEvent(long display,long ptr);
|
|
193 |
|
|
194 |
/*
|
|
195 |
XMaskEvent(display, event_mask, event_return)
|
|
196 |
Display *display;
|
|
197 |
long event_mask;
|
|
198 |
XEvent *event_return;
|
|
199 |
*/
|
|
200 |
static native void XMaskEvent(long display, long event_mask, long event_return);
|
|
201 |
|
|
202 |
static native void XWindowEvent(long display, long window, long event_mask, long event_return);
|
|
203 |
|
|
204 |
/*
|
|
205 |
Bool XFilterEvent(event, w)
|
|
206 |
XEvent *event;
|
|
207 |
Window w;
|
|
208 |
*/
|
|
209 |
static native boolean XFilterEvent(long ptr, long window);
|
|
210 |
|
|
211 |
/*
|
|
212 |
Bool XSupportsLocale()
|
|
213 |
*/
|
|
214 |
static native boolean XSupportsLocale();
|
|
215 |
|
|
216 |
/*
|
|
217 |
char *XSetLocaleModifiers(modifier_list)
|
|
218 |
char *modifier_list;
|
|
219 |
*/
|
|
220 |
static native String XSetLocaleModifiers(String modifier_list);
|
|
221 |
|
|
222 |
|
|
223 |
static native int XTranslateCoordinates(
|
|
224 |
long display, long src_w, long dest_w,
|
|
225 |
long src_x, long src_y,
|
|
226 |
long dest_x_return, long dest_y_return,
|
|
227 |
long child_return);
|
|
228 |
|
|
229 |
/*
|
|
230 |
XPeekEvent(display, event_return)
|
|
231 |
Display *display;
|
|
232 |
XEvent *event_return;
|
|
233 |
|
|
234 |
*/
|
|
235 |
|
|
236 |
static native void XPeekEvent(long display,long ptr);
|
|
237 |
|
|
238 |
/*
|
|
239 |
XFlush(display)
|
|
240 |
Display *display;
|
|
241 |
*/
|
|
242 |
|
|
243 |
static native void XFlush(long display);
|
|
244 |
|
|
245 |
/*
|
|
246 |
XSync(display, discard)
|
|
247 |
Display *display;
|
|
248 |
Bool discard;
|
|
249 |
*/
|
|
250 |
|
|
251 |
static native void XSync(long display,int discard);
|
|
252 |
|
|
253 |
|
|
254 |
/* XMoveResizeWindow(display, w, x, y, width, height)
|
|
255 |
Display *display;
|
|
256 |
Window w;
|
|
257 |
int x, y;
|
|
258 |
unsigned int width, height;
|
|
259 |
*/
|
|
260 |
static native void XMoveResizeWindow(long display, long window, int x, int y, int width, int height);
|
|
261 |
static native void XResizeWindow(long display, long window, int width, int height);
|
|
262 |
static native void XMoveWindow(long display, long window, int x, int y);
|
|
263 |
|
|
264 |
/*
|
|
265 |
Bool XQueryPointer(display, w, root_return, child_return,
|
|
266 |
root_x_return, root_y_return,
|
|
267 |
win_x_return, win_y_return,
|
|
268 |
mask_return)
|
|
269 |
Display *display;
|
|
270 |
Window w;
|
|
271 |
Window *root_return, *child_return;
|
|
272 |
int *root_x_return, *root_y_return;
|
|
273 |
int *win_x_return, *win_y_return;
|
|
274 |
unsigned int *mask_return;
|
|
275 |
*/
|
|
276 |
|
|
277 |
static native boolean XQueryPointer (long display, long window, long root_return, long child_return, long root_x_return, long root_y_return, long win_x_return, long win_y_return, long mask_return);
|
|
278 |
|
|
279 |
/* XFreeCursor(display, cursor)
|
|
280 |
Display *display;
|
|
281 |
Cursor cursor;
|
|
282 |
*/
|
|
283 |
|
|
284 |
static native void XFreeCursor(long display, long cursor);
|
|
285 |
|
|
286 |
/*
|
|
287 |
XSetWindowBackground(display, w, background_pixel)
|
|
288 |
Display *display;
|
|
289 |
Window w;
|
|
290 |
unsigned long background_pixel;
|
|
291 |
*/
|
|
292 |
|
|
293 |
static native void XSetWindowBackground(long display, long window, long background_pixel);
|
|
294 |
|
|
295 |
static native int XEventsQueued(long display, int mode);
|
|
296 |
|
|
297 |
/*
|
|
298 |
Atom XInternAtom(display, atom_name, only_if_exists)
|
|
299 |
Display *display;
|
|
300 |
char *atom_name;
|
|
301 |
Bool only_if_exists;
|
|
302 |
*/
|
|
303 |
|
|
304 |
static native int XInternAtoms(long display, String[] names, boolean only_if_exists, long atoms);
|
|
305 |
|
|
306 |
static native void SetProperty(long display, long window, long atom, String str);
|
|
307 |
static native String GetProperty(long display ,long window, long atom);
|
|
308 |
static native long InternAtom(long display, String string, int only_if_exists);
|
|
309 |
static native int XGetWindowProperty(long display, long window, long atom,
|
|
310 |
long long_offset, long long_length,
|
|
311 |
long delete, long req_type, long actualy_type,
|
|
312 |
long actualy_format, long nitems_ptr,
|
|
313 |
long bytes_after, long data_ptr);
|
|
314 |
native static void XChangePropertyImpl(long display, long window, long atom,
|
|
315 |
long type, int format, int mode, long data,
|
|
316 |
int nelements);
|
|
317 |
static void XChangeProperty(long display, long window, long atom,
|
|
318 |
long type, int format, int mode, long data,
|
|
319 |
int nelements) {
|
|
320 |
// TODO: handling of XChangePropertyImpl return value, if not Success - don't cache
|
|
321 |
if (XPropertyCache.isCachingSupported() &&
|
|
322 |
XToolkit.windowToXWindow(window) != null &&
|
|
323 |
WindowPropertyGetter.isCacheableProperty(XAtom.get(atom)) &&
|
|
324 |
mode == PropModeReplace)
|
|
325 |
{
|
|
326 |
int length = (format / 8) * nelements;
|
|
327 |
XPropertyCache.storeCache(
|
|
328 |
new XPropertyCache.PropertyCacheEntry(format,
|
|
329 |
nelements,
|
|
330 |
0,
|
|
331 |
data,
|
|
332 |
length),
|
|
333 |
window,
|
|
334 |
XAtom.get(atom));
|
|
335 |
}
|
|
336 |
XChangePropertyImpl(display, window, atom, type, format, mode, data, nelements);
|
|
337 |
}
|
|
338 |
|
|
339 |
static native void XChangePropertyS(long display, long window, long atom,
|
|
340 |
long type, int format, int mode, String value);
|
|
341 |
static native void XDeleteProperty(long display, long window, long atom);
|
|
342 |
|
|
343 |
static native void XSetTransientFor(long display, long window, long transient_for_window);
|
|
344 |
static native void XSetWMHints(long display, long window, long wmhints);
|
|
345 |
static native void XGetWMHints(long display, long window, long wmhints);
|
|
346 |
static native long XAllocWMHints();
|
|
347 |
static native int XGetPointerMapping(long display, long map, int buttonNumber);
|
|
348 |
static native String XGetDefault(long display, String program, String option);
|
|
349 |
static native long getScreenOfWindow(long display, long window);
|
|
350 |
static native long XScreenNumberOfScreen(long screen);
|
|
351 |
static native int XIconifyWindow(long display, long window, long screenNumber);
|
|
352 |
static native String ServerVendor(long display);
|
|
353 |
static native int VendorRelease(long display);
|
|
354 |
|
|
355 |
static native void XBell(long display, int percent);
|
|
356 |
|
|
357 |
/*
|
|
358 |
Cursor XCreateFontCursor(display, shape)
|
|
359 |
Display *display;
|
|
360 |
unsigned int shape;
|
|
361 |
|
|
362 |
we always pass int as shape param.
|
|
363 |
perhaps later we will need to change type of shape to long.
|
|
364 |
*/
|
|
365 |
|
|
366 |
static native int XCreateFontCursor(long display, int shape);
|
|
367 |
|
|
368 |
/*
|
|
369 |
Pixmap XCreateBitmapFromData(display, d, data, width,
|
|
370 |
height)
|
|
371 |
Display *display;
|
|
372 |
Drawable d;
|
|
373 |
char *data;
|
|
374 |
unsigned int width, height;
|
|
375 |
*/
|
|
376 |
|
|
377 |
static native long XCreateBitmapFromData(long display, long drawable, long data, int width, int height);
|
|
378 |
|
|
379 |
/*
|
|
380 |
XFreePixmap(display, pixmap)
|
|
381 |
Display *display;
|
|
382 |
Pixmap pixmap;
|
|
383 |
*/
|
|
384 |
|
|
385 |
static native void XFreePixmap(long display, long pixmap);
|
|
386 |
|
|
387 |
/*
|
|
388 |
Cursor XCreatePixmapCursor(display, source, mask,
|
|
389 |
foreground_color, background_color, x, y)
|
|
390 |
Display *display;
|
|
391 |
Pixmap source;
|
|
392 |
Pixmap mask;
|
|
393 |
XColor *foreground_color;
|
|
394 |
XColor *background_color;
|
|
395 |
unsigned int x, y;
|
|
396 |
*/
|
|
397 |
static native long XCreatePixmapCursor(long display, long source, long mask, long fore, long back, int x, int y);
|
|
398 |
|
|
399 |
|
|
400 |
/*
|
|
401 |
Status XQueryBestCursor(display, d, width, height,
|
|
402 |
width_return, height_return)
|
|
403 |
Display *display;
|
|
404 |
Drawable d;
|
|
405 |
unsigned int width, height;
|
|
406 |
unsigned int *width_return, *height_return;
|
|
407 |
|
|
408 |
*/
|
|
409 |
|
|
410 |
static native boolean XQueryBestCursor(long display, long drawable, int width, int height, long width_return, long height_return);
|
|
411 |
|
|
412 |
|
|
413 |
/*
|
|
414 |
Status XAllocColor(display, colormap, screen_in_out)
|
|
415 |
Display *display;
|
|
416 |
Colormap colormap;
|
|
417 |
XColor *screen_in_out;
|
|
418 |
*/
|
|
419 |
|
|
420 |
static native boolean XAllocColor( long display, long colormap, long screen_in_out);
|
|
421 |
|
|
422 |
|
|
423 |
static native long SetToolkitErrorHandler();
|
|
424 |
static native void XSetErrorHandler(long handler);
|
|
425 |
static native int CallErrorHandler(long handler, long display, long event_ptr);
|
|
426 |
|
|
427 |
/*
|
|
428 |
XChangeWindowAttributes(display, w, valuemask, attributes)
|
|
429 |
Display *display;
|
|
430 |
Window w;
|
|
431 |
unsigned long valuemask;
|
|
432 |
XSetWindowAttributes *attributes;
|
|
433 |
*/
|
|
434 |
|
|
435 |
static native void XChangeWindowAttributes(long display, long window, long valuemask, long attributes);
|
|
436 |
static native int XGetWindowAttributes(long display, long window, long attr_ptr);
|
|
437 |
static native int XGetGeometry(long display, long drawable, long root_return, long x_return, long y_return,
|
|
438 |
long width_return, long height_return, long border_width_return, long depth_return);
|
|
439 |
|
|
440 |
static native int XGetWMNormalHints(long display, long window, long hints, long supplied_return);
|
|
441 |
static native void XSetWMNormalHints(long display, long window, long hints);
|
|
442 |
static native void XSetMinMaxHints(long display, long window, int x, int y, int width, int height, long flags);
|
|
443 |
static native long XAllocSizeHints();
|
|
444 |
|
|
445 |
static native int XSendEvent(long display, long window, boolean propagate, long event_mask, long event);
|
|
446 |
static native void XPutBackEvent(long display, long event);
|
|
447 |
static native int XQueryTree(long display, long window, long root_return, long parent_return, long children_return, long nchildren_return);
|
|
448 |
static native long XGetVisualInfo(long display, long vinfo_mask, long vinfo_template, long nitems_return);
|
|
449 |
static native void XReparentWindow(long display, long window, long parent, int x, int y);
|
|
450 |
|
|
451 |
static native void XConvertSelection(long display, long selection,
|
|
452 |
long target, long property,
|
|
453 |
long requestor, long time);
|
|
454 |
|
|
455 |
static native void XSetSelectionOwner(long display, long selection,
|
|
456 |
long owner, long time);
|
|
457 |
|
|
458 |
static native long XGetSelectionOwner(long display, long selection);
|
|
459 |
|
|
460 |
static native String XGetAtomName(long display, long atom);
|
|
461 |
|
|
462 |
static native long XMaxRequestSize(long display);
|
|
463 |
|
|
464 |
|
|
465 |
static native long XCreatePixmap(long display, long drawable, int width, int height, int depth);
|
|
466 |
static native long XCreateImage(long display, long visual_ptr, int depth, int format,
|
|
467 |
int offset, long data, int width, int height, int bitmap_pad,
|
|
468 |
int bytes_per_line);
|
|
469 |
static native void XDestroyImage(long image);
|
|
470 |
static native void XPutImage(long display, long drawable, long gc, long image,
|
|
471 |
int src_x, int src_y, int dest_x, int dest_y,
|
|
472 |
int width, int height);
|
|
473 |
static native long XCreateGC(long display, long drawable, long valuemask, long values);
|
|
474 |
static native void XFreeGC(long display, long gc);
|
|
475 |
static native void XSetWindowBackgroundPixmap(long display, long window, long pixmap);
|
|
476 |
static native void XClearWindow(long display, long window);
|
|
477 |
static native int XGetIconSizes(long display, long window, long ret_sizes, long ret_count);
|
|
478 |
static native int XdbeQueryExtension(long display, long major_version_return,
|
|
479 |
long minor_version_return);
|
|
480 |
static native boolean XQueryExtension(long display, String name, long mop_return,
|
|
481 |
long feve_return, long err_return);
|
|
482 |
static native boolean IsKeypadKey(long keysym);
|
|
483 |
static native long XdbeAllocateBackBufferName(long display, long window, int swap_action);
|
|
484 |
static native int XdbeDeallocateBackBufferName(long display, long buffer);
|
|
485 |
static native int XdbeBeginIdiom(long display);
|
|
486 |
static native int XdbeEndIdiom(long display);
|
|
487 |
static native int XdbeSwapBuffers(long display, long swap_info, int num_windows);
|
|
488 |
|
|
489 |
static native long XKeycodeToKeysym(long display, int keycode, int index);
|
|
490 |
|
|
491 |
static native int XKeysymToKeycode(long display, long keysym);
|
|
492 |
|
|
493 |
static native void XConvertCase(long keysym,
|
|
494 |
long keysym_lowercase,
|
|
495 |
long keysym_uppercase);
|
|
496 |
|
|
497 |
static native long XGetModifierMapping(long display);
|
|
498 |
|
|
499 |
static native void XFreeModifiermap(long keymap);
|
|
500 |
|
|
501 |
static native void XChangeActivePointerGrab(long display, int mask,
|
|
502 |
long cursor, long time);
|
|
503 |
|
|
504 |
/*
|
|
505 |
int (*XSynchronize(Display *display, Bool onoff))();
|
|
506 |
display Specifies the connection to the X server.
|
|
507 |
onoff Specifies a Boolean value that indicates whether to enable or disable synchronization.
|
|
508 |
*/
|
|
509 |
public static native int XSynchronize(long display, boolean onoff);
|
|
510 |
|
|
511 |
/**
|
|
512 |
* Extracts an X event that can be processed in a secondary loop.
|
|
513 |
* Should only be called on the toolkit thread.
|
|
514 |
* Returns false if this secondary event was terminated.
|
|
515 |
*/
|
|
516 |
static native boolean XNextSecondaryLoopEvent(long display, long ptr);
|
|
517 |
/**
|
|
518 |
* Terminates the topmost secondary loop (if any).
|
|
519 |
* Should never be called on the toolkit thread.
|
|
520 |
*/
|
|
521 |
static native void ExitSecondaryLoop();
|
|
522 |
|
|
523 |
/**
|
|
524 |
* Calls XTextPropertyToStringList on the specified byte array and returns
|
|
525 |
* the array of strings.
|
|
526 |
*/
|
|
527 |
static native String[] XTextPropertyToStringList(byte[] bytes, long encoding_atom);
|
|
528 |
|
|
529 |
/**
|
|
530 |
* XSHAPE extension support.
|
|
531 |
*/
|
|
532 |
static native boolean XShapeQueryExtension(long display, long event_base_return, long error_base_return);
|
|
533 |
static native void SetRectangularShape(long display, long window,
|
|
534 |
int lox, int loy, int hix, int hiy,
|
|
535 |
sun.java2d.pipe.Region region);
|
|
536 |
|
|
537 |
/* Global memory area used for X lib parameter passing */
|
|
538 |
|
|
539 |
final static long lbuffer = unsafe.allocateMemory(64); // array to hold 8 longs
|
|
540 |
final static long ibuffer = unsafe.allocateMemory(32); // array to hold 8 ints
|
|
541 |
|
|
542 |
static final long larg1 = lbuffer;
|
|
543 |
static final long larg2 = larg1+8;
|
|
544 |
static final long larg3 = larg2+8;
|
|
545 |
static final long larg4 = larg3+8;
|
|
546 |
static final long larg5 = larg4+8;
|
|
547 |
static final long larg6 = larg5+8;
|
|
548 |
static final long larg7 = larg6+8;
|
|
549 |
static final long larg8 = larg7+8;
|
|
550 |
|
|
551 |
static final long iarg1 = ibuffer;
|
|
552 |
static final long iarg2 = iarg1+4;
|
|
553 |
static final long iarg3 = iarg2+4;
|
|
554 |
static final long iarg4 = iarg3+4;
|
|
555 |
static final long iarg5 = iarg4+4;
|
|
556 |
static final long iarg6 = iarg5+4;
|
|
557 |
static final long iarg7 = iarg6+4;
|
|
558 |
static final long iarg8 = iarg7+4;
|
|
559 |
|
|
560 |
|
|
561 |
static int dataModel;
|
|
562 |
static final boolean isBuildInternal;
|
|
563 |
|
|
564 |
static {
|
|
565 |
String dataModelProp = (String)AccessController.doPrivileged(
|
|
566 |
new PrivilegedAction() {
|
|
567 |
public Object run() {
|
|
568 |
return System.getProperty("sun.arch.data.model");
|
|
569 |
}
|
|
570 |
});
|
|
571 |
try {
|
|
572 |
dataModel = Integer.parseInt(dataModelProp);
|
|
573 |
} catch (Exception e) {
|
|
574 |
dataModel = 32;
|
|
575 |
}
|
|
576 |
|
|
577 |
isBuildInternal = getBuildInternal();
|
|
578 |
|
|
579 |
// System.loadLibrary("mawt");
|
|
580 |
}
|
|
581 |
|
|
582 |
static int getDataModel() {
|
|
583 |
return dataModel;
|
|
584 |
}
|
|
585 |
|
|
586 |
static String hintsToString(long flags) {
|
|
587 |
StringBuffer buf = new StringBuffer();
|
|
588 |
if ((flags & PMaxSize) != 0) {
|
|
589 |
buf.append("PMaxSize ");
|
|
590 |
}
|
|
591 |
if ((flags & PMinSize) != 0) {
|
|
592 |
buf.append("PMinSize ");
|
|
593 |
}
|
|
594 |
if ((flags & USSize) != 0) {
|
|
595 |
buf.append("USSize ");
|
|
596 |
}
|
|
597 |
if ((flags & USPosition) != 0) {
|
|
598 |
buf.append("USPosition ");
|
|
599 |
}
|
|
600 |
if ((flags & PPosition) != 0) {
|
|
601 |
buf.append("PPosition ");
|
|
602 |
}
|
|
603 |
if ((flags & PSize) != 0) {
|
|
604 |
buf.append("PSize ");
|
|
605 |
}
|
|
606 |
if ((flags & PWinGravity) != 0) {
|
|
607 |
buf.append("PWinGravity ");
|
|
608 |
}
|
|
609 |
return buf.toString();
|
|
610 |
}
|
|
611 |
|
|
612 |
private static boolean getBuildInternal() {
|
|
613 |
String javaVersion = XToolkit.getSystemProperty("java.version");
|
|
614 |
return javaVersion != null && javaVersion.contains("internal");
|
|
615 |
}
|
|
616 |
}
|