jdk/src/solaris/native/sun/xawt/XToolkit.c
author anthony
Fri, 20 Feb 2009 17:34:16 +0300
changeset 2459 08f3416ff334
parent 2 90ce3da70b43
child 2802 d05a9dcc8296
permissions -rw-r--r--
6804747: Ensure consistent graphicsConfig member across components hierarchy Reviewed-by: art, dcherepanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <X11/Xlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <X11/Xutil.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <X11/Xos.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <X11/Xatom.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#ifdef __linux__
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <execinfo.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <jvm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "awt_MenuComponent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "awt_KeyboardFocusManager.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "awt_Font.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "sun_awt_X11_XToolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "java_awt_SystemColor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "java_awt_TrayIcon.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
uint32_t awt_NumLockMask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
Boolean  awt_ModLockIsShiftLock = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
extern JavaVM *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
// Tracing level
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
static int tracing = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#ifdef PRINT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#undef PRINT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#ifdef PRINT2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#undef PRINT2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define PRINT if (tracing) printf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define PRINT2 if (tracing > 1) printf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
struct ComponentIDs componentIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
struct MenuComponentIDs menuComponentIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
extern Display* awt_init_Display(JNIEnv *env, jobject this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
extern struct MFontPeerIDs mFontPeerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
Java_sun_awt_X11_XFontPeer_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    mFontPeerIDs.xfsname =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      (*env)->GetFieldID(env, cls, "xfsname", "Ljava/lang/String;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
/* This function gets called from the static initializer for FileDialog.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   to initialize the fieldIDs for fields that may be accessed from C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
Java_java_awt_FileDialog_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
Java_sun_awt_X11_XToolkit_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  (JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    jfieldID fid = (*env)->GetStaticFieldID(env, clazz, "numLockMask", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    awt_NumLockMask = (*env)->GetStaticIntField(env, clazz, fid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    DTRACE_PRINTLN1("awt_NumLockMask = %u", awt_NumLockMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    fid = (*env)->GetStaticFieldID(env, clazz, "modLockIsShiftLock", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * Class:     sun_awt_X11_XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * Method:    getDefaultXColormap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * Signature: ()J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getDefaultXColormap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  (JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    AwtGraphicsConfigDataPtr defaultConfig =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        getDefaultConfig(DefaultScreen(awt_display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    return (jlong) defaultConfig->awt_cmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getDefaultScreenData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  (JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    return ptr_to_jlong(getDefaultConfig(DefaultScreen(awt_display)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
JNI_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    jvm = vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * Class:     sun_awt_X11_XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * Method:    nativeLoadSystemColors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * Signature: ([I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_nativeLoadSystemColors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  (JNIEnv *env, jobject this, jintArray systemColors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    AwtGraphicsConfigDataPtr defaultConfig =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        getDefaultConfig(DefaultScreen(awt_display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    awtJNI_CreateColorData(env, defaultConfig, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
Java_java_awt_Component_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    jclass keyclass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    componentIDs.x = (*env)->GetFieldID(env, cls, "x", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    componentIDs.y = (*env)->GetFieldID(env, cls, "y", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    componentIDs.width = (*env)->GetFieldID(env, cls, "width", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    componentIDs.height = (*env)->GetFieldID(env, cls, "height", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    componentIDs.isPacked = (*env)->GetFieldID(env, cls, "isPacked", "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    componentIDs.peer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      (*env)->GetFieldID(env, cls, "peer", "Ljava/awt/peer/ComponentPeer;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    componentIDs.background =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
      (*env)->GetFieldID(env, cls, "background", "Ljava/awt/Color;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    componentIDs.foreground =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
      (*env)->GetFieldID(env, cls, "foreground", "Ljava/awt/Color;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    componentIDs.graphicsConfig =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        (*env)->GetFieldID(env, cls, "graphicsConfig",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                           "Ljava/awt/GraphicsConfiguration;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    componentIDs.name =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
      (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /* Use _NoClientCode() methods for trusted methods, so that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *  know that we are not invoking client code on trusted threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    componentIDs.getParent =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      (*env)->GetMethodID(env, cls, "getParent_NoClientCode",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                         "()Ljava/awt/Container;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    componentIDs.getLocationOnScreen =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
      (*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                         "()Ljava/awt/Point;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    DASSERT (keyclass != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    componentIDs.isProxyActive =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        (*env)->GetFieldID(env, keyclass, "isProxyActive",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                           "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    componentIDs.appContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        (*env)->GetFieldID(env, cls, "appContext",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                           "Lsun/awt/AppContext;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    (*env)->DeleteLocalRef(env, keyclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
Java_java_awt_Container_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
Java_java_awt_Button_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
Java_java_awt_Scrollbar_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
Java_java_awt_Window_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
Java_java_awt_Frame_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
Java_java_awt_MenuComponent_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    menuComponentIDs.appContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      (*env)->GetFieldID(env, cls, "appContext", "Lsun/awt/AppContext;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
Java_java_awt_Cursor_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
JNIEXPORT void JNICALL Java_java_awt_MenuItem_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
JNIEXPORT void JNICALL Java_java_awt_Menu_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
Java_java_awt_TextArea_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
Java_java_awt_Checkbox_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
JNIEXPORT void JNICALL Java_java_awt_ScrollPane_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
Java_java_awt_TextField_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
JNIEXPORT void JNICALL Java_java_awt_Dialog_initIDs (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
/* ========================== Begin poll section ================================ */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
// Includes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
#include <sys/time.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
#include <limits.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
#include <locale.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
#include <pthread.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
#include <fcntl.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
#include <poll.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
#ifndef POLLRDNORM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
#define POLLRDNORM POLLIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
// Prototypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
static void     waitForEvents(JNIEnv *, jlong);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
static void     awt_pipe_init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
static void     processOneEvent(XtInputMask iMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
static void     performPoll(JNIEnv *, jlong);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
static void     wakeUp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
static void     update_poll_timeout(int timeout_control);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
static uint32_t get_poll_timeout(jlong nextTaskTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
// Defines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
#ifndef bzero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
#define bzero(a,b) memset(a, 0, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
#define AWT_POLL_BUFSIZE        100 /* bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
#define AWT_READPIPE            (awt_pipe_fds[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
#define AWT_WRITEPIPE           (awt_pipe_fds[1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
#define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
#define TIMEOUT_TIMEDOUT 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
#define TIMEOUT_EVENTS 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
// Static fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
static uint32_t AWT_FLUSH_TIMEOUT  =  DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
static pthread_t    awt_MainThread = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
static int32_t      awt_pipe_fds[2];                   /* fds for wkaeup pipe */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
static Boolean      awt_pipe_inited = False;           /* make sure pipe is initialized before write */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
static jlong        awt_next_flush_time = 0LL; /* 0 == no scheduled flush */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
static jlong        awt_last_flush_time = 0LL; /* 0 == no scheduled flush */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
static uint32_t     curPollTimeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
static struct pollfd pollFds[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
static jlong        poll_sleep_time = 0LL; // Used for tracing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
static jlong        poll_wakeup_time = 0LL; // Used for tracing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
// AWT static poll timeout.  Zero means "not set", aging algorithm is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
// used.  Static poll timeout values higher than 50 cause application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
// look "slow" - they don't respond to user request fast
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
// enough. Static poll timeout value less than 10 are usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
// considered by schedulers as zero, so this might cause unnecessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
// CPU consumption by Java.  The values between 10 - 50 are suggested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
// for single client desktop configurations.  For SunRay servers, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
// is highly recomended to use aging algorithm (set static poll timeout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
// to 0).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
static int32_t static_poll_timeout = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
static Bool isMainThread() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    return awt_MainThread == pthread_self();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 * Creates the AWT utility pipe. This pipe exists solely so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
 * we can cause the main event thread to wake up from a poll() or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
 * select() by writing to this pipe.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
awt_pipe_init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    if (awt_pipe_inited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    if ( pipe ( awt_pipe_fds ) == 0 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        ** the write wakes us up from the infinite sleep, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        ** then we cause a delay of AWT_FLUSHTIME and then we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        ** flush.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        int32_t flags = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        /* set the pipe to be non-blocking */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        flags = fcntl ( AWT_READPIPE, F_GETFL, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        fcntl( AWT_READPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        flags = fcntl ( AWT_WRITEPIPE, F_GETFL, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        fcntl( AWT_WRITEPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        awt_pipe_inited = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        AWT_READPIPE = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        AWT_WRITEPIPE = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
} /* awt_pipe_init() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
 * Reads environment variables to initialize timeout fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
static void readEnv() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    char * value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    static Boolean env_read = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    if (env_read) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    env_read = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    value = getenv("_AWT_MAX_POLL_TIMEOUT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    if (value != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        AWT_MAX_POLL_TIMEOUT = atoi(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if (AWT_MAX_POLL_TIMEOUT == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    curPollTimeout = AWT_MAX_POLL_TIMEOUT/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    value = getenv("_AWT_FLUSH_TIMEOUT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    if (value != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        AWT_FLUSH_TIMEOUT = atoi(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        if (AWT_FLUSH_TIMEOUT == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    value = getenv("_AWT_POLL_TRACING");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    if (value != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        tracing = atoi(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    value = getenv("_AWT_STATIC_POLL_TIMEOUT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    if (value != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        static_poll_timeout = atoi(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    if (static_poll_timeout != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        curPollTimeout = static_poll_timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
 * Returns the amount of milliseconds similar to System.currentTimeMillis()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
static jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
awtJNI_TimeMillis(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    struct timeval t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    gettimeofday(&t, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    return jlong_add(jlong_mul(jint_to_jlong(t.tv_sec), jint_to_jlong(1000)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
             jint_to_jlong(t.tv_usec / 1000));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 * Updates curPollTimeout according to the aging algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 * @param timeout_control Either TIMEOUT_TIMEDOUT or TIMEOUT_EVENTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
static void update_poll_timeout(int timeout_control) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    PRINT2("tout: %d\n", timeout_control);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    // If static_poll_timeout is set, curPollTimeout has the fixed value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    if (static_poll_timeout != 0) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    // Update it otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    if (timeout_control == TIMEOUT_TIMEDOUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        /* add 1/4 (plus 1, in case the division truncates to 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        curPollTimeout += ((curPollTimeout>>2) + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    } else if (timeout_control == TIMEOUT_EVENTS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        /* subtract 1/4 (plus 1, in case the division truncates to 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        curPollTimeout -= ((curPollTimeout>>2) + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
 * Gets the best timeout for the next call to poll().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
 * @param nextTaskTime -1, if there are no tasks; next time when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
 * timeout task needs to be run, in millis(of currentTimeMillis)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
static uint32_t get_poll_timeout(jlong nextTaskTime)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    jlong curTime = awtJNI_TimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    uint32_t timeout = curPollTimeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    // Adjust timeout to flush_time and task_time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    return min(flushTimeout, min(taskTimeout, timeout));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
} /* awt_get_poll_timeout() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
 * Waits for X/Xt events to appear on the pipe. Returns only when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
 * it is likely (but not definite) that there are events waiting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
 * be processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
 * This routine also flushes the outgoing X queue, when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
 * awt_next_flush_time has been reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
 * If fdAWTPipe is greater or equal than zero the routine also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
 * checks if there are events pending on the putback queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
waitForEvents(JNIEnv *env, jlong nextTaskTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    performPoll(env, nextTaskTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    if ((awt_next_flush_time > 0) && (awtJNI_TimeMillis() >= awt_next_flush_time)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        XFlush(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        awt_last_flush_time = awt_next_flush_time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        awt_next_flush_time = 0LL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
} /* waitForEvents() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_waitForEvents (JNIEnv *env, jclass class, jlong nextTaskTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    waitForEvents(env, nextTaskTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_awt_1toolkit_1init (JNIEnv *env, jclass class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    awt_MainThread = pthread_self();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    awt_pipe_init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    readEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_awt_1output_1flush (JNIEnv *env, jclass class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    awt_output_flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_wakeup_1poll (JNIEnv *env, jclass class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    wakeUp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
 * Polls both the X pipe and our AWT utility pipe. Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
 * when there is data on one of the pipes, or the operation times
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
 * out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
 * Not all Xt events come across the X pipe (e.g., timers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
 * and alternate inputs), so we must time out every now and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
 * then to check the Xt event queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
 * The fdAWTPipe will be empty when this returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
performPoll(JNIEnv *env, jlong nextTaskTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    static Bool pollFdsInited = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    static char read_buf[AWT_POLL_BUFSIZE + 1];    /* dummy buf to empty pipe */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    uint32_t timeout = get_poll_timeout(nextTaskTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    int32_t result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    if (!pollFdsInited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        pollFds[0].fd = ConnectionNumber(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        pollFds[0].events = POLLRDNORM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        pollFds[0].revents = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        pollFds[1].fd = AWT_READPIPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        pollFds[1].events = POLLRDNORM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        pollFds[1].revents = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        pollFdsInited = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        pollFds[0].revents = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        pollFds[1].revents = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    AWT_NOFLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    /* ACTUALLY DO THE POLL() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    if (timeout == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        // be sure other threads get a chance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        awtJNI_ThreadYield(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    if (tracing) poll_sleep_time = awtJNI_TimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    result = poll( pollFds, 2, (int32_t) timeout );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    if (tracing) poll_wakeup_time = awtJNI_TimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    PRINT("%d of %d, res: %d\n", (int)(poll_wakeup_time-poll_sleep_time), (int)timeout, result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    if (result == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        /* poll() timed out -- update timeout value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        update_poll_timeout(TIMEOUT_TIMEDOUT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    if (pollFds[1].revents) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        int count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        PRINT("Woke up\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        /* There is data on the AWT pipe - empty it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        } while (count == AWT_POLL_BUFSIZE );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    if (pollFds[0].revents) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        // Events in X pipe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        update_poll_timeout(TIMEOUT_EVENTS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
} /* performPoll() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
 * Schedules next auto-flush event or performs forced flush depending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
 * on the time of the previous flush.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
void awt_output_flush() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    if (awt_next_flush_time == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        jlong curTime = awtJNI_TimeMillis(); // current time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        jlong l_awt_last_flush_time = awt_last_flush_time; // last time we flushed queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        jlong next_flush_time = l_awt_last_flush_time + AWT_FLUSH_TIMEOUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        if (curTime >= next_flush_time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            // Enough time passed from last flush
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            PRINT("f1\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            XFlush(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            awt_last_flush_time = curTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            AWT_NOFLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            awt_next_flush_time = next_flush_time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            PRINT("f2\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            wakeUp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
 * Wakes-up poll() in performPoll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
static void wakeUp() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    static char wakeUp_char = 'p';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    if (!isMainThread() && awt_pipe_inited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        write ( AWT_WRITEPIPE, &wakeUp_char, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
/* ========================== End poll section ================================= */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
 * Class:     java_awt_KeyboardFocusManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
Java_java_awt_KeyboardFocusManager_initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
 * Class:     sun_awt_X11_XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
 * Method:    getEnv
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
(JNIEnv *env , jclass clazz, jstring key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    char *ptr = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    const char *keystr = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    jstring ret = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    keystr = JNU_GetStringPlatformChars(env, key, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    if (key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        ptr = getenv(keystr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        if (ptr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            ret = JNU_NewStringPlatform(env, (const char *) ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        JNU_ReleaseStringPlatformChars(env, key, (const char*)keystr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
static XErrorHandler saved_error_handler = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
#ifdef __linux__
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
void print_stack(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
  void *array[10];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
  size_t size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
  char **strings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
  size_t i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
  size = backtrace (array, 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
  strings = backtrace_symbols (array, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
  fprintf (stderr, "Obtained %zd stack frames.\n", size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
  for (i = 0; i < size; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     fprintf (stderr, "%s\n", strings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
  free (strings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
static int NoisyXErrorHandler(Display * dpy, XErrorEvent * event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    fprintf(stderr, "id=%x, serial=%x, ec=%d, rc=%d, mc=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            event->resourceid, event->serial, event->error_code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            event->request_code, event->minor_code);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    #ifdef __linux__
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        print_stack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    #endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    if (jvm != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
      JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
      JNU_CallStaticMethodByName(env, NULL, "java/lang/Thread", "dumpStack", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    if (!saved_error_handler) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        return saved_error_handler(dpy, event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
 * Class:     sun_awt_X11_XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
 * Method:    setNoisyXErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
(JNIEnv *env , jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    (*env)->GetJavaVM(env, &jvm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    saved_error_handler = XSetErrorHandler(NoisyXErrorHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
Window get_xawt_root_shell(JNIEnv *env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
  static jclass classXRootWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
  static jmethodID methodGetXRootWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
  static Window xawt_root_shell = None;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  if (xawt_root_shell == None){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
      if (classXRootWindow == NULL){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
          jclass cls_tmp = (*env)->FindClass(env, "sun/awt/X11/XRootWindow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
          classXRootWindow = (jclass)(*env)->NewGlobalRef(env, cls_tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
          (*env)->DeleteLocalRef(env, cls_tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
      if( classXRootWindow != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
          methodGetXRootWindow = (*env)->GetStaticMethodID(env, classXRootWindow, "getXRootWindow", "()J");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
      if( classXRootWindow != NULL && methodGetXRootWindow !=NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
          xawt_root_shell = (Window) (*env)->CallStaticLongMethod(env, classXRootWindow, methodGetXRootWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
      if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        (*env)->ExceptionClear(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
  return xawt_root_shell;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
 * Old, compatibility, backdoor for DT.  This is a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
 * implementation.  It keeps the signature, but acts on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
 * awt_root_shell, not the frame passed as an argument.  Note, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
 * the code that uses the old backdoor doesn't work correctly with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
 * gnome session proxy that checks for WM_COMMAND when the window is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
 * firts mapped, because DT code calls this old backdoor *after* the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
 * frame is shown or it would get NPE with old AWT (previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
 * implementation of this backdoor) otherwise.  Old style session
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
 * managers (e.g. CDE) that check WM_COMMAND only during session
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
 * checkpoint should work fine, though.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
 * NB: The function name looks deceptively like a JNI native method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
 * name.  It's not!  It's just a plain function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    jobject frame, jstring jcommand)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    const char *command;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    XTextProperty text_prop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    char *c[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    int32_t status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    Window xawt_root_window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    xawt_root_window = get_xawt_root_shell(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    if ( xawt_root_window == None ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    command = (char *) JNU_GetStringPlatformChars(env, jcommand, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    c[0] = (char *)command;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    status = XmbTextListToTextProperty(awt_display, c, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                                       XStdICCTextStyle, &text_prop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    if (status == Success || status > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        XSetTextProperty(awt_display, xawt_root_window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                         &text_prop, XA_WM_COMMAND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        if (text_prop.value != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            XFree(text_prop.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    JNU_ReleaseStringPlatformChars(env, jcommand, command);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
 * New DT backdoor to set WM_COMMAND.  New code should use this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
 * backdoor and call it *before* the first frame is shown so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
 * gnome session proxy can correctly handle it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
 * NB: The function name looks deceptively like a JNI native method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
 * name.  It's not!  It's just a plain function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    static const char empty[] = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    int argc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    const char **cargv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    XTextProperty text_prop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    int status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    Window xawt_root_window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    xawt_root_window = get_xawt_root_shell(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    if (xawt_root_window == None) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
      JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
      AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
      return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    argc = (int)(*env)->GetArrayLength(env, jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    if (argc == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    /* array of C strings */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    cargv = (const char **)calloc(argc, sizeof(char *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    if (cargv == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        JNU_ThrowOutOfMemoryError(env, "Unable to allocate cargv");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    /* fill C array with platform chars of java strings */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
      for (i = 0; i < argc; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        jstring js;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        const char *cs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        cs = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        js = (*env)->GetObjectArrayElement(env, jargv, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        if (js != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            cs = JNU_GetStringPlatformChars(env, js, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        if (cs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            cs = empty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        cargv[i] = cs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        (*env)->DeleteLocalRef(env, js);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    /* grr, X prototype doesn't declare cargv as const, thought it really is */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    status = XmbTextListToTextProperty(awt_display, (char **)cargv, argc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                                       XStdICCTextStyle, &text_prop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    if (status < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        switch (status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        case XNoMemory:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            JNU_ThrowOutOfMemoryError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                "XmbTextListToTextProperty: XNoMemory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        case XLocaleNotSupported:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                "XmbTextListToTextProperty: XLocaleNotSupported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        case XConverterNotFound:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                "XmbTextListToTextProperty: XConverterNotFound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                "XmbTextListToTextProperty: unknown error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    XSetTextProperty(awt_display, xawt_root_window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                         &text_prop, XA_WM_COMMAND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    for (i = 0; i < argc; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        jstring js;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        if (cargv[i] == empty)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        js = (*env)->GetObjectArrayElement(env, jargv, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        JNU_ReleaseStringPlatformChars(env, js, cargv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        (*env)->DeleteLocalRef(env, js);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    if (text_prop.value != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        XFree(text_prop.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
 * Class:     java_awt_TrayIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
JNIEXPORT void JNICALL Java_java_awt_TrayIcon_initIDs(JNIEnv *env , jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
 * Class:     java_awt_Cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
 * Method:    finalizeImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
Java_java_awt_Cursor_finalizeImpl(JNIEnv *env, jclass clazz, jlong pData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    Cursor xcursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    xcursor = (Cursor)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    if (xcursor != None) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        XFreeCursor(awt_display, xcursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
}