< prev index next >

src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c

Print this page




  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
  23  * questions.
  24  */
  25 
  26 #include <X11/Xlib.h>
  27 #include <X11/Xutil.h>
  28 #include <X11/Xos.h>
  29 #include <X11/Xatom.h>
  30 #ifdef __linux__
  31 #include <execinfo.h>
  32 #endif
  33 
  34 #include <jvm.h>
  35 #include <jni.h>
  36 #include <jlong.h>
  37 #include <jni_util.h>
  38 
  39 #include "awt_p.h"
  40 #include "awt_Component.h"
  41 #include "awt_MenuComponent.h"
  42 #include "awt_Font.h"
  43 #include "awt_util.h"
  44 
  45 #include "sun_awt_X11_XToolkit.h"
  46 #include "java_awt_SystemColor.h"
  47 #include "java_awt_TrayIcon.h"
  48 #include <X11/extensions/XTest.h>
  49 
  50 #include <unistd.h>
  51 
  52 uint32_t awt_NumLockMask = 0;


 773  * Class:     sun_awt_X11_XToolkit
 774  * Method:    getEnv
 775  * Signature: (Ljava/lang/String;)Ljava/lang/String;
 776  */
 777 JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv
 778 (JNIEnv *env , jclass clazz, jstring key) {
 779     char *ptr = NULL;
 780     const char *keystr = NULL;
 781     jstring ret = NULL;
 782 
 783     keystr = JNU_GetStringPlatformChars(env, key, NULL);
 784     if (keystr) {
 785         ptr = getenv(keystr);
 786         if (ptr) {
 787             ret = JNU_NewStringPlatform(env, (const char *) ptr);
 788         }
 789         JNU_ReleaseStringPlatformChars(env, key, (const char*)keystr);
 790     }
 791     return ret;
 792 }
 793 
 794 #ifdef __linux__
 795 void print_stack(void)
 796 {
 797   void *array[10];
 798   size_t size;
 799   char **strings;
 800   size_t i;
 801 
 802   size = backtrace (array, 10);
 803   strings = backtrace_symbols (array, size);
 804 
 805   fprintf (stderr, "Obtained %zd stack frames.\n", size);
 806 
 807   for (i = 0; i < size; i++)
 808      fprintf (stderr, "%s\n", strings[i]);
 809 
 810   free (strings);
 811 }
 812 #endif
 813 
 814 Window get_xawt_root_shell(JNIEnv *env) {
 815   static jclass classXRootWindow = NULL;
 816   static jmethodID methodGetXRootWindow = NULL;
 817   static Window xawt_root_shell = None;
 818 
 819   if (xawt_root_shell == None){
 820       if (classXRootWindow == NULL){
 821           jclass cls_tmp = (*env)->FindClass(env, "sun/awt/X11/XRootWindow");
 822           if (!JNU_IsNull(env, cls_tmp)) {
 823               classXRootWindow = (jclass)(*env)->NewGlobalRef(env, cls_tmp);
 824               (*env)->DeleteLocalRef(env, cls_tmp);
 825           }
 826       }
 827       if( classXRootWindow != NULL) {
 828           methodGetXRootWindow = (*env)->GetStaticMethodID(env, classXRootWindow, "getXRootWindow", "()J");
 829       }
 830       if( classXRootWindow != NULL && methodGetXRootWindow !=NULL ) {
 831           xawt_root_shell = (Window) (*env)->CallStaticLongMethod(env, classXRootWindow, methodGetXRootWindow);
 832       }




  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
  23  * questions.
  24  */
  25 
  26 #include <X11/Xlib.h>
  27 #include <X11/Xutil.h>
  28 #include <X11/Xos.h>
  29 #include <X11/Xatom.h>



  30 
  31 #include <jvm.h>
  32 #include <jni.h>
  33 #include <jlong.h>
  34 #include <jni_util.h>
  35 
  36 #include "awt_p.h"
  37 #include "awt_Component.h"
  38 #include "awt_MenuComponent.h"
  39 #include "awt_Font.h"
  40 #include "awt_util.h"
  41 
  42 #include "sun_awt_X11_XToolkit.h"
  43 #include "java_awt_SystemColor.h"
  44 #include "java_awt_TrayIcon.h"
  45 #include <X11/extensions/XTest.h>
  46 
  47 #include <unistd.h>
  48 
  49 uint32_t awt_NumLockMask = 0;


 770  * Class:     sun_awt_X11_XToolkit
 771  * Method:    getEnv
 772  * Signature: (Ljava/lang/String;)Ljava/lang/String;
 773  */
 774 JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv
 775 (JNIEnv *env , jclass clazz, jstring key) {
 776     char *ptr = NULL;
 777     const char *keystr = NULL;
 778     jstring ret = NULL;
 779 
 780     keystr = JNU_GetStringPlatformChars(env, key, NULL);
 781     if (keystr) {
 782         ptr = getenv(keystr);
 783         if (ptr) {
 784             ret = JNU_NewStringPlatform(env, (const char *) ptr);
 785         }
 786         JNU_ReleaseStringPlatformChars(env, key, (const char*)keystr);
 787     }
 788     return ret;
 789 }




















 790 
 791 Window get_xawt_root_shell(JNIEnv *env) {
 792   static jclass classXRootWindow = NULL;
 793   static jmethodID methodGetXRootWindow = NULL;
 794   static Window xawt_root_shell = None;
 795 
 796   if (xawt_root_shell == None){
 797       if (classXRootWindow == NULL){
 798           jclass cls_tmp = (*env)->FindClass(env, "sun/awt/X11/XRootWindow");
 799           if (!JNU_IsNull(env, cls_tmp)) {
 800               classXRootWindow = (jclass)(*env)->NewGlobalRef(env, cls_tmp);
 801               (*env)->DeleteLocalRef(env, cls_tmp);
 802           }
 803       }
 804       if( classXRootWindow != NULL) {
 805           methodGetXRootWindow = (*env)->GetStaticMethodID(env, classXRootWindow, "getXRootWindow", "()J");
 806       }
 807       if( classXRootWindow != NULL && methodGetXRootWindow !=NULL ) {
 808           xawt_root_shell = (Window) (*env)->CallStaticLongMethod(env, classXRootWindow, methodGetXRootWindow);
 809       }


< prev index next >