173 x11GraphicsDeviceIDs.screen = (*env)->GetFieldID (env, cls, "screen", "I"); |
173 x11GraphicsDeviceIDs.screen = (*env)->GetFieldID (env, cls, "screen", "I"); |
174 DASSERT(x11GraphicsDeviceIDs.screen); |
174 DASSERT(x11GraphicsDeviceIDs.screen); |
175 } |
175 } |
176 |
176 |
177 #ifndef HEADLESS |
177 #ifndef HEADLESS |
178 /* |
178 |
179 * error handlers |
179 /* |
180 */ |
180 * XIOErrorHandler |
181 |
181 */ |
182 int |
182 static int xioerror_handler(Display *disp) |
183 xerror_handler(Display * disp, XErrorEvent * err) |
|
184 { |
|
185 /* #ifdef DEBUG */ |
|
186 char msg[128]; |
|
187 char buf[128]; |
|
188 char *ev = getenv("NOISY_AWT"); |
|
189 |
|
190 if (!ev || !ev[0]) |
|
191 return 0; |
|
192 XGetErrorText(disp, err->error_code, msg, sizeof(msg)); |
|
193 jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial); |
|
194 jio_snprintf(buf, sizeof(buf), "%d", err->request_code); |
|
195 XGetErrorDatabaseText(disp, "XRequest", buf, "Unknown", msg, sizeof(msg)); |
|
196 jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg); |
|
197 if (err->request_code > 128) { |
|
198 jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code); |
|
199 } |
|
200 if (awtLockInited) { |
|
201 /*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", msg); */ |
|
202 } |
|
203 if (strcasecmp(ev, "abort") == 0) { |
|
204 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
205 |
|
206 (*env)->FatalError(env, "xerror_handler abort"); |
|
207 } |
|
208 /* #endif */ |
|
209 return 0; |
|
210 } |
|
211 |
|
212 static int |
|
213 xioerror_handler(Display * disp) |
|
214 { |
183 { |
215 if (awtLockInited) { |
184 if (awtLockInited) { |
216 if (errno == EPIPE) { |
185 if (errno == EPIPE) { |
217 jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL)); |
186 jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL)); |
218 } |
187 } |
884 (getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY")); |
853 (getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY")); |
885 JNU_ThrowInternalError(env, errmsg); |
854 JNU_ThrowInternalError(env, errmsg); |
886 return NULL; |
855 return NULL; |
887 } |
856 } |
888 |
857 |
889 XSetErrorHandler(xerror_handler); |
|
890 XSetIOErrorHandler(xioerror_handler); |
858 XSetIOErrorHandler(xioerror_handler); |
891 |
859 |
892 /* set awt_numScreens, and whether or not we're using Xinerama */ |
860 /* set awt_numScreens, and whether or not we're using Xinerama */ |
893 xineramaInit(); |
861 xineramaInit(); |
894 |
862 |