src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
author itakiguchi
Wed, 08 May 2019 22:59:20 -0700
changeset 54875 bcfedddcf4ce
parent 53319 db7b41933563
permissions -rw-r--r--
8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion() Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
     2
 * Copyright (c) 2004, 2019, 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: 5444
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: 5444
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: 5444
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
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 <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <unistd.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <jni.h>
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
    32
#include <sizecalc.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "sun_awt_UNIXToolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "awt.h"
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    37
#include "gtk_interface.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
static jclass this_class = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
static jmethodID icon_upcall_method = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Method:    check_gtk
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    48
 * Signature: (I)Z
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
JNIEXPORT jboolean JNICALL
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    51
Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass, jint version) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#ifndef HEADLESS
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    53
    return (jboolean)gtk_check_version(version);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * Method:    load_gtk
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    63
 * Signature: (I)Z
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
JNIEXPORT jboolean JNICALL
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    66
Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass, jint version,
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    67
                                                             jboolean verbose) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#ifndef HEADLESS
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    69
    return (jboolean)gtk_load(env, version, verbose);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * Method:    unload_gtk
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
Java_sun_awt_UNIXToolkit_unload_1gtk(JNIEnv *env, jclass klass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#ifndef HEADLESS
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    85
    return (jboolean)gtk->unload();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
    91
jboolean init_method(JNIEnv *env, jobject this)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    if (this_class == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this_class = (*env)->NewGlobalRef(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                                          (*env)->GetObjectClass(env, this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        icon_upcall_method = (*env)->GetMethodID(env, this_class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                                 "loadIconCallback", "([BIIIIIZ)V");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 23010
diff changeset
    98
        CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   100
    return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * Method:    load_gtk_icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * Signature: (Ljava/lang/String)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * This method assumes that GTK libs are present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
Java_sun_awt_UNIXToolkit_load_1gtk_1icon(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        jstring filename)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    int len;
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   116
    jsize jlen;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    char *filename_str = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    GError **error = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    if (filename == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    len = (*env)->GetStringUTFLength(env, filename);
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   126
    jlen = (*env)->GetStringLength(env, filename);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   127
    filename_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   128
            sizeof(char), len + 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    if (filename_str == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   133
    if (!init_method(env, this) ) {
40146
e824dfef29db 8161740: [parfait] Memory leak in Java_sun_awt_UNIXToolkit_load_1gtk_1icon of awt_UNIXToolkit.c:132
vadim
parents: 37711
diff changeset
   134
        free(filename_str);
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   135
        return JNI_FALSE;
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   136
    }
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   137
    (*env)->GetStringUTFRegion(env, filename, 0, jlen, filename_str);
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   138
    jboolean result = gtk->get_file_icon_data(env, filename_str, error,
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   139
                                            icon_upcall_method, this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /* Release the strings we've allocated. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    free(filename_str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   144
    return result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#else /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * Method:    load_stock_icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * Signature: (ILjava/lang/String;IILjava/lang/String;)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * This method assumes that GTK libs are present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
Java_sun_awt_UNIXToolkit_load_1stock_1icon(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        jint widget_type, jstring stock_id, jint icon_size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        jint text_direction, jstring detail)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    int len;
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   164
    jsize jlen;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    char *stock_id_str = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    char *detail_str = NULL;
53319
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   167
    jboolean result = JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    if (stock_id == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    len = (*env)->GetStringUTFLength(env, stock_id);
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   175
    jlen = (*env)->GetStringLength(env, stock_id);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   176
    stock_id_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   177
            sizeof(char), len + 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    if (stock_id_str == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   182
    (*env)->GetStringUTFRegion(env, stock_id, 0, jlen, stock_id_str);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /* Detail isn't required so check for NULL. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    if (detail != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        len = (*env)->GetStringUTFLength(env, detail);
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   188
        jlen = (*env)->GetStringLength(env, detail);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   189
        detail_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
b538b71fb429 8009071: Improve shape handling
anthony
parents: 7668
diff changeset
   190
                sizeof(char), len + 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (detail_str == NULL) {
52251
b43c2aa001a5 8211317: avoid memory leak in Java_sun_awt_UNIXToolkit_load_1stock_1icon
mbaesken
parents: 47216
diff changeset
   192
            free(stock_id_str);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
54875
bcfedddcf4ce 8211826: StringIndexOutOfBoundsException happens via GetStringUTFRegion()
itakiguchi
parents: 53319
diff changeset
   196
        (*env)->GetStringUTFRegion(env, detail, 0, jlen, detail_str);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
53319
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   199
    if (init_method(env, this)) {
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   200
        result = gtk->get_icon_data(env, widget_type, stock_id_str,
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   201
                                    icon_size, text_direction, detail_str,
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   202
                                    icon_upcall_method, this);
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   203
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /* Release the strings we've allocated. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    free(stock_id_str);
53319
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   206
    free(detail_str);
db7b41933563 8204895: Better icon support
serb
parents: 52251
diff changeset
   207
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   208
    return result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
#else /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * Class:     sun_awt_UNIXToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * Method:    nativeSync
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
Java_sun_awt_UNIXToolkit_nativeSync(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * Class:     sun_awt_SunToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * Method:    closeSplashScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
Java_sun_awt_SunToolkit_closeSplashScreen(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    typedef void (*SplashClose_t)();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    SplashClose_t splashClose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    void* hSplashLib = dlopen(0, RTLD_LAZY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    if (!hSplashLib) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    splashClose = (SplashClose_t)dlsym(hSplashLib,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        "SplashClose");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    if (splashClose) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        splashClose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    dlclose(hSplashLib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   250
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   251
/*
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   252
 * Class:     sun_awt_UNIXToolkit
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   253
 * Method:    gtkCheckVersionImpl
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   254
 * Signature: (III)Ljava/lang/String;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   255
 */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   256
JNIEXPORT jboolean JNICALL
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   257
Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl(JNIEnv *env, jobject this,
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   258
        jint major, jint minor, jint micro)
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   259
{
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   260
    char *ret;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   261
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   262
    ret = gtk->gtk_check_version(major, minor, micro);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   263
    if (ret == NULL) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   264
        return TRUE;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   265
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   266
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   267
    return FALSE;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents: 2
diff changeset
   268
}
37711
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   269
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   270
/*
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   271
 * Class:     sun_awt_UNIXToolkit
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   272
 * Method:    get_gtk_version
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   273
 * Signature: ()I
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   274
 */
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   275
JNIEXPORT jint JNICALL
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   276
Java_sun_awt_UNIXToolkit_get_1gtk_1version(JNIEnv *env, jclass klass)
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   277
{
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   278
#ifndef HEADLESS
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   279
    return gtk ? gtk->version : GTK_ANY;
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   280
#else
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   281
    return GTK_ANY;
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   282
#endif /* !HEADLESS */
972001566d66 8145547: [AWT/Swing] Conditional support for GTK 3 on Linux
ssadetsky
parents: 26751
diff changeset
   283
}