63 static GetRasInfoFunc X11SD_GetRasInfo; |
63 static GetRasInfoFunc X11SD_GetRasInfo; |
64 static UnlockFunc X11SD_Unlock; |
64 static UnlockFunc X11SD_Unlock; |
65 static DisposeFunc X11SD_Dispose; |
65 static DisposeFunc X11SD_Dispose; |
66 static GetPixmapBgFunc X11SD_GetPixmapWithBg; |
66 static GetPixmapBgFunc X11SD_GetPixmapWithBg; |
67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg; |
67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg; |
|
68 extern int XShmAttachXErrHandler(Display *display, XErrorEvent *xerr); |
68 extern AwtGraphicsConfigDataPtr |
69 extern AwtGraphicsConfigDataPtr |
69 getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this); |
70 getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this); |
70 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
71 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
71 |
72 |
72 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, |
73 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, |
530 XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, |
531 XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, |
531 jint width, jint height) |
532 jint width, jint height) |
532 { |
533 { |
533 XImage *img = NULL; |
534 XImage *img = NULL; |
534 XShmSegmentInfo *shminfo; |
535 XShmSegmentInfo *shminfo; |
535 JNIEnv* env; |
|
536 jboolean xShmAttachResult; |
|
537 |
536 |
538 shminfo = malloc(sizeof(XShmSegmentInfo)); |
537 shminfo = malloc(sizeof(XShmSegmentInfo)); |
539 if (shminfo == NULL) { |
538 if (shminfo == NULL) { |
540 return NULL; |
539 return NULL; |
541 } |
540 } |
571 return NULL; |
570 return NULL; |
572 } |
571 } |
573 |
572 |
574 shminfo->readOnly = False; |
573 shminfo->readOnly = False; |
575 |
574 |
576 env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
575 resetXShmAttachFailed(); |
577 xShmAttachResult = TryXShmAttach(env, awt_display, shminfo); |
576 EXEC_WITH_XERROR_HANDLER(XShmAttachXErrHandler, |
|
577 XShmAttach(awt_display, shminfo)); |
578 |
578 |
579 /* |
579 /* |
580 * Once the XSync round trip has finished then we |
580 * Once the XSync round trip has finished then we |
581 * can get rid of the id so that this segment does not stick |
581 * can get rid of the id so that this segment does not stick |
582 * around after we go away, holding system resources. |
582 * around after we go away, holding system resources. |
583 */ |
583 */ |
584 shmctl(shminfo->shmid, IPC_RMID, 0); |
584 shmctl(shminfo->shmid, IPC_RMID, 0); |
585 |
585 |
586 if (xShmAttachResult == JNI_FALSE) { |
586 if (isXShmAttachFailed() == JNI_TRUE) { |
587 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
587 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
588 "X11SD_SetupSharedSegment XShmAttach has failed: %s", |
588 "X11SD_SetupSharedSegment XShmAttach has failed: %s", |
589 strerror(errno)); |
589 strerror(errno)); |
590 shmdt(shminfo->shmaddr); |
590 shmdt(shminfo->shmaddr); |
591 free((void *)shminfo); |
591 free((void *)shminfo); |