src/solaris/native/sun/awt/awt_GraphicsEnv.c

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 888 /*
 889  * Class:     sun_awt_X11GraphicsDevice
 890  * Method:    getDisplay
 891  * Signature: ()J
 892  */
 893 JNIEXPORT jlong JNICALL
 894 Java_sun_awt_X11GraphicsDevice_getDisplay(JNIEnv *env, jobject this)
 895 {
 896 #ifdef HEADLESS
 897     return NULL;
 898 #else
 899     return ptr_to_jlong(awt_display);
 900 #endif /* !HEADLESS */
 901 }
 902 
 903 #ifdef MITSHM
 904 
 905 static jint canUseShmExt = UNSET_MITSHM;
 906 static jint canUseShmExtPixmaps = UNSET_MITSHM;
 907 static jboolean xshmAttachFailed = JNI_FALSE;

 908 
 909 int J2DXErrHandler(Display *display, XErrorEvent *xerr) {
 910     int ret = 0;
 911     if (xerr->minor_code == X_ShmAttach) {
 912         xshmAttachFailed = JNI_TRUE;
 913     } else {


 914         ret = (*xerror_saved_handler)(display, xerr);


 915     }
 916     return ret;
 917 }
 918 jboolean isXShmAttachFailed() {
 919     return xshmAttachFailed;
 920 }
 921 void resetXShmAttachFailed() {
 922     xshmAttachFailed = JNI_FALSE;
 923 }
 924 
 925 void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) {
 926     XShmSegmentInfo shminfo;
 927     int XShmMajor, XShmMinor;
 928     int a, b, c;
 929 
 930     AWT_LOCK();
 931     if (canUseShmExt != UNSET_MITSHM) {
 932         *shmExt = canUseShmExt;
 933         *shmPixmaps = canUseShmExtPixmaps;
 934         AWT_UNLOCK();


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 888 /*
 889  * Class:     sun_awt_X11GraphicsDevice
 890  * Method:    getDisplay
 891  * Signature: ()J
 892  */
 893 JNIEXPORT jlong JNICALL
 894 Java_sun_awt_X11GraphicsDevice_getDisplay(JNIEnv *env, jobject this)
 895 {
 896 #ifdef HEADLESS
 897     return NULL;
 898 #else
 899     return ptr_to_jlong(awt_display);
 900 #endif /* !HEADLESS */
 901 }
 902 
 903 #ifdef MITSHM
 904 
 905 static jint canUseShmExt = UNSET_MITSHM;
 906 static jint canUseShmExtPixmaps = UNSET_MITSHM;
 907 static jboolean xshmAttachFailed = JNI_FALSE;
 908 static int j2dxErrHandlerCallsCount = 0;
 909 
 910 int J2DXErrHandler(Display *display, XErrorEvent *xerr) {
 911     int ret = 0;
 912     if (xerr->minor_code == X_ShmAttach) {
 913         xshmAttachFailed = JNI_TRUE;
 914     } else {
 915         // Verify that this handler is not called twice for the same error.
 916         if (++j2dxErrHandlerCallsCount < 2) {
 917             ret = (*xerror_saved_handler)(display, xerr);
 918         }
 919         j2dxErrHandlerCallsCount--;
 920     }
 921     return ret;
 922 }
 923 jboolean isXShmAttachFailed() {
 924     return xshmAttachFailed;
 925 }
 926 void resetXShmAttachFailed() {
 927     xshmAttachFailed = JNI_FALSE;
 928 }
 929 
 930 void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) {
 931     XShmSegmentInfo shminfo;
 932     int XShmMajor, XShmMinor;
 933     int a, b, c;
 934 
 935     AWT_LOCK();
 936     if (canUseShmExt != UNSET_MITSHM) {
 937         *shmExt = canUseShmExt;
 938         *shmPixmaps = canUseShmExtPixmaps;
 939         AWT_UNLOCK();