author | pchelko |
Wed, 19 Jun 2013 17:12:23 +0400 | |
changeset 18135 | d9be76f1a19c |
parent 17679 | a81555868357 |
child 18295 | 4fed9f71df91 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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 |
||
26 |
#include "awt_p.h" |
|
27 |
#include "awt.h" |
|
28 |
#include "color.h" |
|
29 |
#include <java_awt_DisplayMode.h> |
|
30 |
#include <sun_awt_X11GraphicsEnvironment.h> |
|
31 |
#include <sun_awt_X11GraphicsDevice.h> |
|
32 |
#include <sun_awt_X11GraphicsConfig.h> |
|
33 |
#ifndef HEADLESS |
|
34 |
#include <X11/extensions/Xdbe.h> |
|
35 |
#include <X11/XKBlib.h> |
|
36 |
#include "Xrandr.h" |
|
37 |
#include "GLXGraphicsConfig.h" |
|
38 |
#endif /* !HEADLESS */ |
|
39 |
||
40 |
#include <jni.h> |
|
41 |
#include <jni_util.h> |
|
42 |
#include <jvm.h> |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
43 |
#include <jvm_md.h> |
2 | 44 |
#include <jlong.h> |
45 |
||
46 |
#include <stdlib.h> |
|
47 |
||
48 |
#include "awt_GraphicsEnv.h" |
|
49 |
#include "awt_util.h" |
|
50 |
#include "gdefs.h" |
|
51 |
#include <dlfcn.h> |
|
52 |
#include "Trace.h" |
|
53 |
||
54 |
#ifdef NETSCAPE |
|
55 |
#include <signal.h> |
|
56 |
extern int awt_init_xt; |
|
57 |
#endif |
|
58 |
||
59 |
#ifndef HEADLESS |
|
60 |
||
61 |
int awt_numScreens; /* Xinerama-aware number of screens */ |
|
62 |
||
63 |
AwtScreenDataPtr x11Screens; |
|
64 |
||
65 |
/* |
|
66 |
* Set in initDisplay() to indicate whether we should attempt to initialize |
|
67 |
* GLX for the default configuration. |
|
68 |
*/ |
|
69 |
static jboolean glxRequested = JNI_FALSE; |
|
70 |
||
71 |
#endif /* !HEADLESS */ |
|
72 |
||
73 |
#ifdef HEADLESS |
|
74 |
#define Display void |
|
75 |
#endif /* HEADLESS */ |
|
76 |
||
77 |
Display *awt_display; |
|
78 |
||
79 |
jclass tkClass = NULL; |
|
80 |
jmethodID awtLockMID = NULL; |
|
81 |
jmethodID awtUnlockMID = NULL; |
|
82 |
jmethodID awtWaitMID = NULL; |
|
83 |
jmethodID awtNotifyMID = NULL; |
|
84 |
jmethodID awtNotifyAllMID = NULL; |
|
85 |
jboolean awtLockInited = JNI_FALSE; |
|
86 |
||
87 |
/** Convenience macro for loading the lock-related method IDs. */ |
|
88 |
#define GET_STATIC_METHOD(klass, method_id, method_name, method_sig) \ |
|
89 |
do { \ |
|
90 |
method_id = (*env)->GetStaticMethodID(env, klass, \ |
|
91 |
method_name, method_sig); \ |
|
92 |
if (method_id == NULL) return NULL; \ |
|
93 |
} while (0) |
|
94 |
||
95 |
struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
|
96 |
struct X11GraphicsDeviceIDs x11GraphicsDeviceIDs; |
|
97 |
||
98 |
#ifndef HEADLESS |
|
99 |
int awtCreateX11Colormap(AwtGraphicsConfigDataPtr adata); |
|
100 |
#endif /* HEADLESS */ |
|
101 |
||
102 |
static char *x11GraphicsConfigClassName = "sun/awt/X11GraphicsConfig"; |
|
103 |
||
104 |
/* AWT and Xinerama |
|
105 |
* |
|
106 |
* As of fix 4356756, AWT is Xinerama-aware. X11GraphicsDevices are created for |
|
107 |
* each screen of a Xinerama setup, though X11 itself still only sees a single |
|
108 |
* display. |
|
109 |
* In many places where we talk to X11, a xinawareScreen variable is used to |
|
110 |
* pass the correct Display value, depending on the circumstances (a single |
|
111 |
* X display, multiple X displays, or a single X display with multiple |
|
112 |
* Xinerama screens). |
|
113 |
* |
|
114 |
* Solaris and Linux differ in the functions used to access Xinerama-related |
|
115 |
* data. This is in part because at this time, the X consortium has not |
|
116 |
* finalized the "official" Xinerama API. Once this spec is available, and |
|
117 |
* both OSes are conformant, one code base should be sufficient for Xinerama |
|
118 |
* operation on both OSes. Until then, some of the Xinerama-related code |
|
119 |
* is ifdef'd appropriately. -bchristi, 7/12/01 |
|
120 |
*/ |
|
121 |
||
122 |
#define MAXFRAMEBUFFERS 16 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
123 |
#if defined(__linux__) || defined(MACOSX) |
2 | 124 |
typedef struct { |
125 |
int screen_number; |
|
126 |
short x_org; |
|
127 |
short y_org; |
|
128 |
short width; |
|
129 |
short height; |
|
130 |
} XineramaScreenInfo; |
|
131 |
||
132 |
typedef XineramaScreenInfo* XineramaQueryScreensFunc(Display*, int*); |
|
133 |
||
134 |
#else /* SOLARIS */ |
|
135 |
typedef Status XineramaGetInfoFunc(Display* display, int screen_number, |
|
136 |
XRectangle* framebuffer_rects, unsigned char* framebuffer_hints, |
|
137 |
int* num_framebuffers); |
|
138 |
typedef Status XineramaGetCenterHintFunc(Display* display, int screen_number, |
|
139 |
int* x, int* y); |
|
140 |
||
141 |
XineramaGetCenterHintFunc* XineramaSolarisCenterFunc = NULL; |
|
142 |
#endif |
|
143 |
||
144 |
Bool usingXinerama = False; |
|
145 |
XRectangle fbrects[MAXFRAMEBUFFERS]; |
|
146 |
||
147 |
JNIEXPORT void JNICALL |
|
148 |
Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls) |
|
149 |
{ |
|
150 |
x11GraphicsConfigIDs.aData = NULL; |
|
151 |
x11GraphicsConfigIDs.bitsPerPixel = NULL; |
|
152 |
x11GraphicsConfigIDs.screen = NULL; |
|
153 |
||
154 |
x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J"); |
|
155 |
x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I"); |
|
156 |
x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;"); |
|
157 |
||
158 |
if (x11GraphicsConfigIDs.aData == NULL || |
|
159 |
x11GraphicsConfigIDs.bitsPerPixel == NULL || |
|
160 |
x11GraphicsConfigIDs.screen == NULL) { |
|
161 |
||
162 |
JNU_ThrowNoSuchFieldError(env, "Can't find a field"); |
|
163 |
return; |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
JNIEXPORT void JNICALL |
|
168 |
Java_sun_awt_X11GraphicsDevice_initIDs (JNIEnv *env, jclass cls) |
|
169 |
{ |
|
170 |
x11GraphicsDeviceIDs.screen = NULL; |
|
171 |
x11GraphicsDeviceIDs.screen = (*env)->GetFieldID (env, cls, "screen", "I"); |
|
172 |
DASSERT(x11GraphicsDeviceIDs.screen); |
|
173 |
} |
|
174 |
||
175 |
#ifndef HEADLESS |
|
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2760
diff
changeset
|
176 |
|
2 | 177 |
/* |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2760
diff
changeset
|
178 |
* XIOErrorHandler |
2 | 179 |
*/ |
2802
d05a9dcc8296
6678385: Random java.lang.StackOverflowError from various JDKs
art
parents:
2760
diff
changeset
|
180 |
static int xioerror_handler(Display *disp) |
2 | 181 |
{ |
182 |
if (awtLockInited) { |
|
183 |
if (errno == EPIPE) { |
|
184 |
jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL)); |
|
185 |
} |
|
186 |
/*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", "I/O error"); */ |
|
187 |
} |
|
188 |
return 0; |
|
189 |
} |
|
190 |
||
191 |
static AwtGraphicsConfigDataPtr |
|
192 |
findWithTemplate(XVisualInfo *vinfo, |
|
193 |
long mask) |
|
194 |
{ |
|
195 |
||
196 |
XVisualInfo *visualList; |
|
197 |
XColor color; |
|
198 |
AwtGraphicsConfigDataPtr defaultConfig; |
|
199 |
int visualsMatched, i; |
|
200 |
||
201 |
visualList = XGetVisualInfo(awt_display, |
|
202 |
mask, vinfo, &visualsMatched); |
|
203 |
if (visualList) { |
|
204 |
defaultConfig = ZALLOC(_AwtGraphicsConfigData); |
|
205 |
for (i = 0; i < visualsMatched; i++) { |
|
206 |
memcpy(&defaultConfig->awt_visInfo, &visualList[i], sizeof(XVisualInfo)); |
|
207 |
defaultConfig->awt_depth = visualList[i].depth; |
|
208 |
||
209 |
/* we can't use awtJNI_CreateColorData here, because it'll pull, |
|
210 |
SystemColor, which in turn will cause toolkit to be reinitialized */ |
|
211 |
if (awtCreateX11Colormap(defaultConfig)) { |
|
212 |
/* Allocate white and black pixels for this visual */ |
|
213 |
color.flags = DoRed | DoGreen | DoBlue; |
|
214 |
color.red = color.green = color.blue = 0x0000; |
|
215 |
XAllocColor(awt_display, defaultConfig->awt_cmap, &color); |
|
216 |
x11Screens[visualList[i].screen].blackpixel = color.pixel; |
|
217 |
color.flags = DoRed | DoGreen | DoBlue; |
|
218 |
color.red = color.green = color.blue = 0xffff; |
|
219 |
XAllocColor(awt_display, defaultConfig->awt_cmap, &color); |
|
220 |
x11Screens[visualList[i].screen].whitepixel = color.pixel; |
|
221 |
||
222 |
XFree(visualList); |
|
223 |
return defaultConfig; |
|
224 |
} |
|
225 |
} |
|
226 |
XFree(visualList); |
|
227 |
free((void *)defaultConfig); |
|
228 |
} |
|
229 |
return NULL; |
|
230 |
} |
|
231 |
||
232 |
/* default config is based on X11 screen. All Xinerama screens of that X11 |
|
233 |
screen will have the same default config */ |
|
234 |
/* Need more notes about which fields of the structure are based on the X |
|
235 |
screen, and which are based on the Xinerama screen */ |
|
236 |
static AwtGraphicsConfigDataPtr |
|
237 |
makeDefaultConfig(JNIEnv *env, int screen) { |
|
238 |
||
239 |
AwtGraphicsConfigDataPtr defaultConfig; |
|
240 |
int xinawareScreen = 0; |
|
8745
6b9548badbaf
7022280: Parfait reports Format string argument mismatch in /jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
bae
parents:
5506
diff
changeset
|
241 |
VisualID forcedVisualID = 0, defaultVisualID; |
2 | 242 |
char *forcedVisualStr; |
243 |
XVisualInfo vinfo; |
|
244 |
long mask; |
|
245 |
||
246 |
xinawareScreen = usingXinerama ? 0 : screen; |
|
247 |
defaultVisualID = |
|
248 |
XVisualIDFromVisual(DefaultVisual(awt_display, xinawareScreen)); |
|
249 |
||
250 |
memset(&vinfo, 0, sizeof(XVisualInfo)); |
|
251 |
vinfo.screen = xinawareScreen; |
|
252 |
||
253 |
if ((forcedVisualStr = getenv("FORCEDEFVIS"))) { |
|
254 |
mask = VisualIDMask | VisualScreenMask; |
|
8745
6b9548badbaf
7022280: Parfait reports Format string argument mismatch in /jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
bae
parents:
5506
diff
changeset
|
255 |
if (sscanf(forcedVisualStr, "%lx", &forcedVisualID) > 0 && |
2 | 256 |
forcedVisualID > 0) |
257 |
{ |
|
258 |
vinfo.visualid = forcedVisualID; |
|
259 |
} else { |
|
260 |
vinfo.visualid = defaultVisualID; |
|
261 |
} |
|
262 |
} else { |
|
263 |
VisualID bestGLXVisualID; |
|
264 |
if (glxRequested && |
|
265 |
(bestGLXVisualID = GLXGC_FindBestVisual(env, xinawareScreen)) > 0) |
|
266 |
{ |
|
267 |
/* we've found the best visual for use with GLX, so use it */ |
|
268 |
vinfo.visualid = bestGLXVisualID; |
|
269 |
mask = VisualIDMask | VisualScreenMask; |
|
270 |
} else { |
|
271 |
/* otherwise, continue looking for the best X11 visual */ |
|
272 |
vinfo.depth = 24; |
|
273 |
vinfo.class = TrueColor; |
|
274 |
mask = VisualDepthMask | VisualScreenMask | VisualClassMask; |
|
275 |
} |
|
276 |
} |
|
277 |
||
278 |
/* try the best, or forced visual */ |
|
279 |
defaultConfig = findWithTemplate(&vinfo, mask); |
|
280 |
if (defaultConfig) { |
|
281 |
return defaultConfig; |
|
282 |
} |
|
283 |
||
284 |
/* try the default visual */ |
|
285 |
vinfo.visualid = defaultVisualID; |
|
286 |
mask = VisualIDMask | VisualScreenMask; |
|
287 |
defaultConfig = findWithTemplate(&vinfo, mask); |
|
288 |
if (defaultConfig) { |
|
289 |
return defaultConfig; |
|
290 |
} |
|
291 |
||
292 |
/* try any TrueColor */ |
|
293 |
vinfo.class = TrueColor; |
|
294 |
mask = VisualScreenMask | VisualClassMask; |
|
295 |
defaultConfig = findWithTemplate(&vinfo, mask); |
|
296 |
if (defaultConfig) { |
|
297 |
return defaultConfig; |
|
298 |
} |
|
299 |
||
300 |
/* try 8-bit PseudoColor */ |
|
301 |
vinfo.depth = 8; |
|
302 |
vinfo.class = PseudoColor; |
|
303 |
mask = VisualDepthMask | VisualScreenMask | VisualClassMask; |
|
304 |
defaultConfig = findWithTemplate(&vinfo, mask); |
|
305 |
if (defaultConfig) { |
|
306 |
return defaultConfig; |
|
307 |
} |
|
308 |
||
309 |
/* try any 8-bit */ |
|
310 |
vinfo.depth = 8; |
|
311 |
mask = VisualDepthMask | VisualScreenMask; |
|
312 |
defaultConfig = findWithTemplate(&vinfo, mask); |
|
313 |
if (defaultConfig) { |
|
314 |
return defaultConfig; |
|
315 |
} |
|
316 |
||
317 |
/* we tried everything, give up */ |
|
318 |
JNU_ThrowInternalError(env, "Can't find supported visual"); |
|
319 |
XCloseDisplay(awt_display); |
|
320 |
awt_display = NULL; |
|
321 |
return NULL; |
|
322 |
} |
|
323 |
||
324 |
static void |
|
325 |
getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) { |
|
326 |
||
327 |
int i; |
|
328 |
int n8p=0, n12p=0, n8s=0, n8gs=0, n8sg=0, n1sg=0, nTrue=0; |
|
329 |
int nConfig; |
|
330 |
XVisualInfo *pVI8p, *pVI12p, *pVI8s, *pVITrue, *pVI8gs, |
|
331 |
*pVI8sg, *pVI1sg = NULL, viTmp; |
|
332 |
AwtGraphicsConfigDataPtr *graphicsConfigs; |
|
333 |
AwtGraphicsConfigDataPtr defaultConfig; |
|
334 |
int ind; |
|
335 |
char errmsg[128]; |
|
336 |
int xinawareScreen; |
|
2451 | 337 |
void* xrenderLibHandle = NULL; |
2955
9327f093140c
6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents:
2807
diff
changeset
|
338 |
XRenderFindVisualFormatFunc* xrenderFindVisualFormat = NULL; |
2451 | 339 |
int major_opcode, first_event, first_error; |
2 | 340 |
|
341 |
if (usingXinerama) { |
|
342 |
xinawareScreen = 0; |
|
343 |
} |
|
344 |
else { |
|
345 |
xinawareScreen = screen; |
|
346 |
} |
|
347 |
||
348 |
AWT_LOCK (); |
|
349 |
||
350 |
viTmp.screen = xinawareScreen; |
|
351 |
||
352 |
viTmp.depth = 8; |
|
353 |
viTmp.class = PseudoColor; |
|
354 |
viTmp.colormap_size = 256; |
|
355 |
pVI8p = XGetVisualInfo (awt_display, |
|
356 |
VisualDepthMask | VisualClassMask | |
|
357 |
VisualColormapSizeMask | VisualScreenMask, |
|
358 |
&viTmp, &n8p); |
|
359 |
||
360 |
viTmp.depth = 12; |
|
361 |
viTmp.class = PseudoColor; |
|
362 |
viTmp.colormap_size = 4096; |
|
363 |
pVI12p = XGetVisualInfo (awt_display, |
|
364 |
VisualDepthMask | VisualClassMask | |
|
365 |
VisualColormapSizeMask | VisualScreenMask, |
|
366 |
&viTmp, &n12p); |
|
367 |
||
368 |
viTmp.class = TrueColor; |
|
369 |
pVITrue = XGetVisualInfo (awt_display, |
|
370 |
VisualClassMask | |
|
371 |
VisualScreenMask, |
|
372 |
&viTmp, &nTrue); |
|
373 |
||
374 |
viTmp.depth = 8; |
|
375 |
viTmp.class = StaticColor; |
|
376 |
pVI8s = XGetVisualInfo (awt_display, VisualDepthMask | VisualClassMask | |
|
377 |
VisualScreenMask, &viTmp, &n8s); |
|
378 |
||
379 |
viTmp.depth = 8; |
|
380 |
viTmp.class = GrayScale; |
|
381 |
viTmp.colormap_size = 256; |
|
382 |
pVI8gs = XGetVisualInfo (awt_display, |
|
383 |
VisualDepthMask | VisualClassMask | |
|
384 |
VisualColormapSizeMask | VisualScreenMask, |
|
385 |
&viTmp, &n8gs); |
|
386 |
viTmp.depth = 8; |
|
387 |
viTmp.class = StaticGray; |
|
388 |
viTmp.colormap_size = 256; |
|
389 |
pVI8sg = XGetVisualInfo (awt_display, |
|
390 |
VisualDepthMask | VisualClassMask | |
|
391 |
VisualColormapSizeMask | VisualScreenMask, |
|
392 |
&viTmp, &n8sg); |
|
393 |
||
394 |
/* REMIND.. remove when we have support for the color classes below */ |
|
395 |
/* viTmp.depth = 1; */ |
|
396 |
/* viTmp.class = StaticGray; */ |
|
397 |
/* pVI1sg = XGetVisualInfo (awt_display, VisualDepthMask | VisualClassMask, */ |
|
398 |
/* viTmp, &n1sg); */ |
|
399 |
||
400 |
nConfig = n8p + n12p + n8s + n8gs + n8sg + n1sg + nTrue + 1; |
|
401 |
graphicsConfigs = (AwtGraphicsConfigDataPtr *) |
|
402 |
calloc(nConfig, sizeof(AwtGraphicsConfigDataPtr)); |
|
403 |
if (graphicsConfigs == NULL) { |
|
404 |
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), |
|
405 |
NULL); |
|
406 |
AWT_UNLOCK(); |
|
407 |
return; |
|
408 |
} |
|
409 |
||
410 |
if (screenDataPtr->defaultConfig == NULL) { |
|
411 |
/* |
|
412 |
* After a display change event, the default config field will have |
|
413 |
* been reset, so we need to recreate the default config here. |
|
414 |
*/ |
|
415 |
screenDataPtr->defaultConfig = makeDefaultConfig(env, screen); |
|
416 |
} |
|
417 |
||
418 |
defaultConfig = screenDataPtr->defaultConfig; |
|
419 |
graphicsConfigs[0] = defaultConfig; |
|
420 |
nConfig = 1; /* reserve index 0 for default config */ |
|
421 |
||
2451 | 422 |
// Only use the RENDER extension if it is available on the X server |
423 |
if (XQueryExtension(awt_display, "RENDER", |
|
424 |
&major_opcode, &first_event, &first_error)) |
|
425 |
{ |
|
426 |
xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL); |
|
427 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
428 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
429 |
#define XRENDER_LIB "/usr/X11/lib/libXrender.dylib" |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
430 |
#else |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
431 |
#define XRENDER_LIB "libXrender.so" |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
432 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
433 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
434 |
if (xrenderLibHandle == NULL) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
435 |
xrenderLibHandle = dlopen(XRENDER_LIB, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
436 |
RTLD_LAZY | RTLD_GLOBAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
437 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
438 |
|
2451 | 439 |
#ifndef __linux__ /* SOLARIS */ |
440 |
if (xrenderLibHandle == NULL) { |
|
441 |
xrenderLibHandle = dlopen("/usr/sfw/lib/libXrender.so.1", |
|
442 |
RTLD_LAZY | RTLD_GLOBAL); |
|
443 |
} |
|
444 |
#endif |
|
445 |
||
446 |
if (xrenderLibHandle != NULL) { |
|
2955
9327f093140c
6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents:
2807
diff
changeset
|
447 |
xrenderFindVisualFormat = |
2451 | 448 |
(XRenderFindVisualFormatFunc*)dlsym(xrenderLibHandle, |
449 |
"XRenderFindVisualFormat"); |
|
450 |
} |
|
451 |
} |
|
452 |
||
2 | 453 |
for (i = 0; i < nTrue; i++) { |
454 |
if (XVisualIDFromVisual(pVITrue[i].visual) == |
|
455 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual) || |
|
456 |
pVITrue[i].depth == 12) { |
|
457 |
/* Skip the non-supported 12-bit TrueColor visual */ |
|
458 |
continue; |
|
459 |
} else { |
|
460 |
ind = nConfig++; |
|
461 |
} |
|
462 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
463 |
graphicsConfigs [ind]->awt_depth = pVITrue [i].depth; |
|
464 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i], |
|
465 |
sizeof (XVisualInfo)); |
|
2955
9327f093140c
6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents:
2807
diff
changeset
|
466 |
if (xrenderFindVisualFormat != NULL) { |
9327f093140c
6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents:
2807
diff
changeset
|
467 |
XRenderPictFormat *format = xrenderFindVisualFormat (awt_display, |
2451 | 468 |
pVITrue [i].visual); |
469 |
if (format && |
|
470 |
format->type == PictTypeDirect && |
|
471 |
format->direct.alphaMask) |
|
472 |
{ |
|
473 |
graphicsConfigs [ind]->isTranslucencySupported = 1; |
|
2807 | 474 |
memcpy(&graphicsConfigs [ind]->renderPictFormat, format, |
475 |
sizeof(*format)); |
|
2451 | 476 |
} |
477 |
} |
|
478 |
} |
|
479 |
||
480 |
if (xrenderLibHandle != NULL) { |
|
481 |
dlclose(xrenderLibHandle); |
|
482 |
xrenderLibHandle = NULL; |
|
2 | 483 |
} |
484 |
||
485 |
for (i = 0; i < n8p; i++) { |
|
486 |
if (XVisualIDFromVisual(pVI8p[i].visual) == |
|
487 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
488 |
continue; |
|
489 |
} else { |
|
490 |
ind = nConfig++; |
|
491 |
} |
|
492 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
493 |
graphicsConfigs [ind]->awt_depth = pVI8p [i].depth; |
|
494 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8p [i], |
|
495 |
sizeof (XVisualInfo)); |
|
496 |
} |
|
497 |
||
498 |
for (i = 0; i < n12p; i++) { |
|
499 |
if (XVisualIDFromVisual(pVI12p[i].visual) == |
|
500 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
501 |
continue; |
|
502 |
} else { |
|
503 |
ind = nConfig++; |
|
504 |
} |
|
505 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
506 |
graphicsConfigs [ind]->awt_depth = pVI12p [i].depth; |
|
507 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI12p [i], |
|
508 |
sizeof (XVisualInfo)); |
|
509 |
} |
|
510 |
||
511 |
for (i = 0; i < n8s; i++) { |
|
512 |
if (XVisualIDFromVisual(pVI8s[i].visual) == |
|
513 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
514 |
continue; |
|
515 |
} else { |
|
516 |
ind = nConfig++; |
|
517 |
} |
|
518 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
519 |
graphicsConfigs [ind]->awt_depth = pVI8s [i].depth; |
|
520 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8s [i], |
|
521 |
sizeof (XVisualInfo)); |
|
522 |
} |
|
523 |
||
524 |
for (i = 0; i < n8gs; i++) { |
|
525 |
if (XVisualIDFromVisual(pVI8gs[i].visual) == |
|
526 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
527 |
continue; |
|
528 |
} else { |
|
529 |
ind = nConfig++; |
|
530 |
} |
|
531 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
532 |
graphicsConfigs [ind]->awt_depth = pVI8gs [i].depth; |
|
533 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8gs [i], |
|
534 |
sizeof (XVisualInfo)); |
|
535 |
} |
|
536 |
||
537 |
for (i = 0; i < n8sg; i++) { |
|
538 |
if (XVisualIDFromVisual(pVI8sg[i].visual) == |
|
539 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
540 |
continue; |
|
541 |
} else { |
|
542 |
ind = nConfig++; |
|
543 |
} |
|
544 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
545 |
graphicsConfigs [ind]->awt_depth = pVI8sg [i].depth; |
|
546 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8sg [i], |
|
547 |
sizeof (XVisualInfo)); |
|
548 |
} |
|
549 |
||
550 |
for (i = 0; i < n1sg; i++) { |
|
551 |
if (XVisualIDFromVisual(pVI1sg[i].visual) == |
|
552 |
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { |
|
553 |
continue; |
|
554 |
} else { |
|
555 |
ind = nConfig++; |
|
556 |
} |
|
557 |
graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); |
|
558 |
graphicsConfigs [ind]->awt_depth = pVI1sg [i].depth; |
|
559 |
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI1sg [i], |
|
560 |
sizeof (XVisualInfo)); |
|
561 |
} |
|
562 |
||
563 |
if (n8p != 0) |
|
564 |
XFree (pVI8p); |
|
565 |
if (n12p != 0) |
|
566 |
XFree (pVI12p); |
|
567 |
if (n8s != 0) |
|
568 |
XFree (pVI8s); |
|
569 |
if (n8gs != 0) |
|
570 |
XFree (pVI8gs); |
|
571 |
if (n8sg != 0) |
|
572 |
XFree (pVI8sg); |
|
573 |
if (n1sg != 0) |
|
574 |
XFree (pVI1sg); |
|
575 |
||
576 |
screenDataPtr->numConfigs = nConfig; |
|
577 |
screenDataPtr->configs = graphicsConfigs; |
|
578 |
||
579 |
AWT_UNLOCK (); |
|
580 |
} |
|
581 |
||
582 |
#ifndef HEADLESS |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
583 |
#if defined(__linux__) || defined(MACOSX) |
2 | 584 |
static void xinerama_init_linux() |
585 |
{ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
586 |
void* libHandle = NULL; |
2 | 587 |
int32_t locNumScr = 0; |
588 |
XineramaScreenInfo *xinInfo; |
|
589 |
char* XineramaQueryScreensName = "XineramaQueryScreens"; |
|
590 |
XineramaQueryScreensFunc* XineramaQueryScreens = NULL; |
|
591 |
||
592 |
/* load library */ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
593 |
libHandle = dlopen(VERSIONED_JNI_LIB_NAME("Xinerama", "1"), |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
594 |
RTLD_LAZY | RTLD_GLOBAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
595 |
if (libHandle == NULL) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
596 |
libHandle = dlopen(JNI_LIB_NAME("Xinerama"), RTLD_LAZY | RTLD_GLOBAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
597 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
598 |
if (libHandle != NULL) { |
2 | 599 |
XineramaQueryScreens = (XineramaQueryScreensFunc*) |
600 |
dlsym(libHandle, XineramaQueryScreensName); |
|
601 |
||
602 |
if (XineramaQueryScreens != NULL) { |
|
603 |
DTRACE_PRINTLN("calling XineramaQueryScreens func on Linux"); |
|
604 |
xinInfo = (*XineramaQueryScreens)(awt_display, &locNumScr); |
|
556 | 605 |
if (xinInfo != NULL && locNumScr > XScreenCount(awt_display)) { |
2 | 606 |
int32_t idx; |
607 |
DTRACE_PRINTLN("Enabling Xinerama support"); |
|
608 |
usingXinerama = True; |
|
609 |
/* set global number of screens */ |
|
610 |
DTRACE_PRINTLN1(" num screens = %i\n", locNumScr); |
|
611 |
awt_numScreens = locNumScr; |
|
612 |
||
613 |
/* stuff values into fbrects */ |
|
614 |
for (idx = 0; idx < awt_numScreens; idx++) { |
|
615 |
DASSERT(xinInfo[idx].screen_number == idx); |
|
616 |
||
617 |
fbrects[idx].width = xinInfo[idx].width; |
|
618 |
fbrects[idx].height = xinInfo[idx].height; |
|
619 |
fbrects[idx].x = xinInfo[idx].x_org; |
|
620 |
fbrects[idx].y = xinInfo[idx].y_org; |
|
621 |
} |
|
622 |
} else { |
|
623 |
DTRACE_PRINTLN("calling XineramaQueryScreens didn't work"); |
|
624 |
} |
|
625 |
} else { |
|
626 |
DTRACE_PRINTLN("couldn't load XineramaQueryScreens symbol"); |
|
627 |
} |
|
628 |
dlclose(libHandle); |
|
629 |
} else { |
|
630 |
DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror()); |
|
631 |
} |
|
632 |
} |
|
633 |
#endif |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
634 |
#if !defined(__linux__) && !defined(MACOSX) /* Solaris */ |
2 | 635 |
static void xinerama_init_solaris() |
636 |
{ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
637 |
void* libHandle = NULL; |
2 | 638 |
unsigned char fbhints[MAXFRAMEBUFFERS]; |
639 |
int32_t locNumScr = 0; |
|
640 |
/* load and run XineramaGetInfo */ |
|
641 |
char* XineramaGetInfoName = "XineramaGetInfo"; |
|
642 |
char* XineramaGetCenterHintName = "XineramaGetCenterHint"; |
|
643 |
XineramaGetInfoFunc* XineramaSolarisFunc = NULL; |
|
644 |
||
645 |
/* load library */ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
646 |
libHandle = dlopen(JNI_LIB_NAME("Xext"), RTLD_LAZY | RTLD_GLOBAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
647 |
if (libHandle != NULL) { |
2 | 648 |
XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName); |
649 |
XineramaSolarisCenterFunc = |
|
650 |
(XineramaGetCenterHintFunc*)dlsym(libHandle, XineramaGetCenterHintName); |
|
651 |
||
652 |
if (XineramaSolarisFunc != NULL) { |
|
653 |
DTRACE_PRINTLN("calling XineramaGetInfo func on Solaris"); |
|
654 |
if ((*XineramaSolarisFunc)(awt_display, 0, &fbrects[0], |
|
556 | 655 |
&fbhints[0], &locNumScr) != 0 && |
656 |
locNumScr > XScreenCount(awt_display)) |
|
2 | 657 |
{ |
658 |
DTRACE_PRINTLN("Enabling Xinerama support"); |
|
659 |
usingXinerama = True; |
|
660 |
/* set global number of screens */ |
|
661 |
DTRACE_PRINTLN1(" num screens = %i\n", locNumScr); |
|
662 |
awt_numScreens = locNumScr; |
|
663 |
} else { |
|
664 |
DTRACE_PRINTLN("calling XineramaGetInfo didn't work"); |
|
665 |
} |
|
666 |
} else { |
|
667 |
DTRACE_PRINTLN("couldn't load XineramaGetInfo symbol"); |
|
668 |
} |
|
669 |
dlclose(libHandle); |
|
670 |
} else { |
|
671 |
DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror()); |
|
672 |
} |
|
673 |
} |
|
674 |
#endif |
|
675 |
||
676 |
/* |
|
677 |
* Checks if Xinerama is running and perform Xinerama-related |
|
678 |
* platform dependent initialization. |
|
679 |
*/ |
|
680 |
static void xineramaInit(void) { |
|
681 |
char* XinExtName = "XINERAMA"; |
|
682 |
int32_t major_opcode, first_event, first_error; |
|
683 |
Bool gotXinExt = False; |
|
684 |
||
685 |
gotXinExt = XQueryExtension(awt_display, XinExtName, &major_opcode, |
|
686 |
&first_event, &first_error); |
|
687 |
||
688 |
if (!gotXinExt) { |
|
689 |
DTRACE_PRINTLN("Xinerama extension is not available"); |
|
690 |
return; |
|
691 |
} |
|
692 |
||
693 |
DTRACE_PRINTLN("Xinerama extension is available"); |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
694 |
#if defined(__linux__) || defined(MACOSX) |
2 | 695 |
xinerama_init_linux(); |
696 |
#else /* Solaris */ |
|
697 |
xinerama_init_solaris(); |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
698 |
#endif /* __linux__ || MACOSX */ |
2 | 699 |
} |
700 |
#endif /* HEADLESS */ |
|
701 |
||
702 |
Display * |
|
703 |
awt_init_Display(JNIEnv *env, jobject this) |
|
704 |
{ |
|
705 |
jclass klass; |
|
706 |
Display *dpy; |
|
707 |
char errmsg[128]; |
|
708 |
int i; |
|
709 |
#ifdef NETSCAPE |
|
710 |
sigset_t alarm_set, oldset; |
|
711 |
#endif |
|
712 |
||
713 |
if (awt_display) { |
|
714 |
return awt_display; |
|
715 |
} |
|
716 |
||
717 |
#ifdef NETSCAPE |
|
718 |
/* Disable interrupts during XtOpenDisplay to avoid bugs in unix os select |
|
719 |
code: some unix systems don't implement SA_RESTART properly and |
|
720 |
because of this, select returns with EINTR. Most implementations of |
|
721 |
gethostbyname don't cope with EINTR properly and as a result we get |
|
722 |
stuck (forever) in the gethostbyname code |
|
723 |
*/ |
|
724 |
sigemptyset(&alarm_set); |
|
725 |
sigaddset(&alarm_set, SIGALRM); |
|
726 |
sigprocmask(SIG_BLOCK, &alarm_set, &oldset); |
|
727 |
#endif |
|
728 |
||
729 |
/* Load AWT lock-related methods in SunToolkit */ |
|
730 |
klass = (*env)->FindClass(env, "sun/awt/SunToolkit"); |
|
731 |
if (klass == NULL) return NULL; |
|
732 |
GET_STATIC_METHOD(klass, awtLockMID, "awtLock", "()V"); |
|
733 |
GET_STATIC_METHOD(klass, awtUnlockMID, "awtUnlock", "()V"); |
|
734 |
GET_STATIC_METHOD(klass, awtWaitMID, "awtLockWait", "(J)V"); |
|
735 |
GET_STATIC_METHOD(klass, awtNotifyMID, "awtLockNotify", "()V"); |
|
736 |
GET_STATIC_METHOD(klass, awtNotifyAllMID, "awtLockNotifyAll", "()V"); |
|
737 |
tkClass = (*env)->NewGlobalRef(env, klass); |
|
738 |
awtLockInited = JNI_TRUE; |
|
739 |
||
740 |
if (getenv("_AWT_IGNORE_XKB") != NULL && |
|
741 |
strlen(getenv("_AWT_IGNORE_XKB")) > 0) { |
|
742 |
if (XkbIgnoreExtension(True)) { |
|
743 |
printf("Ignoring XKB.\n"); |
|
744 |
} |
|
745 |
} |
|
746 |
||
747 |
dpy = awt_display = XOpenDisplay(NULL); |
|
748 |
#ifdef NETSCAPE |
|
749 |
sigprocmask(SIG_SETMASK, &oldset, NULL); |
|
750 |
#endif |
|
751 |
if (!dpy) { |
|
752 |
jio_snprintf(errmsg, |
|
753 |
sizeof(errmsg), |
|
754 |
"Can't connect to X11 window server using '%s' as the value of the DISPLAY variable.", |
|
755 |
(getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY")); |
|
14160
249b30c4dea8
6818083: When DISPLAY is bad, InternalError thrown, not AWTError
anthony
parents:
12047
diff
changeset
|
756 |
JNU_ThrowByName(env, "java/awt/AWTError", errmsg); |
2 | 757 |
return NULL; |
758 |
} |
|
759 |
||
760 |
XSetIOErrorHandler(xioerror_handler); |
|
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
761 |
JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "init", "(J)V", |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
762 |
ptr_to_jlong(awt_display)); |
2 | 763 |
|
764 |
/* set awt_numScreens, and whether or not we're using Xinerama */ |
|
765 |
xineramaInit(); |
|
766 |
||
767 |
if (!usingXinerama) { |
|
768 |
awt_numScreens = XScreenCount(awt_display); |
|
769 |
} |
|
770 |
||
771 |
DTRACE_PRINTLN1("allocating %i screens\n", awt_numScreens); |
|
772 |
/* Allocate screen data structure array */ |
|
773 |
x11Screens = calloc(awt_numScreens, sizeof(AwtScreenData)); |
|
774 |
if (x11Screens == NULL) { |
|
775 |
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), |
|
776 |
NULL); |
|
777 |
return NULL; |
|
778 |
} |
|
779 |
||
780 |
for (i = 0; i < awt_numScreens; i++) { |
|
781 |
if (usingXinerama) { |
|
782 |
/* All Xinerama screens use the same X11 root for now */ |
|
783 |
x11Screens[i].root = RootWindow(awt_display, 0); |
|
784 |
} |
|
785 |
else { |
|
786 |
x11Screens[i].root = RootWindow(awt_display, i); |
|
787 |
} |
|
788 |
x11Screens[i].defaultConfig = makeDefaultConfig(env, i); |
|
789 |
} |
|
790 |
||
791 |
return dpy; |
|
792 |
} |
|
793 |
#endif /* !HEADLESS */ |
|
794 |
||
795 |
/* |
|
796 |
* Class: sun_awt_X11GraphicsEnvironment |
|
797 |
* Method: getDefaultScreenNum |
|
798 |
* Signature: ()I |
|
799 |
*/ |
|
800 |
JNIEXPORT jint JNICALL |
|
801 |
Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum( |
|
802 |
JNIEnv *env, jobject this) |
|
803 |
{ |
|
804 |
#ifdef HEADLESS |
|
805 |
return (jint)0; |
|
806 |
#else |
|
807 |
return DefaultScreen(awt_display); |
|
808 |
#endif /* !HEADLESS */ |
|
809 |
} |
|
810 |
||
811 |
#ifndef HEADLESS |
|
812 |
static void ensureConfigsInited(JNIEnv* env, int screen) { |
|
813 |
if (x11Screens[screen].numConfigs == 0) { |
|
814 |
if (env == NULL) { |
|
815 |
env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
816 |
} |
|
817 |
getAllConfigs (env, screen, &(x11Screens[screen])); |
|
818 |
} |
|
819 |
} |
|
820 |
#endif |
|
821 |
||
822 |
#ifdef HEADLESS |
|
823 |
void* getDefaultConfig(int screen) { |
|
824 |
return NULL; |
|
825 |
} |
|
826 |
#else |
|
827 |
AwtGraphicsConfigDataPtr |
|
828 |
getDefaultConfig(int screen) { |
|
829 |
ensureConfigsInited(NULL, screen); |
|
830 |
return x11Screens[screen].defaultConfig; |
|
831 |
} |
|
832 |
||
833 |
AwtScreenDataPtr |
|
834 |
getScreenData(int screen) { |
|
835 |
return &(x11Screens[screen]); |
|
836 |
} |
|
837 |
#endif /* !HEADLESS */ |
|
838 |
||
839 |
/* |
|
840 |
* Class: sun_awt_X11GraphicsEnvironment |
|
841 |
* Method: initDisplay |
|
842 |
* Signature: (Z)V |
|
843 |
*/ |
|
844 |
JNIEXPORT void JNICALL |
|
845 |
Java_sun_awt_X11GraphicsEnvironment_initDisplay(JNIEnv *env, jobject this, |
|
846 |
jboolean glxReq) |
|
847 |
{ |
|
848 |
#ifndef HEADLESS |
|
849 |
glxRequested = glxReq; |
|
850 |
(void) awt_init_Display(env, this); |
|
851 |
#endif /* !HEADLESS */ |
|
852 |
} |
|
853 |
||
854 |
/* |
|
855 |
* Class: sun_awt_X11GraphicsEnvironment |
|
856 |
* Method: initGLX |
|
857 |
* Signature: ()Z |
|
858 |
*/ |
|
859 |
JNIEXPORT jboolean JNICALL |
|
860 |
Java_sun_awt_X11GraphicsEnvironment_initGLX(JNIEnv *env, jclass x11ge) |
|
861 |
{ |
|
862 |
#ifndef HEADLESS |
|
863 |
jboolean glxAvailable; |
|
864 |
||
865 |
AWT_LOCK(); |
|
866 |
glxAvailable = GLXGC_IsGLXAvailable(); |
|
867 |
AWT_UNLOCK(); |
|
868 |
||
869 |
return glxAvailable; |
|
870 |
#else |
|
871 |
return JNI_FALSE; |
|
872 |
#endif /* !HEADLESS */ |
|
873 |
} |
|
874 |
||
875 |
/* |
|
876 |
* Class: sun_awt_X11GraphicsEnvironment |
|
877 |
* Method: getNumScreens |
|
878 |
* Signature: ()I |
|
879 |
*/ |
|
880 |
JNIEXPORT jint JNICALL |
|
881 |
Java_sun_awt_X11GraphicsEnvironment_getNumScreens(JNIEnv *env, jobject this) |
|
882 |
{ |
|
883 |
#ifdef HEADLESS |
|
884 |
return (jint)0; |
|
885 |
#else |
|
886 |
return awt_numScreens; |
|
887 |
#endif /* !HEADLESS */ |
|
888 |
} |
|
889 |
||
890 |
/* |
|
891 |
* Class: sun_awt_X11GraphicsDevice |
|
892 |
* Method: getDisplay |
|
893 |
* Signature: ()J |
|
894 |
*/ |
|
895 |
JNIEXPORT jlong JNICALL |
|
896 |
Java_sun_awt_X11GraphicsDevice_getDisplay(JNIEnv *env, jobject this) |
|
897 |
{ |
|
898 |
#ifdef HEADLESS |
|
899 |
return NULL; |
|
900 |
#else |
|
901 |
return ptr_to_jlong(awt_display); |
|
902 |
#endif /* !HEADLESS */ |
|
903 |
} |
|
904 |
||
905 |
#ifdef MITSHM |
|
906 |
||
907 |
static jint canUseShmExt = UNSET_MITSHM; |
|
908 |
static jint canUseShmExtPixmaps = UNSET_MITSHM; |
|
909 |
||
910 |
void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) { |
|
911 |
XShmSegmentInfo shminfo; |
|
912 |
int XShmMajor, XShmMinor; |
|
913 |
int a, b, c; |
|
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
914 |
jboolean xShmAttachResult; |
2 | 915 |
|
916 |
AWT_LOCK(); |
|
917 |
if (canUseShmExt != UNSET_MITSHM) { |
|
918 |
*shmExt = canUseShmExt; |
|
919 |
*shmPixmaps = canUseShmExtPixmaps; |
|
920 |
AWT_UNLOCK(); |
|
921 |
return; |
|
922 |
} |
|
923 |
||
924 |
*shmExt = canUseShmExt = CANT_USE_MITSHM; |
|
925 |
*shmPixmaps = canUseShmExtPixmaps = CANT_USE_MITSHM; |
|
926 |
||
927 |
/** |
|
928 |
* XShmQueryExtension returns False in remote server case. |
|
929 |
* Unfortunately it also returns True in ssh case, so |
|
930 |
* we need to test that we can actually do XShmAttach. |
|
931 |
*/ |
|
932 |
if (XShmQueryExtension(awt_display)) { |
|
933 |
shminfo.shmid = shmget(IPC_PRIVATE, 0x10000, IPC_CREAT|0777); |
|
934 |
if (shminfo.shmid < 0) { |
|
935 |
AWT_UNLOCK(); |
|
936 |
J2dRlsTraceLn1(J2D_TRACE_ERROR, |
|
937 |
"TryInitMITShm: shmget has failed: %s", |
|
938 |
strerror(errno)); |
|
939 |
return; |
|
940 |
} |
|
941 |
shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0); |
|
942 |
if (shminfo.shmaddr == ((char *) -1)) { |
|
943 |
shmctl(shminfo.shmid, IPC_RMID, 0); |
|
944 |
AWT_UNLOCK(); |
|
945 |
J2dRlsTraceLn1(J2D_TRACE_ERROR, |
|
946 |
"TryInitMITShm: shmat has failed: %s", |
|
947 |
strerror(errno)); |
|
948 |
return; |
|
949 |
} |
|
950 |
shminfo.readOnly = True; |
|
951 |
||
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
952 |
xShmAttachResult = TryXShmAttach(env, awt_display, &shminfo); |
2 | 953 |
/** |
954 |
* Get rid of the id now to reduce chances of leaking |
|
955 |
* system resources. |
|
956 |
*/ |
|
957 |
shmctl(shminfo.shmid, IPC_RMID, 0); |
|
958 |
||
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
959 |
if (xShmAttachResult == JNI_TRUE) { |
2 | 960 |
canUseShmExt = CAN_USE_MITSHM; |
961 |
/* check if we can use shared pixmaps */ |
|
962 |
XShmQueryVersion(awt_display, &XShmMajor, &XShmMinor, |
|
963 |
(Bool*)&canUseShmExtPixmaps); |
|
964 |
canUseShmExtPixmaps = canUseShmExtPixmaps && |
|
965 |
(XShmPixmapFormat(awt_display) == ZPixmap); |
|
966 |
XShmDetach(awt_display, &shminfo); |
|
967 |
} |
|
968 |
shmdt(shminfo.shmaddr); |
|
969 |
*shmExt = canUseShmExt; |
|
970 |
*shmPixmaps = canUseShmExtPixmaps; |
|
971 |
} |
|
972 |
AWT_UNLOCK(); |
|
973 |
} |
|
17679
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
974 |
|
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
975 |
/* |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
976 |
* Must be called with the acquired AWT lock. |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
977 |
*/ |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
978 |
jboolean TryXShmAttach(JNIEnv *env, Display *display, XShmSegmentInfo *shminfo) { |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
979 |
jboolean errorOccurredFlag = JNI_FALSE; |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
980 |
jobject errorHandlerRef; |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
981 |
|
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
982 |
/* |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
983 |
* XShmAttachHandler will set its internal flag to JNI_TRUE, if any Shm error occurs. |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
984 |
*/ |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
985 |
EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$XShmAttachHandler", |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
986 |
"()Lsun/awt/X11/XErrorHandler$XShmAttachHandler;", JNI_TRUE, |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
987 |
errorHandlerRef, errorOccurredFlag, |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
988 |
XShmAttach(display, shminfo)); |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
989 |
return errorOccurredFlag == JNI_FALSE ? JNI_TRUE : JNI_FALSE; |
a81555868357
8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents:
14160
diff
changeset
|
990 |
} |
2 | 991 |
#endif /* MITSHM */ |
992 |
||
993 |
/* |
|
994 |
* Class: sun_awt_X11GraphicsEnvironment |
|
995 |
* Method: checkShmExt |
|
996 |
* Signature: ()I |
|
997 |
*/ |
|
998 |
JNIEXPORT jint JNICALL |
|
999 |
Java_sun_awt_X11GraphicsEnvironment_checkShmExt(JNIEnv *env, jobject this) |
|
1000 |
{ |
|
1001 |
||
1002 |
int shmExt = NOEXT_MITSHM, shmPixmaps; |
|
1003 |
#ifdef MITSHM |
|
1004 |
TryInitMITShm(env, &shmExt, &shmPixmaps); |
|
1005 |
#endif |
|
1006 |
return shmExt; |
|
1007 |
} |
|
1008 |
||
1009 |
/* |
|
1010 |
* Class: sun_awt_X11GraphicsEnvironment |
|
1011 |
* Method: getDisplayString |
|
1012 |
* Signature: ()Ljava/lang/String |
|
1013 |
*/ |
|
1014 |
JNIEXPORT jstring JNICALL |
|
1015 |
Java_sun_awt_X11GraphicsEnvironment_getDisplayString |
|
1016 |
(JNIEnv *env, jobject this) |
|
1017 |
{ |
|
1018 |
#ifdef HEADLESS |
|
1019 |
return (jstring)NULL; |
|
1020 |
#else |
|
1021 |
return (*env)->NewStringUTF(env, DisplayString(awt_display)); |
|
1022 |
#endif /* HEADLESS */ |
|
1023 |
} |
|
1024 |
||
1025 |
||
1026 |
/* |
|
1027 |
* Class: sun_awt_X11GraphicsDevice |
|
1028 |
* Method: getNumConfigs |
|
1029 |
* Signature: ()I |
|
1030 |
*/ |
|
1031 |
JNIEXPORT jint JNICALL |
|
1032 |
Java_sun_awt_X11GraphicsDevice_getNumConfigs( |
|
1033 |
JNIEnv *env, jobject this, jint screen) |
|
1034 |
{ |
|
1035 |
#ifdef HEADLESS |
|
1036 |
return (jint)0; |
|
1037 |
#else |
|
1038 |
ensureConfigsInited(env, screen); |
|
1039 |
return x11Screens[screen].numConfigs; |
|
1040 |
#endif /* !HEADLESS */ |
|
1041 |
} |
|
1042 |
||
1043 |
/* |
|
1044 |
* Class: sun_awt_X11GraphicsDevice |
|
1045 |
* Method: getConfigVisualId |
|
1046 |
* Signature: (I)I |
|
1047 |
*/ |
|
1048 |
JNIEXPORT jint JNICALL |
|
1049 |
Java_sun_awt_X11GraphicsDevice_getConfigVisualId( |
|
1050 |
JNIEnv *env, jobject this, jint index, jint screen) |
|
1051 |
{ |
|
1052 |
#ifdef HEADLESS |
|
1053 |
return (jint)0; |
|
1054 |
#else |
|
1055 |
int visNum; |
|
1056 |
||
1057 |
ensureConfigsInited(env, screen); |
|
1058 |
if (index == 0) { |
|
1059 |
return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.visualid); |
|
1060 |
} else { |
|
1061 |
return ((jint)x11Screens[screen].configs[index]->awt_visInfo.visualid); |
|
1062 |
} |
|
1063 |
#endif /* !HEADLESS */ |
|
1064 |
} |
|
1065 |
||
1066 |
/* |
|
1067 |
* Class: sun_awt_X11GraphicsDevice |
|
1068 |
* Method: getConfigDepth |
|
1069 |
* Signature: (I)I |
|
1070 |
*/ |
|
1071 |
JNIEXPORT jint JNICALL |
|
1072 |
Java_sun_awt_X11GraphicsDevice_getConfigDepth( |
|
1073 |
JNIEnv *env, jobject this, jint index, jint screen) |
|
1074 |
{ |
|
1075 |
#ifdef HEADLESS |
|
1076 |
return (jint)0; |
|
1077 |
#else |
|
1078 |
int visNum; |
|
1079 |
||
1080 |
ensureConfigsInited(env, screen); |
|
1081 |
if (index == 0) { |
|
1082 |
return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.depth); |
|
1083 |
} else { |
|
1084 |
return ((jint)x11Screens[screen].configs[index]->awt_visInfo.depth); |
|
1085 |
} |
|
1086 |
#endif /* !HEADLESS */ |
|
1087 |
} |
|
1088 |
||
1089 |
/* |
|
1090 |
* Class: sun_awt_X11GraphicsDevice |
|
1091 |
* Method: getConfigColormap |
|
1092 |
* Signature: (I)I |
|
1093 |
*/ |
|
1094 |
JNIEXPORT jint JNICALL |
|
1095 |
Java_sun_awt_X11GraphicsDevice_getConfigColormap( |
|
1096 |
JNIEnv *env, jobject this, jint index, jint screen) |
|
1097 |
{ |
|
1098 |
#ifdef HEADLESS |
|
1099 |
return (jint)0; |
|
1100 |
#else |
|
1101 |
int visNum; |
|
1102 |
||
1103 |
ensureConfigsInited(env, screen); |
|
1104 |
if (index == 0) { |
|
1105 |
return ((jint)x11Screens[screen].defaultConfig->awt_cmap); |
|
1106 |
} else { |
|
1107 |
return ((jint)x11Screens[screen].configs[index]->awt_cmap); |
|
1108 |
} |
|
1109 |
#endif /* !HEADLESS */ |
|
1110 |
} |
|
1111 |
||
1112 |
/* |
|
1113 |
* Class: sun_awt_X11GraphicsDevice |
|
1114 |
* Method: resetNativeData |
|
1115 |
* Signature: (I)V |
|
1116 |
*/ |
|
1117 |
JNIEXPORT void JNICALL |
|
1118 |
Java_sun_awt_X11GraphicsDevice_resetNativeData |
|
1119 |
(JNIEnv *env, jclass x11gd, jint screen) |
|
1120 |
{ |
|
1121 |
#ifndef HEADLESS |
|
1122 |
/* |
|
1123 |
* Reset references to the various configs; the actual native config data |
|
1124 |
* will be free'd later by the Disposer mechanism when the Java-level |
|
1125 |
* X11GraphicsConfig objects go away. By setting these values to NULL, |
|
1126 |
* we ensure that they will be reinitialized as necessary (for example, |
|
1127 |
* see the getNumConfigs() method). |
|
1128 |
*/ |
|
1129 |
if (x11Screens[screen].configs) { |
|
1130 |
free(x11Screens[screen].configs); |
|
1131 |
x11Screens[screen].configs = NULL; |
|
1132 |
} |
|
1133 |
x11Screens[screen].defaultConfig = NULL; |
|
1134 |
x11Screens[screen].numConfigs = 0; |
|
1135 |
#endif /* !HEADLESS */ |
|
1136 |
} |
|
1137 |
||
1138 |
/* |
|
1139 |
* Class: sun_awt_X11GraphicsConfig |
|
1140 |
* Method: dispose |
|
1141 |
* Signature: (J)V |
|
1142 |
*/ |
|
1143 |
JNIEXPORT void JNICALL |
|
1144 |
Java_sun_awt_X11GraphicsConfig_dispose |
|
1145 |
(JNIEnv *env, jclass x11gc, jlong configData) |
|
1146 |
{ |
|
1147 |
#ifndef HEADLESS |
|
1148 |
AwtGraphicsConfigDataPtr aData = (AwtGraphicsConfigDataPtr) |
|
1149 |
jlong_to_ptr(configData); |
|
1150 |
||
1151 |
if (aData == NULL) { |
|
1152 |
return; |
|
1153 |
} |
|
1154 |
||
1155 |
AWT_LOCK(); |
|
1156 |
if (aData->awt_cmap) { |
|
1157 |
XFreeColormap(awt_display, aData->awt_cmap); |
|
1158 |
} |
|
1159 |
if (aData->awtImage) { |
|
1160 |
free(aData->awtImage); |
|
1161 |
} |
|
1162 |
if (aData->monoImage) { |
|
1163 |
XFree(aData->monoImage); |
|
1164 |
} |
|
1165 |
if (aData->monoPixmap) { |
|
1166 |
XFreePixmap(awt_display, aData->monoPixmap); |
|
1167 |
} |
|
1168 |
if (aData->monoPixmapGC) { |
|
1169 |
XFreeGC(awt_display, aData->monoPixmapGC); |
|
1170 |
} |
|
1171 |
if (aData->color_data) { |
|
1172 |
free(aData->color_data); |
|
1173 |
} |
|
1174 |
AWT_UNLOCK(); |
|
1175 |
||
1176 |
if (aData->glxInfo) { |
|
1177 |
/* |
|
1178 |
* The native GLXGraphicsConfig data needs to be disposed separately |
|
1179 |
* on the OGL queue flushing thread (should not be called while |
|
1180 |
* the AWT lock is held). |
|
1181 |
*/ |
|
1182 |
JNU_CallStaticMethodByName(env, NULL, |
|
1183 |
"sun/java2d/opengl/OGLRenderQueue", |
|
1184 |
"disposeGraphicsConfig", "(J)V", |
|
1185 |
ptr_to_jlong(aData->glxInfo)); |
|
1186 |
} |
|
1187 |
||
1188 |
free(aData); |
|
1189 |
#endif /* !HEADLESS */ |
|
1190 |
} |
|
1191 |
||
1192 |
/* |
|
1193 |
* Class: sun_awt_X11GraphicsConfig |
|
1194 |
* Method: getXResolution |
|
1195 |
* Signature: ()I |
|
1196 |
*/ |
|
1197 |
JNIEXPORT jdouble JNICALL |
|
1198 |
Java_sun_awt_X11GraphicsConfig_getXResolution( |
|
1199 |
JNIEnv *env, jobject this, jint screen) |
|
1200 |
{ |
|
1201 |
#ifdef HEADLESS |
|
1202 |
return (jdouble)0; |
|
1203 |
#else |
|
1204 |
return ((DisplayWidth(awt_display, screen) * 25.4) / |
|
1205 |
DisplayWidthMM(awt_display, screen)); |
|
1206 |
#endif /* !HEADLESS */ |
|
1207 |
} |
|
1208 |
||
1209 |
/* |
|
1210 |
* Class: sun_awt_X11GraphicsConfig |
|
1211 |
* Method: getYResolution |
|
1212 |
* Signature: ()I |
|
1213 |
*/ |
|
1214 |
JNIEXPORT jdouble JNICALL |
|
1215 |
Java_sun_awt_X11GraphicsConfig_getYResolution( |
|
1216 |
JNIEnv *env, jobject this, jint screen) |
|
1217 |
{ |
|
1218 |
#ifdef HEADLESS |
|
1219 |
return (jdouble)0; |
|
1220 |
#else |
|
1221 |
return ((DisplayHeight(awt_display, screen) * 25.4) / |
|
1222 |
DisplayHeightMM(awt_display, screen)); |
|
1223 |
#endif /* !HEADLESS */ |
|
1224 |
} |
|
1225 |
||
1226 |
||
1227 |
/* |
|
1228 |
* Class: sun_awt_X11GraphicsConfig |
|
1229 |
* Method: getNumColors |
|
1230 |
* Signature: ()I |
|
1231 |
*/ |
|
1232 |
JNIEXPORT jint JNICALL |
|
1233 |
Java_sun_awt_X11GraphicsConfig_getNumColors( |
|
1234 |
JNIEnv *env, jobject this) |
|
1235 |
{ |
|
1236 |
#ifdef HEADLESS |
|
1237 |
return (jint)0; |
|
1238 |
#else |
|
1239 |
AwtGraphicsConfigData *adata; |
|
1240 |
||
1241 |
adata = (AwtGraphicsConfigData *) JNU_GetLongFieldAsPtr(env, this, |
|
1242 |
x11GraphicsConfigIDs.aData); |
|
1243 |
||
1244 |
return adata->awt_num_colors; |
|
1245 |
#endif /* !HEADLESS */ |
|
1246 |
} |
|
1247 |
||
1248 |
/* |
|
1249 |
* Class: sun_awt_X11GraphicsConfig |
|
1250 |
* Method: init |
|
1251 |
* Signature: (I)V |
|
1252 |
*/ |
|
1253 |
JNIEXPORT void JNICALL |
|
1254 |
Java_sun_awt_X11GraphicsConfig_init( |
|
1255 |
JNIEnv *env, jobject this, jint visualNum, jint screen) |
|
1256 |
{ |
|
1257 |
#ifndef HEADLESS |
|
1258 |
AwtGraphicsConfigData *adata = NULL; |
|
1259 |
AwtScreenData asd = x11Screens[screen]; |
|
1260 |
int i, n; |
|
1261 |
int depth; |
|
1262 |
XImage * tempImage; |
|
1263 |
||
1264 |
/* If haven't gotten all of the configs yet, do it now. */ |
|
1265 |
if (asd.numConfigs == 0) { |
|
1266 |
getAllConfigs (env, screen, &asd); |
|
1267 |
} |
|
1268 |
||
1269 |
/* Check the graphicsConfig for this visual */ |
|
1270 |
for (i = 0; i < asd.numConfigs; i++) { |
|
1271 |
AwtGraphicsConfigDataPtr agcPtr = asd.configs[i]; |
|
1272 |
if ((jint)agcPtr->awt_visInfo.visualid == visualNum) { |
|
1273 |
adata = agcPtr; |
|
1274 |
break; |
|
1275 |
} |
|
1276 |
} |
|
1277 |
||
1278 |
/* If didn't find the visual, throw an exception... */ |
|
1279 |
if (adata == (AwtGraphicsConfigData *) NULL) { |
|
1280 |
JNU_ThrowIllegalArgumentException(env, "Unknown Visual Specified"); |
|
1281 |
return; |
|
1282 |
} |
|
1283 |
||
1284 |
/* adata->awt_cmap initialization has been deferred to |
|
1285 |
* makeColorModel call |
|
1286 |
*/ |
|
1287 |
||
1288 |
JNU_SetLongFieldFromPtr(env, this, x11GraphicsConfigIDs.aData, adata); |
|
1289 |
||
1290 |
depth = adata->awt_visInfo.depth; |
|
1291 |
tempImage = XCreateImage(awt_display, |
|
1292 |
adata->awt_visInfo.visual, |
|
1293 |
depth, ZPixmap, 0, NULL, 1, 1, 32, 0); |
|
1294 |
adata->pixelStride = (tempImage->bits_per_pixel + 7) / 8; |
|
1295 |
(*env)->SetIntField(env, this, x11GraphicsConfigIDs.bitsPerPixel, |
|
1296 |
(jint)tempImage->bits_per_pixel); |
|
1297 |
XDestroyImage(tempImage); |
|
1298 |
#endif /* !HEADLESS */ |
|
1299 |
} |
|
1300 |
||
1301 |
||
1302 |
||
1303 |
/* |
|
1304 |
* Class: sun_awt_X11GraphicsConfig |
|
1305 |
* Method: makeColorModel |
|
1306 |
* Signature: ()Ljava/awt/image/ColorModel |
|
1307 |
*/ |
|
1308 |
JNIEXPORT jobject JNICALL |
|
1309 |
Java_sun_awt_X11GraphicsConfig_makeColorModel( |
|
1310 |
JNIEnv *env, jobject this) |
|
1311 |
{ |
|
1312 |
#ifdef HEADLESS |
|
1313 |
return NULL; |
|
1314 |
#else |
|
1315 |
AwtGraphicsConfigData *adata; |
|
1316 |
jobject colorModel; |
|
1317 |
||
1318 |
/* |
|
1319 |
* If awt is not locked yet, return null since the toolkit is not |
|
1320 |
* initialized yet. |
|
1321 |
*/ |
|
1322 |
if (!awtLockInited) { |
|
1323 |
return NULL; |
|
1324 |
} |
|
1325 |
||
1326 |
AWT_LOCK (); |
|
1327 |
||
1328 |
adata = (AwtGraphicsConfigData *) JNU_GetLongFieldAsPtr(env, this, |
|
1329 |
x11GraphicsConfigIDs.aData); |
|
1330 |
||
1331 |
/* If colormap entry of adata is NULL, need to create it now */ |
|
1332 |
if (adata->awt_cmap == (Colormap) NULL) { |
|
1333 |
awtJNI_CreateColorData (env, adata, 1); |
|
1334 |
} |
|
1335 |
||
1336 |
/* Make Color Model object for this GraphicsConfiguration */ |
|
1337 |
colorModel = awtJNI_GetColorModel (env, adata); |
|
1338 |
||
1339 |
AWT_UNLOCK (); |
|
1340 |
||
1341 |
return colorModel; |
|
1342 |
#endif /* !HEADLESS */ |
|
1343 |
} |
|
1344 |
||
1345 |
||
1346 |
/* |
|
1347 |
* Class: sun_awt_X11GraphicsConfig |
|
1348 |
* Method: getBounds |
|
1349 |
* Signature: ()Ljava/awt/Rectangle |
|
1350 |
*/ |
|
1351 |
JNIEXPORT jobject JNICALL |
|
1352 |
Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen) |
|
1353 |
{ |
|
1354 |
#ifdef HEADLESS |
|
1355 |
return NULL; |
|
1356 |
#else |
|
1357 |
jclass clazz; |
|
1358 |
jmethodID mid; |
|
1359 |
jobject bounds = NULL; |
|
1360 |
AwtGraphicsConfigDataPtr adata; |
|
1361 |
||
1362 |
adata = (AwtGraphicsConfigDataPtr) |
|
1363 |
JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData); |
|
1364 |
||
1365 |
clazz = (*env)->FindClass(env, "java/awt/Rectangle"); |
|
1366 |
mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V"); |
|
1367 |
if (mid != NULL) { |
|
1368 |
if (usingXinerama) { |
|
18135
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1369 |
if (0 <= screen && screen < awt_numScreens) { |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1370 |
bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x, |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1371 |
fbrects[screen].y, |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1372 |
fbrects[screen].width, |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1373 |
fbrects[screen].height); |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1374 |
} else { |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1375 |
jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1376 |
if (exceptionClass != NULL) { |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1377 |
(*env)->ThrowNew(env, exceptionClass, "Illegal screen index"); |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1378 |
} |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1379 |
} |
d9be76f1a19c
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents:
17679
diff
changeset
|
1380 |
} else { |
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1381 |
XWindowAttributes xwa; |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1382 |
memset(&xwa, 0, sizeof(xwa)); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1383 |
|
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1384 |
AWT_LOCK (); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1385 |
XGetWindowAttributes(awt_display, |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1386 |
RootWindow(awt_display, adata->awt_visInfo.screen), |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1387 |
&xwa); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1388 |
AWT_UNLOCK (); |
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1389 |
|
2 | 1390 |
bounds = (*env)->NewObject(env, clazz, mid, 0, 0, |
11083
34aa99149ff2
7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents:
9035
diff
changeset
|
1391 |
xwa.width, xwa.height); |
2 | 1392 |
} |
1393 |
||
1394 |
if ((*env)->ExceptionOccurred(env)) { |
|
1395 |
return NULL; |
|
1396 |
} |
|
1397 |
} |
|
1398 |
return bounds; |
|
1399 |
#endif /* !HEADLESS */ |
|
1400 |
} |
|
1401 |
||
1402 |
/* |
|
1403 |
* Class: sun_awt_X11GraphicsConfig |
|
1404 |
* Method: createBackBuffer |
|
1405 |
* Signature: (JI)J |
|
1406 |
*/ |
|
1407 |
JNIEXPORT jlong JNICALL |
|
1408 |
Java_sun_awt_X11GraphicsConfig_createBackBuffer |
|
1409 |
(JNIEnv *env, jobject this, jlong window, jint swapAction) |
|
1410 |
{ |
|
1411 |
int32_t v1, v2; |
|
1412 |
XdbeBackBuffer ret = (unsigned long) 0; |
|
1413 |
Window w = (Window)window; |
|
1414 |
AWT_LOCK(); |
|
1415 |
if (!XdbeQueryExtension(awt_display, &v1, &v2)) { |
|
1416 |
JNU_ThrowByName(env, "java/lang/Exception", |
|
1417 |
"Could not query double-buffer extension"); |
|
1418 |
AWT_UNLOCK(); |
|
1419 |
return (jlong)0; |
|
1420 |
} |
|
1421 |
ret = XdbeAllocateBackBufferName(awt_display, w, |
|
1422 |
(XdbeSwapAction)swapAction); |
|
1423 |
AWT_FLUSH_UNLOCK(); |
|
1424 |
return (jlong)ret; |
|
1425 |
} |
|
1426 |
||
1427 |
/* |
|
1428 |
* Class: sun_awt_X11GraphicsConfig |
|
1429 |
* Method: destroyBackBuffer |
|
1430 |
* Signature: (J)V |
|
1431 |
*/ |
|
1432 |
JNIEXPORT void JNICALL |
|
1433 |
Java_sun_awt_X11GraphicsConfig_destroyBackBuffer |
|
1434 |
(JNIEnv *env, jobject this, jlong backBuffer) |
|
1435 |
{ |
|
1436 |
AWT_LOCK(); |
|
1437 |
XdbeDeallocateBackBufferName(awt_display, (XdbeBackBuffer)backBuffer); |
|
1438 |
AWT_FLUSH_UNLOCK(); |
|
1439 |
} |
|
1440 |
||
1441 |
/* |
|
1442 |
* Class: sun_awt_X11GraphicsConfig |
|
1443 |
* Method: swapBuffers |
|
1444 |
* Signature: (JI)V |
|
1445 |
*/ |
|
1446 |
JNIEXPORT void JNICALL |
|
1447 |
Java_sun_awt_X11GraphicsConfig_swapBuffers |
|
1448 |
(JNIEnv *env, jobject this, |
|
1449 |
jlong window, jint swapAction) |
|
1450 |
{ |
|
1451 |
XdbeSwapInfo swapInfo; |
|
1452 |
||
1453 |
AWT_LOCK(); |
|
1454 |
||
1455 |
XdbeBeginIdiom(awt_display); |
|
1456 |
swapInfo.swap_window = (Window)window; |
|
1457 |
swapInfo.swap_action = (XdbeSwapAction)swapAction; |
|
1458 |
if (!XdbeSwapBuffers(awt_display, &swapInfo, 1)) { |
|
1459 |
JNU_ThrowInternalError(env, "Could not swap buffers"); |
|
1460 |
} |
|
1461 |
XdbeEndIdiom(awt_display); |
|
1462 |
||
1463 |
AWT_FLUSH_UNLOCK(); |
|
1464 |
} |
|
1465 |
||
1466 |
/* |
|
2451 | 1467 |
* Class: sun_awt_X11GraphicsConfig |
1468 |
* Method: isTranslucencyCapable |
|
1469 |
* Signature: (J)V |
|
1470 |
*/ |
|
1471 |
JNIEXPORT jboolean JNICALL |
|
1472 |
Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable |
|
1473 |
(JNIEnv *env, jobject this, jlong configData) |
|
1474 |
{ |
|
1475 |
#ifdef HEADLESS |
|
1476 |
return JNI_FALSE; |
|
1477 |
#else |
|
1478 |
AwtGraphicsConfigDataPtr aData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(configData); |
|
1479 |
if (aData == NULL) { |
|
1480 |
return JNI_FALSE; |
|
1481 |
} |
|
1482 |
return (jboolean)aData->isTranslucencySupported; |
|
1483 |
#endif |
|
1484 |
} |
|
1485 |
||
1486 |
/* |
|
2 | 1487 |
* Class: sun_awt_X11GraphicsDevice |
1488 |
* Method: isDBESupported |
|
1489 |
* Signature: ()Z |
|
1490 |
*/ |
|
1491 |
JNIEXPORT jboolean JNICALL |
|
1492 |
Java_sun_awt_X11GraphicsDevice_isDBESupported(JNIEnv *env, jobject this) |
|
1493 |
{ |
|
1494 |
#ifdef HEADLESS |
|
1495 |
return JNI_FALSE; |
|
1496 |
#else |
|
1497 |
int opcode = 0, firstEvent = 0, firstError = 0; |
|
1498 |
jboolean ret; |
|
1499 |
||
1500 |
AWT_LOCK(); |
|
1501 |
ret = (jboolean)XQueryExtension(awt_display, "DOUBLE-BUFFER", |
|
1502 |
&opcode, &firstEvent, &firstError); |
|
1503 |
AWT_FLUSH_UNLOCK(); |
|
1504 |
return ret; |
|
1505 |
#endif /* !HEADLESS */ |
|
1506 |
} |
|
1507 |
||
1508 |
/* |
|
1509 |
* Class: sun_awt_X11GraphicsDevice |
|
1510 |
* Method: getDoubleBufferVisuals |
|
1511 |
* Signature: (I)V |
|
1512 |
*/ |
|
1513 |
JNIEXPORT void JNICALL |
|
1514 |
Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals(JNIEnv *env, |
|
1515 |
jobject this, jint screen) |
|
1516 |
{ |
|
1517 |
#ifndef HEADLESS |
|
1518 |
jclass clazz; |
|
1519 |
jmethodID midAddVisual; |
|
1520 |
Window rootWindow; |
|
1521 |
int i, n = 1; |
|
1522 |
XdbeScreenVisualInfo* visScreenInfo; |
|
1523 |
int xinawareScreen; |
|
1524 |
||
1525 |
if (usingXinerama) { |
|
1526 |
xinawareScreen = 0; |
|
1527 |
} |
|
1528 |
else { |
|
1529 |
xinawareScreen = screen; |
|
1530 |
} |
|
1531 |
||
1532 |
clazz = (*env)->GetObjectClass(env, this); |
|
1533 |
midAddVisual = (*env)->GetMethodID(env, clazz, "addDoubleBufferVisual", |
|
1534 |
"(I)V"); |
|
1535 |
||
1536 |
AWT_LOCK(); |
|
1537 |
rootWindow = RootWindow(awt_display, xinawareScreen); |
|
1538 |
visScreenInfo = XdbeGetVisualInfo(awt_display, &rootWindow, &n); |
|
1539 |
if (visScreenInfo == NULL) { |
|
1540 |
JNU_ThrowInternalError(env, "Could not get visual info"); |
|
1541 |
AWT_UNLOCK(); |
|
1542 |
return; |
|
1543 |
} |
|
1544 |
AWT_FLUSH_UNLOCK(); |
|
1545 |
for (i = 0; i < visScreenInfo->count; i++) { |
|
1546 |
XdbeVisualInfo* visInfo = visScreenInfo->visinfo; |
|
1547 |
(*env)->CallVoidMethod(env, this, midAddVisual, (visInfo[i]).visual); |
|
1548 |
} |
|
1549 |
#endif /* !HEADLESS */ |
|
1550 |
} |
|
1551 |
||
1552 |
/* |
|
1553 |
* Class: sun_awt_X11GraphicsEnvironment |
|
1554 |
* Method: pRunningXinerama |
|
1555 |
* Signature: ()Z |
|
1556 |
*/ |
|
1557 |
JNIEXPORT jboolean JNICALL |
|
1558 |
Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama(JNIEnv *env, |
|
1559 |
jobject this) |
|
1560 |
{ |
|
1561 |
#ifdef HEADLESS |
|
1562 |
return false; |
|
1563 |
#else |
|
1564 |
return usingXinerama; |
|
1565 |
#endif /* HEADLESS */ |
|
1566 |
} |
|
1567 |
||
1568 |
/* |
|
1569 |
* Can return NULL. |
|
1570 |
* |
|
1571 |
* Class: sun_awt_X11GraphicsEnvironment |
|
1572 |
* Method: getXineramaCenterPoint |
|
1573 |
* Signature: ()Ljava/awt/Point |
|
1574 |
*/ |
|
1575 |
JNIEXPORT jobject JNICALL |
|
1576 |
Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint(JNIEnv *env, |
|
1577 |
jobject this) |
|
1578 |
{ |
|
1579 |
jobject point = NULL; |
|
1580 |
#ifndef HEADLESS /* return NULL in HEADLESS, Linux */ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1581 |
#if !defined(__linux__) && !defined(MACOSX) |
2 | 1582 |
int x,y; |
1583 |
||
1584 |
AWT_LOCK(); |
|
1585 |
DASSERT(usingXinerama); |
|
1586 |
if (XineramaSolarisCenterFunc != NULL) { |
|
1587 |
(XineramaSolarisCenterFunc)(awt_display, 0, &x, &y); |
|
1588 |
point = JNU_NewObjectByName(env, "java/awt/Point","(II)V", x, y); |
|
1589 |
DASSERT(point); |
|
1590 |
} else { |
|
1591 |
DTRACE_PRINTLN("unable to call XineramaSolarisCenterFunc: symbol is null"); |
|
1592 |
} |
|
1593 |
AWT_FLUSH_UNLOCK(); |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1594 |
#endif /* __linux __ || MACOSX */ |
2 | 1595 |
#endif /* HEADLESS */ |
1596 |
return point; |
|
1597 |
} |
|
1598 |
||
1599 |
||
1600 |
/** |
|
1601 |
* Begin DisplayMode/FullScreen support |
|
1602 |
*/ |
|
1603 |
||
1604 |
#ifndef HEADLESS |
|
1605 |
||
1606 |
#define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI |
|
4265
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1607 |
#define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN |
2 | 1608 |
|
552
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1609 |
typedef Status |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1610 |
(*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp); |
2 | 1611 |
typedef XRRScreenConfiguration* |
1612 |
(*XRRGetScreenInfoType)(Display *dpy, Drawable root); |
|
1613 |
typedef void |
|
1614 |
(*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config); |
|
1615 |
typedef short* |
|
1616 |
(*XRRConfigRatesType)(XRRScreenConfiguration *config, |
|
1617 |
int sizeID, int *nrates); |
|
1618 |
typedef short |
|
1619 |
(*XRRConfigCurrentRateType)(XRRScreenConfiguration *config); |
|
1620 |
typedef XRRScreenSize* |
|
1621 |
(*XRRConfigSizesType)(XRRScreenConfiguration *config, |
|
1622 |
int *nsizes); |
|
1623 |
typedef SizeID |
|
1624 |
(*XRRConfigCurrentConfigurationType)(XRRScreenConfiguration *config, |
|
1625 |
Rotation *rotation); |
|
1626 |
typedef Status |
|
1627 |
(*XRRSetScreenConfigAndRateType)(Display *dpy, |
|
1628 |
XRRScreenConfiguration *config, |
|
1629 |
Drawable draw, |
|
1630 |
int size_index, |
|
1631 |
Rotation rotation, |
|
1632 |
short rate, |
|
1633 |
Time timestamp); |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1634 |
typedef Rotation |
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1635 |
(*XRRConfigRotationsType)(XRRScreenConfiguration *config, |
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1636 |
Rotation *current_rotation); |
2 | 1637 |
|
552
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1638 |
static XRRQueryVersionType awt_XRRQueryVersion; |
2 | 1639 |
static XRRGetScreenInfoType awt_XRRGetScreenInfo; |
1640 |
static XRRFreeScreenConfigInfoType awt_XRRFreeScreenConfigInfo; |
|
1641 |
static XRRConfigRatesType awt_XRRConfigRates; |
|
1642 |
static XRRConfigCurrentRateType awt_XRRConfigCurrentRate; |
|
1643 |
static XRRConfigSizesType awt_XRRConfigSizes; |
|
1644 |
static XRRConfigCurrentConfigurationType awt_XRRConfigCurrentConfiguration; |
|
1645 |
static XRRSetScreenConfigAndRateType awt_XRRSetScreenConfigAndRate; |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1646 |
static XRRConfigRotationsType awt_XRRConfigRotations; |
2 | 1647 |
|
1648 |
#define LOAD_XRANDR_FUNC(f) \ |
|
1649 |
do { \ |
|
1650 |
awt_##f = (f##Type)dlsym(pLibRandR, #f); \ |
|
1651 |
if (awt_##f == NULL) { \ |
|
1652 |
J2dRlsTraceLn1(J2D_TRACE_ERROR, \ |
|
1653 |
"X11GD_InitXrandrFuncs: Could not load %s", #f); \ |
|
1654 |
dlclose(pLibRandR); \ |
|
1655 |
return JNI_FALSE; \ |
|
1656 |
} \ |
|
1657 |
} while (0) |
|
1658 |
||
1659 |
static jboolean |
|
1660 |
X11GD_InitXrandrFuncs(JNIEnv *env) |
|
1661 |
{ |
|
552
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1662 |
int rr_maj_ver = 0, rr_min_ver = 0; |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1663 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1664 |
void *pLibRandR = dlopen(VERSIONED_JNI_LIB_NAME("Xrandr", "2"), |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1665 |
RTLD_LAZY | RTLD_LOCAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1666 |
if (pLibRandR == NULL) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1667 |
pLibRandR = dlopen(JNI_LIB_NAME("Xrandr"), RTLD_LAZY | RTLD_LOCAL); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11093
diff
changeset
|
1668 |
} |
2 | 1669 |
if (pLibRandR == NULL) { |
1670 |
J2dRlsTraceLn(J2D_TRACE_ERROR, |
|
1671 |
"X11GD_InitXrandrFuncs: Could not open libXrandr.so.2"); |
|
1672 |
return JNI_FALSE; |
|
1673 |
} |
|
1674 |
||
552
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1675 |
LOAD_XRANDR_FUNC(XRRQueryVersion); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1676 |
|
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1677 |
if (!(*awt_XRRQueryVersion)(awt_display, &rr_maj_ver, &rr_min_ver)) { |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1678 |
J2dRlsTraceLn(J2D_TRACE_ERROR, |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1679 |
"X11GD_InitXrandrFuncs: XRRQueryVersion returned an error status"); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1680 |
dlclose(pLibRandR); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1681 |
return JNI_FALSE; |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1682 |
} |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1683 |
|
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1684 |
if (usingXinerama) { |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1685 |
/* |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1686 |
* We can proceed as long as this is RANDR 1.2 or above. |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1687 |
* As of Xorg server 1.3 onwards the Xinerama backend may actually be |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1688 |
* a fake one provided by RANDR itself. See Java bug 6636469 for info. |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1689 |
*/ |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1690 |
if (!(rr_maj_ver > 1 || (rr_maj_ver == 1 && rr_min_ver >= 2))) { |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1691 |
J2dRlsTraceLn2(J2D_TRACE_INFO, "X11GD_InitXrandrFuncs: Can't use Xrandr. " |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1692 |
"Xinerama is active and Xrandr version is %d.%d", |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1693 |
rr_maj_ver, rr_min_ver); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1694 |
dlclose(pLibRandR); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1695 |
return JNI_FALSE; |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1696 |
} |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1697 |
|
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1698 |
/* |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1699 |
* REMIND: Fullscreen mode doesn't work quite right with multi-monitor |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1700 |
* setups and RANDR 1.2. So for now we also require a single screen. |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1701 |
*/ |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1702 |
if (awt_numScreens > 1 ) { |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1703 |
J2dRlsTraceLn(J2D_TRACE_INFO, "X11GD_InitXrandrFuncs: Can't use Xrandr. " |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1704 |
"Multiple screens in use"); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1705 |
dlclose(pLibRandR); |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1706 |
return JNI_FALSE; |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1707 |
} |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1708 |
} |
7213834c854f
6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents:
2
diff
changeset
|
1709 |
|
2 | 1710 |
LOAD_XRANDR_FUNC(XRRGetScreenInfo); |
1711 |
LOAD_XRANDR_FUNC(XRRFreeScreenConfigInfo); |
|
1712 |
LOAD_XRANDR_FUNC(XRRConfigRates); |
|
1713 |
LOAD_XRANDR_FUNC(XRRConfigCurrentRate); |
|
1714 |
LOAD_XRANDR_FUNC(XRRConfigSizes); |
|
1715 |
LOAD_XRANDR_FUNC(XRRConfigCurrentConfiguration); |
|
1716 |
LOAD_XRANDR_FUNC(XRRSetScreenConfigAndRate); |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1717 |
LOAD_XRANDR_FUNC(XRRConfigRotations); |
2 | 1718 |
|
1719 |
return JNI_TRUE; |
|
1720 |
} |
|
1721 |
||
1722 |
static jobject |
|
1723 |
X11GD_CreateDisplayMode(JNIEnv *env, jint width, jint height, |
|
1724 |
jint bitDepth, jint refreshRate) |
|
1725 |
{ |
|
1726 |
jclass displayModeClass; |
|
1727 |
jmethodID cid; |
|
4265
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1728 |
jint validRefreshRate = refreshRate; |
2 | 1729 |
|
1730 |
displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode"); |
|
1731 |
if (JNU_IsNull(env, displayModeClass)) { |
|
1732 |
JNU_ThrowInternalError(env, |
|
1733 |
"Could not get display mode class"); |
|
1734 |
return NULL; |
|
1735 |
} |
|
1736 |
||
1737 |
cid = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V"); |
|
1738 |
if (cid == NULL) { |
|
1739 |
JNU_ThrowInternalError(env, |
|
1740 |
"Could not get display mode constructor"); |
|
1741 |
return NULL; |
|
1742 |
} |
|
1743 |
||
4265
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1744 |
// early versions of xrandr may report "empty" rates (6880694) |
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1745 |
if (validRefreshRate <= 0) { |
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1746 |
validRefreshRate = REFRESH_RATE_UNKNOWN; |
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1747 |
} |
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1748 |
|
2 | 1749 |
return (*env)->NewObject(env, displayModeClass, cid, |
4265
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1750 |
width, height, bitDepth, validRefreshRate); |
2 | 1751 |
} |
1752 |
||
1753 |
static void |
|
1754 |
X11GD_AddDisplayMode(JNIEnv *env, jobject arrayList, |
|
1755 |
jint width, jint height, |
|
1756 |
jint bitDepth, jint refreshRate) |
|
1757 |
{ |
|
1758 |
jobject displayMode = X11GD_CreateDisplayMode(env, width, height, |
|
1759 |
bitDepth, refreshRate); |
|
1760 |
if (!JNU_IsNull(env, displayMode)) { |
|
1761 |
jclass arrayListClass; |
|
1762 |
jmethodID mid; |
|
1763 |
arrayListClass = (*env)->GetObjectClass(env, arrayList); |
|
1764 |
if (JNU_IsNull(env, arrayListClass)) { |
|
1765 |
JNU_ThrowInternalError(env, |
|
1766 |
"Could not get class java.util.ArrayList"); |
|
1767 |
return; |
|
1768 |
} |
|
1769 |
mid = (*env)->GetMethodID(env, arrayListClass, "add", |
|
1770 |
"(Ljava/lang/Object;)Z"); |
|
1771 |
if (mid == NULL) { |
|
1772 |
JNU_ThrowInternalError(env, |
|
1773 |
"Could not get method java.util.ArrayList.add()"); |
|
1774 |
return; |
|
1775 |
} |
|
1776 |
(*env)->CallObjectMethod(env, arrayList, mid, displayMode); |
|
1777 |
(*env)->DeleteLocalRef(env, displayMode); |
|
1778 |
} |
|
1779 |
} |
|
1780 |
||
1781 |
static void |
|
1782 |
X11GD_SetFullscreenMode(Window win, jboolean enabled) |
|
1783 |
{ |
|
1784 |
Atom wmState = XInternAtom(awt_display, "_NET_WM_STATE", False); |
|
1785 |
Atom wmStateFs = XInternAtom(awt_display, |
|
1786 |
"_NET_WM_STATE_FULLSCREEN", False); |
|
1787 |
Window root, parent, *children = NULL; |
|
1788 |
unsigned int numchildren; |
|
1789 |
XEvent event; |
|
1790 |
Status status; |
|
1791 |
||
1792 |
if (wmState == None || wmStateFs == None) { |
|
1793 |
return; |
|
1794 |
} |
|
1795 |
||
1796 |
/* |
|
1797 |
* Note: the Window passed to this method is typically the "content |
|
1798 |
* window" of the top-level, but we need the actual shell window for |
|
1799 |
* the purposes of constructing the XEvent. Therefore, we walk up the |
|
1800 |
* window hierarchy here to find the true top-level. |
|
1801 |
*/ |
|
1802 |
do { |
|
1803 |
if (!XQueryTree(awt_display, win, |
|
1804 |
&root, &parent, |
|
1805 |
&children, &numchildren)) |
|
1806 |
{ |
|
1807 |
return; |
|
1808 |
} |
|
1809 |
||
1810 |
if (children != NULL) { |
|
1811 |
XFree(children); |
|
1812 |
} |
|
1813 |
||
1814 |
if (parent == root) { |
|
1815 |
break; |
|
1816 |
} |
|
1817 |
||
1818 |
win = parent; |
|
1819 |
} while (root != parent); |
|
1820 |
||
1821 |
memset(&event, 0, sizeof(event)); |
|
1822 |
event.xclient.type = ClientMessage; |
|
1823 |
event.xclient.message_type = wmState; |
|
1824 |
event.xclient.display = awt_display; |
|
1825 |
event.xclient.window = win; |
|
1826 |
event.xclient.format = 32; |
|
1827 |
event.xclient.data.l[0] = enabled ? 1 : 0; // 1==add, 0==remove |
|
1828 |
event.xclient.data.l[1] = wmStateFs; |
|
1829 |
||
1830 |
XSendEvent(awt_display, root, False, |
|
1831 |
SubstructureRedirectMask | SubstructureNotifyMask, |
|
1832 |
&event); |
|
1833 |
XSync(awt_display, False); |
|
1834 |
} |
|
1835 |
#endif /* !HEADLESS */ |
|
1836 |
||
1837 |
/* |
|
1838 |
* Class: sun_awt_X11GraphicsDevice |
|
1839 |
* Method: initXrandrExtension |
|
1840 |
* Signature: ()Z |
|
1841 |
*/ |
|
1842 |
JNIEXPORT jboolean JNICALL |
|
1843 |
Java_sun_awt_X11GraphicsDevice_initXrandrExtension |
|
1844 |
(JNIEnv *env, jclass x11gd) |
|
1845 |
{ |
|
1846 |
#ifdef HEADLESS |
|
1847 |
return JNI_FALSE; |
|
1848 |
#else |
|
1849 |
int opcode = 0, firstEvent = 0, firstError = 0; |
|
1850 |
jboolean ret; |
|
1851 |
||
1852 |
AWT_LOCK(); |
|
1853 |
ret = (jboolean)XQueryExtension(awt_display, "RANDR", |
|
1854 |
&opcode, &firstEvent, &firstError); |
|
1855 |
if (ret) { |
|
1856 |
ret = X11GD_InitXrandrFuncs(env); |
|
1857 |
} |
|
1858 |
AWT_FLUSH_UNLOCK(); |
|
1859 |
||
1860 |
return ret; |
|
1861 |
#endif /* HEADLESS */ |
|
1862 |
} |
|
1863 |
||
1864 |
/* |
|
1865 |
* Class: sun_awt_X11GraphicsDevice |
|
1866 |
* Method: getCurrentDisplayMode |
|
1867 |
* Signature: (I)Ljava/awt/DisplayMode; |
|
1868 |
*/ |
|
1869 |
JNIEXPORT jobject JNICALL |
|
1870 |
Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode |
|
1871 |
(JNIEnv* env, jclass x11gd, jint screen) |
|
1872 |
{ |
|
1873 |
#ifdef HEADLESS |
|
1874 |
return NULL; |
|
1875 |
#else |
|
1876 |
XRRScreenConfiguration *config; |
|
1877 |
jobject displayMode = NULL; |
|
1878 |
||
1879 |
AWT_LOCK(); |
|
1880 |
||
1881 |
config = awt_XRRGetScreenInfo(awt_display, |
|
1882 |
RootWindow(awt_display, screen)); |
|
1883 |
if (config != NULL) { |
|
1884 |
Rotation rotation; |
|
1885 |
short curRate; |
|
1886 |
SizeID curSizeIndex; |
|
1887 |
XRRScreenSize *sizes; |
|
1888 |
int nsizes; |
|
1889 |
||
1890 |
curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation); |
|
1891 |
sizes = awt_XRRConfigSizes(config, &nsizes); |
|
1892 |
curRate = awt_XRRConfigCurrentRate(config); |
|
1893 |
||
1894 |
if ((sizes != NULL) && |
|
4265
8950a3d33a86
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents:
2955
diff
changeset
|
1895 |
(curSizeIndex < nsizes)) |
2 | 1896 |
{ |
1897 |
XRRScreenSize curSize = sizes[curSizeIndex]; |
|
1898 |
displayMode = X11GD_CreateDisplayMode(env, |
|
1899 |
curSize.width, |
|
1900 |
curSize.height, |
|
1901 |
BIT_DEPTH_MULTI, |
|
1902 |
curRate); |
|
1903 |
} |
|
1904 |
||
1905 |
awt_XRRFreeScreenConfigInfo(config); |
|
1906 |
} |
|
1907 |
||
1908 |
AWT_FLUSH_UNLOCK(); |
|
1909 |
||
1910 |
return displayMode; |
|
1911 |
#endif /* HEADLESS */ |
|
1912 |
} |
|
1913 |
||
1914 |
/* |
|
1915 |
* Class: sun_awt_X11GraphicsDevice |
|
1916 |
* Method: enumDisplayModes |
|
1917 |
* Signature: (ILjava/util/ArrayList;)V |
|
1918 |
*/ |
|
1919 |
JNIEXPORT void JNICALL |
|
1920 |
Java_sun_awt_X11GraphicsDevice_enumDisplayModes |
|
1921 |
(JNIEnv* env, jclass x11gd, |
|
1922 |
jint screen, jobject arrayList) |
|
1923 |
{ |
|
1924 |
#ifndef HEADLESS |
|
1925 |
XRRScreenConfiguration *config; |
|
1926 |
||
1927 |
AWT_LOCK(); |
|
1928 |
||
1929 |
config = awt_XRRGetScreenInfo(awt_display, |
|
1930 |
RootWindow(awt_display, screen)); |
|
1931 |
if (config != NULL) { |
|
1932 |
int nsizes, i, j; |
|
1933 |
XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes); |
|
1934 |
||
1935 |
if (sizes != NULL) { |
|
1936 |
for (i = 0; i < nsizes; i++) { |
|
1937 |
int nrates; |
|
1938 |
XRRScreenSize size = sizes[i]; |
|
1939 |
short *rates = awt_XRRConfigRates(config, i, &nrates); |
|
1940 |
||
1941 |
for (j = 0; j < nrates; j++) { |
|
1942 |
X11GD_AddDisplayMode(env, arrayList, |
|
1943 |
size.width, |
|
1944 |
size.height, |
|
1945 |
BIT_DEPTH_MULTI, |
|
1946 |
rates[j]); |
|
1947 |
} |
|
1948 |
} |
|
1949 |
} |
|
1950 |
||
1951 |
awt_XRRFreeScreenConfigInfo(config); |
|
1952 |
} |
|
1953 |
||
1954 |
AWT_FLUSH_UNLOCK(); |
|
1955 |
#endif /* !HEADLESS */ |
|
1956 |
} |
|
1957 |
||
1958 |
/* |
|
1959 |
* Class: sun_awt_X11GraphicsDevice |
|
1960 |
* Method: configDisplayMode |
|
1961 |
* Signature: (IIII)V |
|
1962 |
*/ |
|
1963 |
JNIEXPORT void JNICALL |
|
1964 |
Java_sun_awt_X11GraphicsDevice_configDisplayMode |
|
1965 |
(JNIEnv* env, jclass x11gd, |
|
1966 |
jint screen, jint width, jint height, jint refreshRate) |
|
1967 |
{ |
|
1968 |
#ifndef HEADLESS |
|
1969 |
jboolean success = JNI_FALSE; |
|
1970 |
XRRScreenConfiguration *config; |
|
1971 |
Drawable root; |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1972 |
Rotation currentRotation = RR_Rotate_0; |
2 | 1973 |
|
1974 |
AWT_LOCK(); |
|
1975 |
||
1976 |
root = RootWindow(awt_display, screen); |
|
1977 |
config = awt_XRRGetScreenInfo(awt_display, root); |
|
1978 |
if (config != NULL) { |
|
1979 |
jboolean foundConfig = JNI_FALSE; |
|
1980 |
int chosenSizeIndex = -1; |
|
1981 |
short chosenRate = -1; |
|
1982 |
int nsizes; |
|
1983 |
XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes); |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
1984 |
awt_XRRConfigRotations(config, ¤tRotation); |
2 | 1985 |
|
1986 |
if (sizes != NULL) { |
|
1987 |
int i, j; |
|
1988 |
||
1989 |
/* find the size index that matches the requested dimensions */ |
|
1990 |
for (i = 0; i < nsizes; i++) { |
|
1991 |
XRRScreenSize size = sizes[i]; |
|
1992 |
||
1993 |
if ((size.width == width) && (size.height == height)) { |
|
1994 |
/* we've found our size index... */ |
|
1995 |
int nrates; |
|
1996 |
short *rates = awt_XRRConfigRates(config, i, &nrates); |
|
1997 |
||
1998 |
/* now find rate that matches requested refresh rate */ |
|
1999 |
for (j = 0; j < nrates; j++) { |
|
2000 |
if (rates[j] == refreshRate) { |
|
2001 |
/* we've found our rate; break out of the loop */ |
|
2002 |
chosenSizeIndex = i; |
|
2003 |
chosenRate = rates[j]; |
|
2004 |
foundConfig = JNI_TRUE; |
|
2005 |
break; |
|
2006 |
} |
|
2007 |
} |
|
2008 |
||
2009 |
break; |
|
2010 |
} |
|
2011 |
} |
|
2012 |
} |
|
2013 |
||
2014 |
if (foundConfig) { |
|
2015 |
Status status = |
|
2016 |
awt_XRRSetScreenConfigAndRate(awt_display, config, root, |
|
2017 |
chosenSizeIndex, |
|
4266
b105f9beb20f
6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents:
4265
diff
changeset
|
2018 |
currentRotation, |
2 | 2019 |
chosenRate, |
2020 |
CurrentTime); |
|
2021 |
||
2022 |
/* issue XSync to ensure immediate mode change */ |
|
2023 |
XSync(awt_display, False); |
|
2024 |
||
2025 |
if (status == RRSetConfigSuccess) { |
|
2026 |
success = JNI_TRUE; |
|
2027 |
} |
|
2028 |
} |
|
2029 |
||
2030 |
awt_XRRFreeScreenConfigInfo(config); |
|
2031 |
} |
|
2032 |
||
2033 |
AWT_FLUSH_UNLOCK(); |
|
2034 |
||
2035 |
if (!success) { |
|
2036 |
JNU_ThrowInternalError(env, "Could not set display mode"); |
|
2037 |
} |
|
2038 |
#endif /* !HEADLESS */ |
|
2039 |
} |
|
2040 |
||
2041 |
/* |
|
2042 |
* Class: sun_awt_X11GraphicsDevice |
|
2043 |
* Method: enterFullScreenExclusive |
|
2044 |
* Signature: (J)V |
|
2045 |
*/ |
|
2046 |
JNIEXPORT void JNICALL |
|
2047 |
Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive |
|
2048 |
(JNIEnv* env, jclass x11gd, |
|
2049 |
jlong window) |
|
2050 |
{ |
|
2051 |
#ifndef HEADLESS |
|
2052 |
Window win = (Window)window; |
|
2053 |
||
2054 |
AWT_LOCK(); |
|
2055 |
XSync(awt_display, False); /* ensures window is visible first */ |
|
2056 |
X11GD_SetFullscreenMode(win, JNI_TRUE); |
|
2057 |
AWT_UNLOCK(); |
|
2058 |
#endif /* !HEADLESS */ |
|
2059 |
} |
|
2060 |
||
2061 |
/* |
|
2062 |
* Class: sun_awt_X11GraphicsDevice |
|
2063 |
* Method: exitFullScreenExclusive |
|
2064 |
* Signature: (J)V |
|
2065 |
*/ |
|
2066 |
JNIEXPORT void JNICALL |
|
2067 |
Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive |
|
2068 |
(JNIEnv* env, jclass x11gd, |
|
2069 |
jlong window) |
|
2070 |
{ |
|
2071 |
#ifndef HEADLESS |
|
2072 |
Window win = (Window)window; |
|
2073 |
||
2074 |
AWT_LOCK(); |
|
2075 |
X11GD_SetFullscreenMode(win, JNI_FALSE); |
|
2076 |
AWT_UNLOCK(); |
|
2077 |
#endif /* !HEADLESS */ |
|
2078 |
} |
|
2079 |
||
2080 |
/** |
|
2081 |
* End DisplayMode/FullScreen support |
|
2082 |
*/ |