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