jdk/src/solaris/native/sun/xawt/XlibWrapper.c
author chegar
Mon, 17 Jun 2013 11:26:16 +0100
changeset 18274 7c4289125569
parent 18253 4323a5fe8bc4
parent 17903 643f1ca93dd6
child 20155 65bcc88496eb
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 14659
diff changeset
     2
 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
    23
 * questions.
2
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 "sun_awt_X11_XlibWrapper.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <X11/Xlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <X11/keysym.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <X11/Xutil.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <X11/Xos.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <X11/Xatom.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <X11/extensions/Xdbe.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <X11/extensions/shape.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <stdlib.h>
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
    36
#include <X11/Sunkeysym.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include <jlong.h>
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
    41
#include <sizecalc.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include <awt.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include <jvm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include <Region.h>
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
    47
#include "utility/rect.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
    49
#include <X11/XKBlib.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#if defined(DEBUG) || defined(INTERNAL_BUILD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
static jmethodID lockIsHeldMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
CheckHaveAWTLock(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    if (lockIsHeldMID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        if (tkClass == NULL) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        lockIsHeldMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            (*env)->GetStaticMethodID(env, tkClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                                      "isAWTLockHeldByCurrentThread", "()Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    if (!(*env)->CallStaticBooleanMethod(env, tkClass, lockIsHeldMID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        JNU_ThrowInternalError(env, "Current thread does not hold AWT_LOCK!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define AWT_CHECK_HAVE_LOCK() CheckHaveAWTLock(env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define AWT_CHECK_HAVE_LOCK()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * Method:    XOpenDisplay
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XOpenDisplay
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
(JNIEnv *env, jclass clazz, jlong display_name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    Display *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    dp  =  XOpenDisplay((char *) jlong_to_ptr(display_name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    return ptr_to_jlong(dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
Java_sun_awt_X11_XlibWrapper_XCloseDisplay(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                       jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    XCloseDisplay((Display*) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
Java_sun_awt_X11_XlibWrapper_XDisplayString(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                        jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    return ptr_to_jlong(XDisplayString((Display*) jlong_to_ptr(display)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
Java_sun_awt_X11_XlibWrapper_XSetCloseDownMode(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                           jlong display, jint mode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    XSetCloseDownMode((Display*) jlong_to_ptr(display), (int)mode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * Method:    DefaultScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DefaultScreen (JNIEnv *env, jclass clazz, jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    return (jlong) DefaultScreen((Display *) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * Method:    ScreenOfDisplay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay(JNIEnv *env, jclass clazz, jlong display, jlong screen_number) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    return ptr_to_jlong(ScreenOfDisplay((Display *) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                        screen_number));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * Method:    DoesBackingStore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * Signature: (J)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_DoesBackingStore(JNIEnv *env, jclass clazz, jlong screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    return (jint) DoesBackingStore((Screen*) jlong_to_ptr(screen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * Method:    DisplayWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
(JNIEnv *env, jclass clazz, jlong display, jlong screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    return (jlong) DisplayWidth((Display *) jlong_to_ptr(display),screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * Method:    DisplayWidthMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayWidthMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
(JNIEnv *env, jclass clazz, jlong display, jlong screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return (jlong) DisplayWidthMM((Display *) jlong_to_ptr(display),screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * Method:    DisplayHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
(JNIEnv *env, jclass clazz, jlong display, jlong screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    return (jlong) DisplayHeight((Display *) jlong_to_ptr(display),screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * Method:    DisplayHeightMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayHeightMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
(JNIEnv *env, jclass clazz, jlong display, jlong screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    return (jlong) DisplayHeightMM((Display *) jlong_to_ptr(display),screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * Method:    RootWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_RootWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
(JNIEnv *env , jclass clazz, jlong display, jlong screen_number) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    return (jlong) RootWindow((Display *) jlong_to_ptr(display), screen_number);
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
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * Method:    ScreenCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_ScreenCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
(JNIEnv *env , jclass clazz, jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    return ScreenCount((Display *) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * Method:    XCreateWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * Signature: (JJIIIIIIJJJJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XCreateWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  (JNIEnv *env, jclass clazz, jlong display, jlong window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
   jint x, jint y, jint w, jint h , jint border_width, jint depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
   jlong wclass, jlong visual, jlong valuemask, jlong attributes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    return  XCreateWindow((Display *) jlong_to_ptr(display),(Window) window, x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
              border_width, depth, wclass, (Visual *) jlong_to_ptr(visual),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
              valuemask, (XSetWindowAttributes *) jlong_to_ptr(attributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 * Method:    XConvertCase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XConvertCase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
  (JNIEnv *env, jclass clazz, jlong keysym,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
   jlong keysym_lowercase, jlong keysym_uppercase)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    XConvertCase(keysym, (jlong_to_ptr(keysym_lowercase)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                         (jlong_to_ptr(keysym_uppercase)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * Method:    XMapWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XMapWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    XMapWindow( (Display *)jlong_to_ptr(display),(Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
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
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 * Method:    XMapRaised
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XMapRaised
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    XMapRaised( (Display *)jlong_to_ptr(display),(Window) window);
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
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 * Method:    XRaiseWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XRaiseWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    XRaiseWindow( (Display *)jlong_to_ptr(display),(Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * Method:    XLowerWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XLowerWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    XLowerWindow( (Display *)jlong_to_ptr(display),(Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
 * Method:    XRestackWindows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
 * Signature: (JJI)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XRestackWindows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
(JNIEnv *env, jclass clazz, jlong display, jlong windows, jint length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    XRestackWindows( (Display *) jlong_to_ptr(display), (Window *) jlong_to_ptr(windows), length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
 * Class:     XlibWrapper
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   312
 * Method:    XConfigureWindow
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   313
 * Signature: (JJJJ)V
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   314
 */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   315
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XConfigureWindow
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   316
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong value_mask,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   317
 jlong values)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   318
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   319
    AWT_CHECK_HAVE_LOCK();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   320
    XConfigureWindow((Display*)jlong_to_ptr(display), (Window)window,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   321
            (unsigned int)value_mask, (XWindowChanges*)jlong_to_ptr(values));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   322
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   323
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   324
/*
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
   325
 * Class:     XlibWrapper
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
 * Method:    XSetInputFocus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetInputFocus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    XSetInputFocus( (Display *)jlong_to_ptr(display),(Window) window, RevertToPointerRoot, CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
 * Method:    XSetInputFocus2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetInputFocus2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    XSetInputFocus( (Display *)jlong_to_ptr(display),(Window) window, RevertToPointerRoot, time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
 * Method:    XGetInputFocus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XGetInputFocus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
(JNIEnv *env, jclass clazz, jlong display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    Window focusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    int revert_to;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    XGetInputFocus( (Display *)jlong_to_ptr(display), &focusOwner, &revert_to);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    return focusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * Method:    XDestroyWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XDestroyWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    XDestroyWindow( (Display *)jlong_to_ptr(display),(Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
433
a7f6bc61993d 6677332: incorrect signatures for JNI methods in XWindow.c and XlibWrapper.c
son
parents: 2
diff changeset
   380
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGrabPointer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
(JNIEnv *env, jclass clazz, jlong display, jlong window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
 jint owner_events, jint event_mask, jint pointer_mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
 jint keyboard_mode, jlong confine_to, jlong cursor, jlong time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    return XGrabPointer( (Display *)jlong_to_ptr(display), (Window) window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
             (Bool) owner_events, (unsigned int) event_mask, (int) pointer_mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
             (int) keyboard_mode, (Window) confine_to, (Cursor) cursor, (Time) time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XUngrabPointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
(JNIEnv *env, jclass clazz, jlong display, jlong time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    XUngrabPointer( (Display *)jlong_to_ptr(display), (Time) time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
433
a7f6bc61993d 6677332: incorrect signatures for JNI methods in XWindow.c and XlibWrapper.c
son
parents: 2
diff changeset
   398
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGrabKeyboard
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
(JNIEnv *env, jclass clazz, jlong display, jlong window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
 jint owner_events, jint pointer_mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
 jint keyboard_mode, jlong time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    return XGrabKeyboard( (Display *)jlong_to_ptr(display), (Window) window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
              (Bool) owner_events, (int) pointer_mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
              (int) keyboard_mode, (Time) time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XUngrabKeyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
(JNIEnv *env, jclass clazz, jlong display, jlong time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    XUngrabKeyboard( (Display *)jlong_to_ptr(display), (Time) time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
Java_sun_awt_X11_XlibWrapper_XGrabServer(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                                         jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     XGrabServer((Display*)jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
Java_sun_awt_X11_XlibWrapper_XUngrabServer(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                           jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     XUngrabServer((Display*)jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     /* Workaround for bug 5039226 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     XSync((Display*)jlong_to_ptr(display), False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
 * Method:    XUnmapWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XUnmapWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    XUnmapWindow( (Display *)jlong_to_ptr(display),(Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSelectInput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong mask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    XSelectInput((Display *) jlong_to_ptr(display), (Window) window, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   455
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XkbSelectEvents
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   456
(JNIEnv *env, jclass clazz, jlong display, jlong device, jlong bits_to_change, jlong values_for_bits)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   457
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   458
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   459
    XkbSelectEvents((Display *) jlong_to_ptr(display), (unsigned int)device,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   460
                   (unsigned long)bits_to_change,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   461
                   (unsigned long)values_for_bits);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   462
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   463
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XkbSelectEventDetails
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   464
(JNIEnv *env, jclass clazz, jlong display, jlong device, jlong event_type, jlong bits_to_change, jlong values_for_bits)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   465
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   466
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   467
    XkbSelectEventDetails((Display *) jlong_to_ptr(display), (unsigned int)device,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   468
                   (unsigned int) event_type,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   469
                   (unsigned long)bits_to_change,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   470
                   (unsigned long)values_for_bits);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   471
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   472
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XkbQueryExtension
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   473
(JNIEnv *env, jclass clazz, jlong display, jlong opcode_rtrn, jlong event_rtrn,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   474
              jlong error_rtrn, jlong major_in_out, jlong minor_in_out)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   475
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   476
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   477
    return XkbQueryExtension( (Display *) jlong_to_ptr(display),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   478
                       (int *) jlong_to_ptr(opcode_rtrn),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   479
                       (int *) jlong_to_ptr(event_rtrn),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   480
                       (int *) jlong_to_ptr(error_rtrn),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   481
                       (int *) jlong_to_ptr(major_in_out),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   482
                       (int *) jlong_to_ptr(minor_in_out));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   483
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   484
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XkbLibraryVersion
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   485
(JNIEnv *env, jclass clazz, jlong lib_major_in_out, jlong lib_minor_in_out)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   486
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   487
    AWT_CHECK_HAVE_LOCK();
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   488
    *((int *)jlong_to_ptr(lib_major_in_out)) =  XkbMajorVersion;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   489
    *((int *)jlong_to_ptr(lib_minor_in_out)) =  XkbMinorVersion;
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   490
    return  XkbLibraryVersion((int *)jlong_to_ptr(lib_major_in_out), (int *)jlong_to_ptr(lib_minor_in_out));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   491
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   492
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   493
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XkbGetMap
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   494
(JNIEnv *env, jclass clazz, jlong display, jlong which, jlong device_spec)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   495
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   496
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   497
    return (jlong) XkbGetMap( (Display *) jlong_to_ptr(display),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   498
                              (unsigned int) which,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   499
                              (unsigned int) device_spec);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   500
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   501
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XkbGetUpdatedMap
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   502
(JNIEnv *env, jclass clazz, jlong display, jlong which, jlong xkb)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   503
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   504
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   505
    return (jlong) XkbGetUpdatedMap( (Display *) jlong_to_ptr(display),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   506
                              (unsigned int) which,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   507
                              (XkbDescPtr) jlong_to_ptr(xkb));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   508
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   509
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XkbFreeKeyboard
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   510
(JNIEnv *env, jclass clazz, jlong xkb, jlong which, jboolean free_all)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   511
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   512
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   513
    XkbFreeKeyboard(jlong_to_ptr(xkb), (unsigned int)which, free_all);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   514
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   515
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XkbTranslateKeyCode
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   516
(JNIEnv *env, jclass clazz, jlong xkb, jint keycode, jlong mods, jlong mods_rtrn, jlong keysym_rtrn)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   517
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   518
    Bool b;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   519
    b = XkbTranslateKeyCode((XkbDescPtr)xkb, (unsigned int)keycode, (unsigned int)mods,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   520
                              (unsigned int *)jlong_to_ptr(mods_rtrn),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   521
                               (KeySym *)jlong_to_ptr(keysym_rtrn));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   522
    //printf("native,  input: keycode:0x%0X; mods:0x%0X\n", keycode, mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   523
    //printf("native, output:  keysym:0x%0X; mods:0x%0X\n", *(unsigned int *)jlong_to_ptr(keysym_rtrn), *(unsigned int *)jlong_to_ptr(mods_rtrn));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   524
    return b;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   525
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   526
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   527
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
 * Method:    XNextEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XNextEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
(JNIEnv *env, jclass clazz, jlong display, jlong ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    XNextEvent( (Display *) jlong_to_ptr(display), jlong_to_ptr(ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
 * Method:    XMaskEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XMaskEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
  (JNIEnv *env, jclass clazz, jlong display, jlong event_mask, jlong event_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    XMaskEvent( (Display *) jlong_to_ptr(display), event_mask, (XEvent *) jlong_to_ptr(event_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
 * Method:    XWindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
 * Signature: (JJJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XWindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
  (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong event_mask, jlong event_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    XWindowEvent( (Display *) jlong_to_ptr(display), (Window)window, event_mask, (XEvent *) jlong_to_ptr(event_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
 * Method:    XFilterEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
 * Signature: (JJ)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XFilterEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
(JNIEnv *env, jclass clazz, jlong ptr, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    return (jboolean) XFilterEvent((XEvent *) jlong_to_ptr(ptr), (Window) window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
 * Method:    XSupportsLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XSupportsLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
(JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    return (jboolean)XSupportsLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
 * Method:    XSetLocaleModifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
JNIEXPORT jstring JNICALL Java_sun_awt_X11_XlibWrapper_XSetLocaleModifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
(JNIEnv *env, jclass clazz, jstring jstr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    char * modifier_list = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    char * ret = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        modifier_list = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    if (modifier_list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        ret = XSetLocaleModifiers(modifier_list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        JNU_ReleaseStringPlatformChars(env, jstr, (const char *) modifier_list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        ret = XSetLocaleModifiers("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    return (ret != NULL ? JNU_NewStringPlatform(env, ret): NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
 * Class:     sun_awt_X11_wrappers_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
 * Method:    XPeekEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XPeekEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
(JNIEnv *env, jclass clazz, jlong display, jlong ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    XPeekEvent((Display *) jlong_to_ptr(display),jlong_to_ptr(ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
 * Method:    XMoveResizeWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
 * Signature: (JJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XMoveResizeWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint x , jint y , jint width, jint height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    XMoveResizeWindow( (Display *) jlong_to_ptr(display), (Window) window, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
 * Method:    XResizeWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
 * Signature: (JJII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XResizeWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    XResizeWindow( (Display *) jlong_to_ptr(display),(Window) window,width,height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
 * Method:    XMoveWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
 * Signature: (JJII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XMoveWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    XMoveWindow( (Display *) jlong_to_ptr(display),(Window) window,width,height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
 * Method:    XSetWindowBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XSetWindowBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong background_pixel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    XSetWindowBackground((Display *) jlong_to_ptr(display),window,background_pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
 * Method:    XFlush
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XFlush
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
(JNIEnv *env, jclass clazz, jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    XFlush((Display *)jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
 * Method:    XSync
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
 * Signature: (JI)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSync
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
(JNIEnv *env, jclass clazz, jlong display, jint discard) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    XSync((Display *) jlong_to_ptr(display), discard);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
433
a7f6bc61993d 6677332: incorrect signatures for JNI methods in XWindow.c and XlibWrapper.c
son
parents: 2
diff changeset
   715
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XTranslateCoordinates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
(JNIEnv *env, jclass clazz, jlong display, jlong src_w, jlong dest_w,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
 jlong src_x, jlong src_y, jlong dest_x_return, jlong dest_y_return,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
 jlong child_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    return XTranslateCoordinates( (Display *) jlong_to_ptr(display), src_w, dest_w,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                  src_x, src_y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                  (int *) jlong_to_ptr(dest_x_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                  (int *) jlong_to_ptr(dest_y_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                  (Window *) jlong_to_ptr(child_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
433
a7f6bc61993d 6677332: incorrect signatures for JNI methods in XWindow.c and XlibWrapper.c
son
parents: 2
diff changeset
   728
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XEventsQueued
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
(JNIEnv *env, jclass clazz, jlong display, jint mode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    return XEventsQueued((Display *) jlong_to_ptr(display), mode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
 * Method:    SetProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
 * Signature: (JJJLjava/lang/String;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_SetProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong atom, jstring jstr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    char *cname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    XTextProperty tp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    int32_t status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
       In case there are direct support of UTF-8 declared, use UTF-8 strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
#ifdef X_HAVE_UTF8_STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        cname = (char *) (*env)->GetStringUTFChars(env, jstr, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        cname = (char *) JNU_GetStringPlatformChars(env, jstr, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        cname = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
#ifdef X_HAVE_UTF8_STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    status = Xutf8TextListToTextProperty((Display *)jlong_to_ptr(display), &cname, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                                       XStdICCTextStyle, &tp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    status = XmbTextListToTextProperty((Display *)jlong_to_ptr(display), &cname, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                                       XStdICCTextStyle, &tp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    if (status == Success || status > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        XChangeProperty((Display *)jlong_to_ptr(display), window, atom, tp.encoding, tp.format, PropModeReplace, tp.value, tp.nitems);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if (tp.value != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            XFree(tp.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
#ifdef X_HAVE_UTF8_STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        (*env)->ReleaseStringUTFChars(env, jstr, (const char *) cname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        JNU_ReleaseStringPlatformChars(env, jstr, (const char *) cname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
 * Method:    XChangeProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
 * Signature: (JJJJJJJJJJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XChangePropertyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    JNIEnv *env, jclass clazz, jlong display, jlong window, jlong property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    jlong type, jint format, jint mode, jlong data, jint nelements)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    XChangeProperty((Display*) jlong_to_ptr(display), (Window) window, (Atom) property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            (Atom) type, format, mode, (unsigned char*) jlong_to_ptr(data),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            nelements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
 * Method:    XChangePropertyS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
 * Signature: (JJJJJJJJJLjava/lang/String;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XChangePropertyS(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    JNIEnv *env, jclass clazz, jlong display, jlong window, jlong property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    jlong type, jint format, jint mode, jstring value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    jboolean iscopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    const char * chars = JNU_GetStringPlatformChars(env, value, &iscopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    XChangeProperty((Display*)jlong_to_ptr(display), window, (Atom)property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                    (Atom)type, format, mode, (unsigned char*)chars, strlen(chars));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    if (iscopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        JNU_ReleaseStringPlatformChars(env, value, chars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
 * Method:    XGetWindowProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
 * Signature: (JJJJJJJJJJJ)J;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetWindowProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong property, jlong long_offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
 jlong long_length, jlong delete, jlong req_type, jlong actual_type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
 jlong actual_format, jlong nitems_ptr, jlong bytes_after, jlong data_ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    return XGetWindowProperty((Display*) jlong_to_ptr(display), window, property, long_offset, long_length,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                  delete, (Atom) req_type, (Atom*) jlong_to_ptr(actual_type),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                  (int *) jlong_to_ptr(actual_format), (unsigned long *) jlong_to_ptr(nitems_ptr),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                  (unsigned long*) jlong_to_ptr(bytes_after), (unsigned char**) jlong_to_ptr(data_ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
 * Method:    GetProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
 * Signature: (JJJ)Ljava/lang/String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
JNIEXPORT jstring JNICALL Java_sun_awt_X11_XlibWrapper_GetProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong atom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    /* Request status */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    int status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    /* Returns of XGetWindowProperty */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    Atom actual_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    int actual_format;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    unsigned long nitems;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    unsigned long bytes_after;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    unsigned char * string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    jstring res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    status = XGetWindowProperty((Display*)jlong_to_ptr(display), window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                                atom, 0, 0xFFFF, False, XA_STRING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                                &actual_type, &actual_format, &nitems, &bytes_after,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                                &string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    if (status != Success || string == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    if (actual_type != XA_STRING || actual_format != 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    XFree(string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    // Memory leak???
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    return JNU_NewStringPlatform(env,(char*) string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
 * Method:    InternAtom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
 * Signature: (JLjava/lang/String;I)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_InternAtom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
(JNIEnv *env, jclass clazz, jlong display, jstring jstr, jint ife) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    char *cname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    unsigned long atom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        cname = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        cname = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    atom = XInternAtom((Display *) jlong_to_ptr(display), cname, ife);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        JNU_ReleaseStringPlatformChars(env, jstr, (const char *) cname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    return (jlong) atom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XCreateFontCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
(JNIEnv *env, jclass clazz, jlong display, jint shape) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    return XCreateFontCursor((Display *) jlong_to_ptr(display), (int) shape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
 * Method:    XCreatePixmapCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
 * Signature: (JJJJJII)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XCreatePixmapCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
(JNIEnv *env , jclass clazz, jlong display, jlong source, jlong mask, jlong fore, jlong back, jint x , jint y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    return (jlong) XCreatePixmapCursor((Display *) jlong_to_ptr(display), (Pixmap) source, (Pixmap) mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                                       (XColor *) jlong_to_ptr(fore), (XColor *) jlong_to_ptr(back), x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
 * Method:    XQueryBestCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
 * Signature: (JJIIJJ)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XQueryBestCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jint width, jint height, jlong width_return, jlong height_return) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    Status status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    status  =  XQueryBestCursor((Display *) jlong_to_ptr(display), (Drawable) drawable, width,height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                                (unsigned int *) jlong_to_ptr(width_return), (unsigned int *) jlong_to_ptr(height_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    if (status == 0) return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    else return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
 * Method:    XFreeCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XFreeCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
(JNIEnv *env, jclass clazz, jlong display, jlong cursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    XFreeCursor( (Display *) jlong_to_ptr(display), (Cursor) cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
 * Method:    XQueryPointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
 * Signature: (JJJJJJJJJ)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XQueryPointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
(JNIEnv *env, jclass clazz, jlong display, jlong w, jlong root_return, jlong child_return, jlong root_x_return , jlong root_y_return, jlong win_x_return, jlong win_y_return, jlong mask_return) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    Bool b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    b = XQueryPointer((Display *) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                      (Window) w, (Window *) jlong_to_ptr(root_return), (Window *) jlong_to_ptr(child_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                      (int *) jlong_to_ptr(root_x_return), (int *) jlong_to_ptr(root_y_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                      (int *) jlong_to_ptr(win_x_return), (int *) jlong_to_ptr(win_y_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                      (unsigned int *) jlong_to_ptr(mask_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    if (b == True) return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    else return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
 * Method:    XChangeWindowAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
 * Signature: (JJJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XChangeWindowAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong valuemask, jlong attributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    XChangeWindowAttributes((Display *) jlong_to_ptr(display), (Window) window, (unsigned long) valuemask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                            (XSetWindowAttributes *) jlong_to_ptr(attributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
 * Method:    XSetTransientFor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetTransientFor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong transient_for_window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    XSetTransientForHint((Display *) jlong_to_ptr(display), window, transient_for_window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
 * Method:    XSetWMHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetWMHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong hints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    XSetWMHints((Display *) jlong_to_ptr(display), window, (XWMHints *) jlong_to_ptr(hints));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
 * Method:    XGetWMHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XGetWMHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong hints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    XWMHints * get_hints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    get_hints = XGetWMHints((Display*)jlong_to_ptr(display), window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    if (get_hints != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        memcpy(jlong_to_ptr(hints), get_hints, sizeof(XWMHints));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        XFree(get_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
        memset(jlong_to_ptr(hints), 0, sizeof(XWMHints));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
 * Method:    XGetPointerMapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
 * Signature: (JJI)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetPointerMapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
(JNIEnv *env, jclass clazz, jlong display, jlong map, jint buttonNumber)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    return XGetPointerMapping((Display*)jlong_to_ptr(display), (unsigned char*) jlong_to_ptr(map), buttonNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
 * Method:    XGetDefault
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
 * Signature: (JJI)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
JNIEXPORT jstring JNICALL Java_sun_awt_X11_XlibWrapper_XGetDefault
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
(JNIEnv *env, jclass clazz, jlong display, jstring program, jstring option)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    char * c_program = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    char * c_option = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    char * c_res = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    if (!JNU_IsNull(env, program)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        c_program = (char *)JNU_GetStringPlatformChars(env, program, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    if (!JNU_IsNull(env, option)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        c_option = (char *)JNU_GetStringPlatformChars(env, option, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
    if (c_program == NULL || c_option == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        if (!JNU_IsNull(env, program)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
            JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        if (!JNU_IsNull(env, option)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
            JNU_ReleaseStringPlatformChars(env, option, (const char *) c_option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    c_res = XGetDefault((Display*)jlong_to_ptr(display), c_program, c_option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    if (!JNU_IsNull(env, program)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    if (!JNU_IsNull(env, option)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        JNU_ReleaseStringPlatformChars(env, option, (const char *) c_option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    if (c_res != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        // Memory leak???
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        return JNU_NewStringPlatform(env, c_res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
 * Method:    getScreenOfWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_getScreenOfWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    XWindowAttributes attrs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    memset(&attrs, 0, sizeof(attrs));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    XGetWindowAttributes((Display *) jlong_to_ptr(display), window, &attrs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    return ptr_to_jlong(attrs.screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
 * Method:    XScreenNumberOfScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XScreenNumberOfScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
(JNIEnv *env, jclass clazz, jlong screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    if(jlong_to_ptr(screen) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    return XScreenNumberOfScreen((Screen*) jlong_to_ptr(screen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
 * Method:    XIconifyWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XIconifyWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong screenNumber)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    return XIconifyWindow((Display*) jlong_to_ptr(display), window, screenNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
 * Method:    XFree
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XFree
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
(JNIEnv *env, jclass clazz, jlong ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
    XFree(jlong_to_ptr(ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
 * Method:    XFree
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
JNIEXPORT jbyteArray JNICALL Java_sun_awt_X11_XlibWrapper_getStringBytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
(JNIEnv *env, jclass clazz, jlong str_ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    unsigned char * str = (unsigned char*) jlong_to_ptr(str_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    long length = strlen((char*)str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
    jbyteArray res = (*env)->NewByteArray(env, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    void * storage = malloc(length+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    memcpy(storage, str, length+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
    (*env)->SetByteArrayRegion(env, res, 0, length,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                   (const signed char*) storage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
 * Method:    ServerVendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
 * Signature: (J)Ljava/lang/String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
JNIEXPORT jstring JNICALL Java_sun_awt_X11_XlibWrapper_ServerVendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
(JNIEnv *env, jclass clazz, jlong display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    return JNU_NewStringPlatform(env, ServerVendor((Display*)jlong_to_ptr(display)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
 * Method:    VendorRelease
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
 * Signature: (J)I;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_VendorRelease
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
(JNIEnv *env, jclass clazz, jlong display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    return VendorRelease((Display*)jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
}
3088
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1186
/*
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1187
 * Class:     sun_awt_X11_XlibWrapper
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1188
 * Method:    IsXsunKPBehavior
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1189
 * Signature: (J)Z;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1190
 */
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1191
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsXsunKPBehavior
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1192
(JNIEnv *env, jclass clazz, jlong display)
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1193
{
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1194
    // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event.
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1195
    // Otherwise, it is [1] or sometimes [0].
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1196
    // This sniffer first tries to determine what is a keycode for XK_KP_7
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1197
    // using XKeysymToKeycode;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1198
    // second, in which place in the keysymarray is XK_KP_7
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1199
    // using XKeycodeToKeysym.
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1200
    int kc7;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1201
    AWT_CHECK_HAVE_LOCK();
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1202
    kc7 = XKeysymToKeycode((Display*)jlong_to_ptr(display), XK_KP_7);
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1203
    if( !kc7 ) {
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1204
        // keycode is not defined. Why, it's a reduced keyboard perhaps:
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1205
        // report arbitrarily false.
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1206
        return JNI_FALSE;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1207
    } else {
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1208
        long ks2 = XKeycodeToKeysym((Display*)jlong_to_ptr(display), kc7, 2);
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1209
        if( ks2 == XK_KP_7 ) {
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1210
            //XXX If some Xorg server would put XK_KP_7 in keysymarray[2] as well,
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1211
            //XXX for yet unknown to me reason, the sniffer would lie.
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1212
            return JNI_TRUE;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1213
        }else{
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1214
            return JNI_FALSE;
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1215
        }
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1216
    }
b0260407a050 6711676: Numpad keys trigger more than one KeyEvent.
yan
parents: 2802
diff changeset
  1217
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1219
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1220
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsSunKeyboard
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1221
(JNIEnv *env, jclass clazz, jlong display)
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1222
{
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1223
    int xx;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1224
    AWT_CHECK_HAVE_LOCK();
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1225
    xx = XKeysymToKeycode((Display*)jlong_to_ptr(display), SunXK_F37);
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1226
    return (!xx) ? JNI_FALSE : JNI_TRUE;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1227
}
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1228
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1229
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsKanaKeyboard
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1230
(JNIEnv *env, jclass clazz, jlong display)
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1231
{
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1232
    int xx;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1233
    static jboolean result = JNI_FALSE;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1234
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1235
    int32_t minKeyCode, maxKeyCode, keySymsPerKeyCode;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1236
    KeySym *keySyms, *keySymsStart, keySym;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1237
    int32_t i;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1238
    int32_t kanaCount = 0;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1239
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1240
    AWT_CHECK_HAVE_LOCK();
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1241
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1242
    // There's no direct way to determine whether the keyboard has
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1243
    // a kana lock key. From available keyboard mapping tables, it looks
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1244
    // like only keyboards with the kana lock key can produce keysyms
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1245
    // for kana characters. So, as an indirect test, we check for those.
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1246
    XDisplayKeycodes((Display*)jlong_to_ptr(display), &minKeyCode, &maxKeyCode);
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1247
    keySyms = XGetKeyboardMapping((Display*)jlong_to_ptr(display), minKeyCode, maxKeyCode - minKeyCode + 1, &keySymsPerKeyCode);
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1248
    keySymsStart = keySyms;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1249
    for (i = 0; i < (maxKeyCode - minKeyCode + 1) * keySymsPerKeyCode; i++) {
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1250
        keySym = *keySyms++;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1251
        if ((keySym & 0xff00) == 0x0400) {
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1252
            kanaCount++;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1253
        }
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1254
    }
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1255
    XFree(keySymsStart);
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1256
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1257
    // use a (somewhat arbitrary) minimum so we don't get confused by a stray function key
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1258
    result = kanaCount > 10;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1259
    return result ? JNI_TRUE : JNI_FALSE;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1260
}
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1261
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
JavaVM* jvm = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
14659
cda39b3e7f15 8004344: Fix a crash in ToolkitErrorHandler() in XlibWrapper.c
aph
parents: 7668
diff changeset
  1264
    JNIEnv * env;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    if (jvm != NULL) {
14659
cda39b3e7f15 8004344: Fix a crash in ToolkitErrorHandler() in XlibWrapper.c
aph
parents: 7668
diff changeset
  1266
        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
cda39b3e7f15 8004344: Fix a crash in ToolkitErrorHandler() in XlibWrapper.c
aph
parents: 7668
diff changeset
  1267
        if (env) {
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 14659
diff changeset
  1268
            return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil",
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 14659
diff changeset
  1269
                "globalErrorHandler", "(JJ)I", ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
14659
cda39b3e7f15 8004344: Fix a crash in ToolkitErrorHandler() in XlibWrapper.c
aph
parents: 7668
diff changeset
  1270
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
    }
14659
cda39b3e7f15 8004344: Fix a crash in ToolkitErrorHandler() in XlibWrapper.c
aph
parents: 7668
diff changeset
  1272
    return 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
 * Method:    SetToolkitErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
 * Signature: ()J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
(JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    (*env)->GetJavaVM(env, &jvm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
    return ptr_to_jlong(XSetErrorHandler(ToolkitErrorHandler));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
 * Method:    XSetErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
(JNIEnv *env, jclass clazz, jlong handler)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
    XSetErrorHandler((XErrorHandler) jlong_to_ptr(handler));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
 * Method:    CallErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
 * Signature: (JJJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_CallErrorHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
(JNIEnv *env, jclass clazz, jlong handler, jlong display, jlong event_ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1311
2802
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1312
/*
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1313
 * Class:     sun_awt_X11_XlibWrapper
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1314
 * Method:    PrintXErrorEvent
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1315
 * Signature: (JJ)V
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1316
 */
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1317
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1318
(JNIEnv *env, jclass clazz, jlong display, jlong event_ptr)
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1319
{
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1320
    char msg[128];
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1321
    char buf[128];
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1322
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1323
    XErrorEvent* err = (XErrorEvent *)jlong_to_ptr(event_ptr);
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1324
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1325
    XGetErrorText((Display *)jlong_to_ptr(display), err->error_code, msg, sizeof(msg));
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1326
    jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1327
    jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1328
    XGetErrorDatabaseText((Display *)jlong_to_ptr(display), "XRequest", buf, "Unknown", msg, sizeof(msg));
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1329
    jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1330
    if (err->request_code > 128) {
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1331
        jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1332
    }
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2473
diff changeset
  1333
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
 * Method:    XInternAtoms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
 * Signature: (J[Ljava/lang/String;ZJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XInternAtoms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
(JNIEnv *env, jclass clazz, jlong display, jobjectArray names_arr, jboolean only_if_exists, jlong atoms)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    int length = (*env)->GetArrayLength(env, names_arr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
    char ** names = (char**)malloc(length*sizeof(char*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
    jboolean copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
    int index, name_index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
    int status;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1349
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1350
    AWT_CHECK_HAVE_LOCK();
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1351
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    for (index = 0; index < length; index++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
        jstring str = (*env)->GetObjectArrayElement(env, names_arr, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
        if (!JNU_IsNull(env, str)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
            const char * str_char = JNU_GetStringPlatformChars(env, str, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
            names[name_index++] = strdup(str_char);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
            JNU_ReleaseStringPlatformChars(env, str, str_char);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
            (*env)->DeleteLocalRef(env, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    status = XInternAtoms((Display*)jlong_to_ptr(display), names, name_index, only_if_exists, (Atom*) jlong_to_ptr(atoms));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
    for (index = 0; index < length; index++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
        free(names[index]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    free(names);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
    return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
 * Method:    XGetWindowAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
 * Signature: (JJJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetWindowAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong attr_ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
    jint status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
    memset((XWindowAttributes*) jlong_to_ptr(attr_ptr), 0, sizeof(XWindowAttributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
    status =  XGetWindowAttributes((Display*)jlong_to_ptr(display), window, (XWindowAttributes*) jlong_to_ptr(attr_ptr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
 * Method:    XGetGeometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
 * Signature: (JJJJJJJJJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetGeometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jlong root_return,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     jlong x_return, jlong y_return, jlong width_return, jlong height_return,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     jlong border_width_return, jlong depth_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    jint status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
    status = XGetGeometry((Display *)jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
                          (Drawable)drawable, (Window *)jlong_to_ptr(root_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
                          (int *)jlong_to_ptr(x_return), (int *)jlong_to_ptr(y_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
                          (unsigned int *)jlong_to_ptr(width_return), (unsigned int *)jlong_to_ptr(height_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                          (unsigned int *)jlong_to_ptr(border_width_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                          (unsigned int *)jlong_to_ptr(depth_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
 * Method:    XGetWMNormalHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
 * Signature: (JJJJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetWMNormalHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong hints, jlong supplied_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
    return XGetWMNormalHints((Display*) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                             window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                             (XSizeHints*) jlong_to_ptr(hints),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                             (long*) jlong_to_ptr(supplied_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
 * Method:    XSetWMNormalHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetWMNormalHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong hints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
    XSetWMNormalHints((Display*) jlong_to_ptr(display), window, (XSizeHints*) jlong_to_ptr(hints));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
 * Method:    XDeleteProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XDeleteProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong atom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
    XDeleteProperty((Display*) jlong_to_ptr(display), window, (Atom)atom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
 * Method:    XSendEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
 * Signature: (JJZJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XSendEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
(JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean propagate, jlong event_mask, jlong event)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    return XSendEvent((Display*) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
                      window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
                      propagate==JNI_TRUE?True:False,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
                      (long) event_mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
                      (XEvent*) jlong_to_ptr(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
 * Method:    XQueryTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
 * Signature: (JJJJJJ)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XQueryTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong root_return, jlong parent_return, jlong children_return, jlong nchildren_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
    return XQueryTree((Display*) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
                      window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
                      (Window *) jlong_to_ptr(root_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
                      (Window*) jlong_to_ptr(parent_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
                      (Window**) jlong_to_ptr(children_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
                      (unsigned int*) jlong_to_ptr(nchildren_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
 * Method:    memcpy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_memcpy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
(JNIEnv *env, jclass clazz, jlong dest_ptr, jlong src_ptr, jlong length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
    memcpy(jlong_to_ptr(dest_ptr), jlong_to_ptr(src_ptr), length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSetMinMaxHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y, jint width, jint height, jlong flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
    XSizeHints * hints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
    hints = XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
    hints->flags = flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    hints->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
    hints->min_width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
    hints->max_width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
    hints->height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
    hints->min_height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
    hints->max_height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
    hints->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
    hints->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
    XSetWMNormalHints((Display*) jlong_to_ptr(display), window, hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
    XFree(hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XGetVisualInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
(JNIEnv *env, jclass clazz, jlong display, jlong vinfo_mask, jlong vinfo_template,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
 jlong nitems_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
    return ptr_to_jlong(XGetVisualInfo((Display*) jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
                                       (long) vinfo_mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
                                       (XVisualInfo*) jlong_to_ptr(vinfo_template),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
                                       (int*) jlong_to_ptr(nitems_return)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XAllocSizeHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
  (JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
    return ptr_to_jlong(XAllocSizeHints());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
 * Method:    XIconifyWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
 * Signature: (JJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XBell
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
(JNIEnv *env, jclass clazz, jlong display, jint percent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
    XBell((Display*)jlong_to_ptr(display), percent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
 * Method:    XAllocColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
 * Signature: (JJJ)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XAllocColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
(JNIEnv *env, jclass clazz, jlong display , jlong colormap, jlong xcolor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
    Status status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
    status = XAllocColor((Display *) jlong_to_ptr(display), (Colormap) colormap, (XColor *) jlong_to_ptr(xcolor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
    if (status == 0) return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
    else return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
 * Method:    XCreateBitmapFromData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
 * Signature: (JJJII)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jlong data, jint width, jint height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
    return (jlong) XCreateBitmapFromData((Display *) jlong_to_ptr(display), (Drawable) drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
                                         (char *) jlong_to_ptr(data), width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
 * Method:    XFreePixmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
 * Signature: (JJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XFreePixmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
(JNIEnv *env, jclass clazz, jlong display, jlong pixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    XFreePixmap((Display *)jlong_to_ptr(display), (Pixmap) pixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
 * Method:    XReparentWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
 * Signature: (JJJII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XReparentWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong parent, jint x, jint y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    XReparentWindow((Display*)jlong_to_ptr(display), window, parent, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
 * Method:    XConvertSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
 * Signature: (JJJJJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
Java_sun_awt_X11_XlibWrapper_XConvertSelection(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                           jlong display, jlong selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                           jlong target, jlong property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
                           jlong requestor, jlong time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
    XConvertSelection((Display*)jlong_to_ptr(display), selection, target, property, requestor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
              time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
 * Method:    XSetSelectionOwner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
 * Signature: (JJJJ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
Java_sun_awt_X11_XlibWrapper_XSetSelectionOwner(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                        jlong display, jlong selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
                        jlong owner, jlong time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
    XSetSelectionOwner((Display*)jlong_to_ptr(display), selection, owner, time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
 * Method:    XGetSelectionOwner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
 * Signature: (JJ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
Java_sun_awt_X11_XlibWrapper_XGetSelectionOwner(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
                        jlong display, jlong selection) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    return (jlong)XGetSelectionOwner((Display*)jlong_to_ptr(display), selection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
 * Method:    XGetAtomName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
 * Signature: (JJ)Ljava/lang/String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
Java_sun_awt_X11_XlibWrapper_XGetAtomName(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
                      jlong display, jlong atom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
    jstring string = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
    char* name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
    name = (char*) XGetAtomName((Display*)jlong_to_ptr(display), atom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
    if (name == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
        fprintf(stderr, "Atom was %d\n", (int)atom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        JNU_ThrowNullPointerException(env, "Failed to retrieve atom name.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
    string = (*env)->NewStringUTF(env, (const char *)name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
    XFree(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
    return string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
 * Class:     sun_awt_X11_XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
 * Method:    XMaxRequestSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
Java_sun_awt_X11_XlibWrapper_XMaxRequestSize(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
                         jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
    return XMaxRequestSize((Display*) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
Java_sun_awt_X11_XlibWrapper_XAllocWMHints(JNIEnv *env, jclass clazz)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
    return ptr_to_jlong(XAllocWMHints());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
Java_sun_awt_X11_XlibWrapper_XCreatePixmap(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jint width, jint height, jint depth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
    return XCreatePixmap((Display*)jlong_to_ptr(display), (Drawable)drawable, width, height, depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
Java_sun_awt_X11_XlibWrapper_XCreateImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
  (JNIEnv *env, jclass clazz, jlong display, jlong visual_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
   jint depth, jint format, jint offset, jlong data, jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
   jint height, jint bitmap_pad, jint bytes_per_line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
    return ptr_to_jlong(XCreateImage((Display*) jlong_to_ptr(display), (Visual*) jlong_to_ptr(visual_ptr),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
                depth, format, offset, (char*) jlong_to_ptr(data),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
                width, height, bitmap_pad, bytes_per_line));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
Java_sun_awt_X11_XlibWrapper_XCreateGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
  (JNIEnv *env, jclass clazz, jlong display, jlong drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
   jlong valuemask, jlong values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
    return ptr_to_jlong(XCreateGC((Display*) jlong_to_ptr(display), (Drawable)drawable, valuemask, (XGCValues*) jlong_to_ptr(values)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
Java_sun_awt_X11_XlibWrapper_XDestroyImage(JNIEnv *env, jclass clazz, jlong image)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
    XImage *img = (XImage*) jlong_to_ptr(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
    // Fix for bug 4903671 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
    // We should be careful to not double free the memory pointed to data
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
    // Since we use unsafe to allocate it, we should use unsafe to free it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    // So we should NULL the data pointer before calling XDestroyImage so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
    // that X does not free the pointer for us.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    img->data = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
    XDestroyImage(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
Java_sun_awt_X11_XlibWrapper_XPutImage(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jlong gc, jlong image, jint src_x, jint src_y, jint dest_x, jint dest_y, jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    XPutImage((Display*)jlong_to_ptr(display), (Drawable)drawable, (GC) jlong_to_ptr(gc), (XImage*) jlong_to_ptr(image), src_x, src_y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
              dest_x, dest_y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
Java_sun_awt_X11_XlibWrapper_XFreeGC(JNIEnv *env, jclass clazz, jlong display, jlong gc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
    XFreeGC((Display*) jlong_to_ptr(display), (GC) jlong_to_ptr(gc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
Java_sun_awt_X11_XlibWrapper_XSetWindowBackgroundPixmap(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong pixmap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
    XSetWindowBackgroundPixmap((Display*) jlong_to_ptr(display), (Window)window, (Pixmap)pixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
Java_sun_awt_X11_XlibWrapper_XClearWindow(JNIEnv *env, jclass clazz, jlong display, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    XClearWindow((Display*) jlong_to_ptr(display), (Window)window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
Java_sun_awt_X11_XlibWrapper_XGetIconSizes(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong ret_sizes, jlong ret_count)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
    XIconSize** psize = (XIconSize**) jlong_to_ptr(ret_sizes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
    int * pcount = (int *) jlong_to_ptr(ret_count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    Status res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
    res = XGetIconSizes((Display*) jlong_to_ptr(display), (Window)window, psize, pcount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
    return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeQueryExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
  (JNIEnv *env, jclass clazz, jlong display, jlong major_version_return,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
   jlong minor_version_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
    return XdbeQueryExtension((Display*) jlong_to_ptr(display), (int *) jlong_to_ptr(major_version_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
                  (int *) jlong_to_ptr(minor_version_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XQueryExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
  (JNIEnv *env, jclass clazz, jlong display, jstring jstr, jlong mop_return,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
   jlong feve_return, jlong err_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
    char *cname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
    Boolean bu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
        cname = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
        cname = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
    bu = XQueryExtension((Display*) jlong_to_ptr(display), cname, (int *) jlong_to_ptr(mop_return),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
                (int *) jlong_to_ptr(feve_return),  (int *) jlong_to_ptr(err_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
    if (!JNU_IsNull(env, jstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
        JNU_ReleaseStringPlatformChars(env, jstr, (const char *) cname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
    return bu ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsKeypadKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
  (JNIEnv *env, jclass clazz, jlong keysym)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
    if(IsKeypadKey(keysym)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XdbeAllocateBackBufferName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
  (JNIEnv *env, jclass clazz, jlong display, jlong window, jint swap_action)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    return XdbeAllocateBackBufferName((Display*) jlong_to_ptr(display), (Window) window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
                      (XdbeSwapAction) swap_action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeDeallocateBackBufferName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
  (JNIEnv *env, jclass clazz, jlong display, jlong buffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
    return XdbeDeallocateBackBufferName((Display*) jlong_to_ptr(display), (XdbeBackBuffer) buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeBeginIdiom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
  (JNIEnv *env, jclass clazz, jlong display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
    return XdbeBeginIdiom((Display*) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeEndIdiom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
  (JNIEnv *env, jclass clazz, jlong display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
    return XdbeEndIdiom((Display*) jlong_to_ptr(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeSwapBuffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
  (JNIEnv *env, jclass clazz, jlong display, jlong swap_info, jint num_windows)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
    return XdbeSwapBuffers((Display*) jlong_to_ptr(display), (XdbeSwapInfo *) jlong_to_ptr(swap_info), num_windows);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
}
1966
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1836
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XQueryKeymap
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1837
(JNIEnv *env, jclass clazz, jlong display, jlong vector)
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1838
{
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1839
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1840
    AWT_CHECK_HAVE_LOCK();
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1841
    XQueryKeymap( (Display *) jlong_to_ptr(display), (char *) jlong_to_ptr(vector));
12a51fb0db0d 5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif
yan
parents: 715
diff changeset
  1842
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
                                              jlong display, jint keycode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
                                              jint index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
    return XKeycodeToKeysym((Display*) jlong_to_ptr(display), (unsigned int)keycode, (int)index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
JNIEXPORT jint JNICALL
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1853
Java_sun_awt_X11_XlibWrapper_XkbGetEffectiveGroup(JNIEnv *env, jclass clazz,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1854
                                              jlong display) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1855
    XkbStateRec sr;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1856
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1857
    memset(&sr, 0, sizeof(XkbStateRec));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1858
    XkbGetState((Display*) jlong_to_ptr(display), XkbUseCoreKbd, &sr);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1859
//    printf("-------------------------------------VVVV\n");
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1860
//    printf("                 group:0x%0X\n",sr.group);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1861
//    printf("            base_group:0x%0X\n",sr.base_group);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1862
//    printf("         latched_group:0x%0X\n",sr.latched_group);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1863
//    printf("          locked_group:0x%0X\n",sr.locked_group);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1864
//    printf("                  mods:0x%0X\n",sr.mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1865
//    printf("             base_mods:0x%0X\n",sr.base_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1866
//    printf("          latched_mods:0x%0X\n",sr.latched_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1867
//    printf("           locked_mods:0x%0X\n",sr.locked_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1868
//    printf("          compat_state:0x%0X\n",sr.compat_state);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1869
//    printf("             grab_mods:0x%0X\n",sr.grab_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1870
//    printf("      compat_grab_mods:0x%0X\n",sr.compat_grab_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1871
//    printf("           lookup_mods:0x%0X\n",sr.lookup_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1872
//    printf("    compat_lookup_mods:0x%0X\n",sr.compat_lookup_mods);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1873
//    printf("           ptr_buttons:0x%0X\n",sr.ptr_buttons);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1874
//    printf("-------------------------------------^^^^\n");
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1875
    return (jint)(sr.group);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1876
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1877
JNIEXPORT jlong JNICALL
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1878
Java_sun_awt_X11_XlibWrapper_XkbKeycodeToKeysym(JNIEnv *env, jclass clazz,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1879
                                              jlong display, jint keycode,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1880
                                              jint group, jint level) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1881
    AWT_CHECK_HAVE_LOCK();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1882
    return XkbKeycodeToKeysym((Display*) jlong_to_ptr(display), (unsigned int)keycode, (unsigned int)group, (unsigned int)level);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1883
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1884
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1885
JNIEXPORT jint JNICALL
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
                                              jlong display, jlong keysym) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
    return XKeysymToKeycode((Display*) jlong_to_ptr(display), (KeySym)keysym);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
Java_sun_awt_X11_XlibWrapper_XGetModifierMapping(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
                                              jlong display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
    return ptr_to_jlong(XGetModifierMapping((Display*) jlong_to_ptr(display)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
Java_sun_awt_X11_XlibWrapper_XFreeModifiermap(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
                                              jlong keymap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
    XFreeModifiermap((XModifierKeymap*) jlong_to_ptr(keymap));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
}
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1905
/*
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1906
 * Class:     sun_awt_X11_XlibWrapper
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1907
 * Method:    XRefreshKeyboardMapping
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1908
 * Signature: (J)V
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1909
 */
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1910
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XRefreshKeyboardMapping
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1911
(JNIEnv *env, jclass clazz, jlong event_ptr)
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1912
{
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1913
    AWT_CHECK_HAVE_LOCK();
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1914
    XRefreshKeyboardMapping((XMappingEvent*) jlong_to_ptr(event_ptr));
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3088
diff changeset
  1915
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
Java_sun_awt_X11_XlibWrapper_XChangeActivePointerGrab(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
                                                      jlong display, jint mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
                                                      jlong cursor, jlong time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
    XChangeActivePointerGrab((Display*)jlong_to_ptr(display), (unsigned int)mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
                             (Cursor)cursor, (Time)time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
/******************* Secondary loop support ************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
#define AWT_SECONDARY_LOOP_TIMEOUT 250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
static Bool exitSecondaryLoop = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
 * This predicate procedure allows the Toolkit thread to process specific events
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
 * while it is blocked waiting for the event dispatch thread to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
 * a SunDropTargetEvent. We need this to prevent deadlock when the client code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
 * processing SunDropTargetEvent sets or gets the contents of the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
 * clipboard/selection. In this case the event dispatch thread waits for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
 * Toolkit thread to process PropertyNotify or SelectionNotify events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
static Bool
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
secondary_loop_event(Display* dpy, XEvent* event, char* arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
    return (event->type == SelectionNotify ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
            event->type == SelectionClear  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
            event->type == PropertyNotify) ? True : False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
Java_sun_awt_X11_XlibWrapper_XNextSecondaryLoopEvent(JNIEnv *env, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
                                                     jlong display, jlong ptr) {
17903
643f1ca93dd6 8015375: Edits to text components hang for clipboard access
mcherkas
parents: 17679
diff changeset
  1950
    uint32_t timeout = 1;
643f1ca93dd6 8015375: Edits to text components hang for clipboard access
mcherkas
parents: 17679
diff changeset
  1951
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
    exitSecondaryLoop = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
    while (!exitSecondaryLoop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
        if (XCheckIfEvent((Display*) jlong_to_ptr(display), (XEvent*) jlong_to_ptr(ptr), secondary_loop_event, NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
        }
17903
643f1ca93dd6 8015375: Edits to text components hang for clipboard access
mcherkas
parents: 17679
diff changeset
  1958
        timeout = (timeout < AWT_SECONDARY_LOOP_TIMEOUT) ? (timeout << 1) : AWT_SECONDARY_LOOP_TIMEOUT;
643f1ca93dd6 8015375: Edits to text components hang for clipboard access
mcherkas
parents: 17679
diff changeset
  1959
        AWT_WAIT(timeout);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
Java_sun_awt_X11_XlibWrapper_ExitSecondaryLoop(JNIEnv *env, jclass clazz) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
    DASSERT(!exitSecondaryLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
    exitSecondaryLoop = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
    AWT_NOTIFY_ALL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
/*******************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
Java_sun_awt_X11_XlibWrapper_XTextPropertyToStringList(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
                                                       jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
                                                       jbyteArray bytes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                                                       jlong encodingAtom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
    XTextProperty tp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
    jbyte         *value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
    char**        strings  = (char **)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
    int32_t       nstrings = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
    jobjectArray  ret = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
    int32_t       i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
    jsize         len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
    jboolean      isCopy = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
    static jclass stringClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
    jclass        stringClassLocal = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
    if (JNU_IsNull(env, stringClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
        stringClassLocal = (*env)->FindClass(env, "java/lang/String");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
        if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
            (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
            (*env)->ExceptionClear(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
            DASSERT(False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
        if (JNU_IsNull(env, stringClassLocal)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        stringClass = (*env)->NewGlobalRef(env, stringClassLocal); /* never freed! */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
        (*env)->DeleteLocalRef(env, stringClassLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
        if (JNU_IsNull(env, stringClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
            JNU_ThrowOutOfMemoryError(env, "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
     * If the length of the byte array is 0 just return a null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
    len = (*env)->GetArrayLength(env, bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
    if (len == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
        return (*env)->NewObjectArray(env, 0, stringClass, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
    value = (*env)->GetByteArrayElements(env, bytes, &isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
    if (JNU_IsNull(env, value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
    tp.encoding = encodingAtom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
    tp.value    = (unsigned char *)value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
    tp.nitems   = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
    tp.format   = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
     * Convert the byte stream into a list of X11 strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
    if (XTextPropertyToStringList(&tp, &strings, &nstrings) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
        (*env)->ReleaseByteArrayElements(env, bytes, value, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
    (*env)->ReleaseByteArrayElements(env, bytes, value, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
    if (nstrings == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
        return (*env)->NewObjectArray(env, 0, stringClass, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
    ret = (*env)->NewObjectArray(env, nstrings, stringClass, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
    if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
        (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
        (*env)->ExceptionClear(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
        goto wayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
    if (JNU_IsNull(env, ret)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
        goto wayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
    for (i = 0; i < nstrings; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
        jstring string = (*env)->NewStringUTF(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
                                              (const char *)strings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
        if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
            (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
            (*env)->ExceptionClear(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
            goto wayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
        if (JNU_IsNull(env, string)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
            goto wayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
        (*env)->SetObjectArrayElement(env, ret, i, string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
        if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
            (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
            (*env)->ExceptionClear(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
            goto wayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
        (*env)->DeleteLocalRef(env, string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
 wayout:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
     * Clean up and return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
    XFreeStringList(strings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
Java_sun_awt_X11_XlibWrapper_XPutBackEvent(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
                                           jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
                                           jlong display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
                                           jlong event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
    XPutBackEvent((Display*)jlong_to_ptr(display), (XEvent*) jlong_to_ptr(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
Java_sun_awt_X11_XlibWrapper_getAddress(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
                                           jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
                                           jobject o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
    return ptr_to_jlong(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
Java_sun_awt_X11_XlibWrapper_copyIntArray(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
                                           jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
                                           jlong dest, jobject array, jint size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
    jboolean isCopy = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
    jint * ints = (*env)->GetIntArrayElements(env, array, &isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
    memcpy(jlong_to_ptr(dest), ints, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
    if (isCopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
        (*env)->ReleaseIntArrayElements(env, array, ints, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
Java_sun_awt_X11_XlibWrapper_copyLongArray(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
                                           jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
                                           jlong dest, jobject array, jint size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
    jboolean isCopy = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
    jlong * longs = (*env)->GetLongArrayElements(env, array, &isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
    memcpy(jlong_to_ptr(dest), longs, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
    if (isCopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
        (*env)->ReleaseLongArrayElements(env, array, longs, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
Java_sun_awt_X11_XlibWrapper_XSynchronize(JNIEnv *env, jclass clazz, jlong display, jboolean onoff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
    return (jint) XSynchronize((Display*)jlong_to_ptr(display), (onoff == JNI_TRUE ? True : False));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
Java_sun_awt_X11_XlibWrapper_XShapeQueryExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
(JNIEnv *env, jclass clazz, jlong display, jlong event_base_return, jlong error_base_return)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
    jboolean status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
    status = XShapeQueryExtension((Display *)jlong_to_ptr(display),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
            (int *)jlong_to_ptr(event_base_return), (int *)jlong_to_ptr(error_base_return));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
    return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
 * Class:     XlibWrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
 * Method:    SetRectangularShape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
Java_sun_awt_X11_XlibWrapper_SetRectangularShape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
(JNIEnv *env, jclass clazz, jlong display, jlong window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
 jint x1, jint y1, jint x2, jint y2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
 jobject region)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
    AWT_CHECK_HAVE_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2162
    // If all the params are zeros, the shape must be simply reset.
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2163
    // Otherwise, the shape may be not rectangular.
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2164
    if (region || x1 || x2 || y1 || y2) {
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2165
        XRectangle rects[256];
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2166
        XRectangle *pRect = rects;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2168
        int numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region,
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2169
                &pRect, 256);
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2170
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2171
        XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2172
                ShapeClip, 0, 0, pRect, numrects, ShapeSet, YXBanded);
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2173
        XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
                ShapeBounding, 0, 0, pRect, numrects, ShapeSet, YXBanded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2176
        if (pRect != rects) {
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2177
            free(pRect);
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2178
        }
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2179
    } else {
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2180
        // Reset the shape to a rectangular form.
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2181
        XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2182
                ShapeClip, 0, 0, None, ShapeSet);
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2183
        XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1966
diff changeset
  2184
                ShapeBounding, 0, 0, None, ShapeSet);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
}
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2187
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2188
/*
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2189
 * Class:     XlibWrapper
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2190
 * Method:    SetZOrder
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2191
 */
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2192
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2193
JNIEXPORT void JNICALL
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2194
Java_sun_awt_X11_XlibWrapper_SetZOrder
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2195
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong above)
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2196
{
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  2197
    unsigned int value_mask = CWStackMode;
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2198
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2199
    XWindowChanges wc;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2200
    wc.sibling = (Window)jlong_to_ptr(above);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2201
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  2202
    AWT_CHECK_HAVE_LOCK();
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2203
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2204
    if (above == 0) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2205
        wc.stack_mode = Above;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2206
    } else {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2207
        wc.stack_mode = Below;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2208
        value_mask |= CWSibling;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2209
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2210
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2211
    XConfigureWindow((Display *)jlong_to_ptr(display),
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2212
                     (Window)jlong_to_ptr(window),
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2213
                     value_mask, &wc );
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 1978
diff changeset
  2214
}
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2215
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2216
/*
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2217
 * Class:     XlibWrapper
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2218
 * Method:    SetBitmapShape
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2219
 */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2220
JNIEXPORT void JNICALL
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2221
Java_sun_awt_X11_XlibWrapper_SetBitmapShape
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2222
(JNIEnv *env, jclass clazz, jlong display, jlong window,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2223
 jint width, jint height, jintArray bitmap)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2224
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2225
    jsize len;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2226
    jint *values;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2227
    jboolean isCopy = JNI_FALSE;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2228
    size_t worstBufferSize = (size_t)((width / 2 + 1) * height);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2229
    RECT_T * pRect;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  2230
    int numrects;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2231
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2232
    if (!IS_SAFE_SIZE_MUL(width / 2 + 1, height)) {
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2233
        return;
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2234
    }
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2235
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2236
    AWT_CHECK_HAVE_LOCK();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2237
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2238
    len = (*env)->GetArrayLength(env, bitmap);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2239
    if (len == 0 || len < width * height) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2240
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2241
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2242
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2243
    values = (*env)->GetIntArrayElements(env, bitmap, &isCopy);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2244
    if (JNU_IsNull(env, values)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2245
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2246
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2247
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2248
    pRect = (RECT_T *)SAFE_SIZE_ARRAY_ALLOC(malloc, worstBufferSize, sizeof(RECT_T));
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2249
    if (!pRect) {
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2250
        return;
b538b71fb429 8009071: Improve shape handling
anthony
parents: 14659
diff changeset
  2251
    }
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2252
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2253
    /* Note: the values[0] and values[1] are supposed to contain the width
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2254
     * and height (see XIconInfo.getIntData() for details). So, we do +2.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2255
     */
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  2256
    numrects = BitmapToYXBandedRectangles(32, (int)width, (int)height,
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2257
            (unsigned char *)(values + 2), pRect);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2258
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2259
    XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2260
            ShapeClip, 0, 0, pRect, numrects, ShapeSet, YXBanded);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2261
    XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2262
            ShapeBounding, 0, 0, pRect, numrects, ShapeSet, YXBanded);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2263
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2264
    free(pRect);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2265
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2266
    (*env)->ReleaseIntArrayElements(env, bitmap, values, JNI_ABORT);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2267
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2462
diff changeset
  2268