src/solaris/native/sun/xawt/XlibWrapper.c

Print this page


   1 /*
   2  * Copyright (c) 2002, 2010, 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


1247     keySymsStart = keySyms;
1248     for (i = 0; i < (maxKeyCode - minKeyCode + 1) * keySymsPerKeyCode; i++) {
1249         keySym = *keySyms++;
1250         if ((keySym & 0xff00) == 0x0400) {
1251             kanaCount++;
1252         }
1253     }
1254     XFree(keySymsStart);
1255 
1256     // use a (somewhat arbitrary) minimum so we don't get confused by a stray function key
1257     result = kanaCount > 10;
1258     return result ? JNI_TRUE : JNI_FALSE;
1259 }
1260 
1261 JavaVM* jvm = NULL;
1262 static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
1263     JNIEnv * env;
1264     if (jvm != NULL) {
1265         env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
1266         if (env) {
1267             return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
1268                                               ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
1269         }
1270     }
1271     return 0;
1272 }
1273 
1274 /*
1275  * Class:     sun_awt_X11_XlibWrapper
1276  * Method:    SetToolkitErrorHandler
1277  * Signature: ()J
1278  */
1279 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler
1280 (JNIEnv *env, jclass clazz)
1281 {
1282     (*env)->GetJavaVM(env, &jvm);
1283     AWT_CHECK_HAVE_LOCK();
1284     return ptr_to_jlong(XSetErrorHandler(ToolkitErrorHandler));
1285 }
1286 
1287 /*
1288  * Class:     sun_awt_X11_XlibWrapper


   1 /*
   2  * Copyright (c) 2002, 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


1247     keySymsStart = keySyms;
1248     for (i = 0; i < (maxKeyCode - minKeyCode + 1) * keySymsPerKeyCode; i++) {
1249         keySym = *keySyms++;
1250         if ((keySym & 0xff00) == 0x0400) {
1251             kanaCount++;
1252         }
1253     }
1254     XFree(keySymsStart);
1255 
1256     // use a (somewhat arbitrary) minimum so we don't get confused by a stray function key
1257     result = kanaCount > 10;
1258     return result ? JNI_TRUE : JNI_FALSE;
1259 }
1260 
1261 JavaVM* jvm = NULL;
1262 static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
1263     JNIEnv * env;
1264     if (jvm != NULL) {
1265         env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
1266         if (env) {
1267             return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil",
1268                 "globalErrorHandler", "(JJ)I", ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
1269         }
1270     }
1271     return 0;
1272 }
1273 
1274 /*
1275  * Class:     sun_awt_X11_XlibWrapper
1276  * Method:    SetToolkitErrorHandler
1277  * Signature: ()J
1278  */
1279 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler
1280 (JNIEnv *env, jclass clazz)
1281 {
1282     (*env)->GetJavaVM(env, &jvm);
1283     AWT_CHECK_HAVE_LOCK();
1284     return ptr_to_jlong(XSetErrorHandler(ToolkitErrorHandler));
1285 }
1286 
1287 /*
1288  * Class:     sun_awt_X11_XlibWrapper