src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
author serb
Tue, 29 Jan 2019 13:53:54 -0800
changeset 53675 58ec9ada9234
parent 53673 e04d39094915
child 53678 9b93a6b30cbe
permissions -rw-r--r--
8214918: Unify GraphicsEnvironment.getCenterPoint()/getMaximumWindowBounds() across the platforms Reviewed-by: kaddepalli, aivanov, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53673
e04d39094915 8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents: 52719
diff changeset
     2
 * Copyright (c) 1997, 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: 4266
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: 4266
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: 4266
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4266
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4266
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
28080
4baf6faff689 8064698: [parfait] JNI exception pending in jdk/src/java/desktop/unix/native: libawt_xawt/awt/, common/awt
azvegint
parents: 26751
diff changeset
    26
#include "jni_util.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "awt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "color.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <java_awt_DisplayMode.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <sun_awt_X11GraphicsEnvironment.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <sun_awt_X11GraphicsDevice.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <sun_awt_X11GraphicsConfig.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <X11/extensions/Xdbe.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <X11/XKBlib.h>
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
    37
#ifndef NO_XRANDR
52533
7d99b410be1b 8210863: Remove Xrandr include files from JDK sources
prr
parents: 47216
diff changeset
    38
#include <X11/extensions/Xrandr.h>
52658
2d18e5ed0f8d 8213944: Fix AIX build after the removal of Xrandr.h and add a configure check for it
simonis
parents: 52533
diff changeset
    39
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "GLXGraphicsConfig.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include <jvm.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
    46
#include <jvm_md.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include <jlong.h>
36869
f8ef78f4157d 8145174: HiDPI splash screen support on Linux
rchamyal
parents: 34395
diff changeset
    48
#include "systemScale.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#include "awt_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#ifdef NETSCAPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#include <signal.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
extern int awt_init_xt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
int awt_numScreens;     /* Xinerama-aware number of screens */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
AwtScreenDataPtr x11Screens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Set in initDisplay() to indicate whether we should attempt to initialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * GLX for the default configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
static jboolean glxRequested = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define Display void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
Display *awt_display;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
jclass tkClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
jmethodID awtLockMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
jmethodID awtUnlockMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
jmethodID awtWaitMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
jmethodID awtNotifyMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
jmethodID awtNotifyAllMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
jboolean awtLockInited = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/** Convenience macro for loading the lock-related method IDs. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define GET_STATIC_METHOD(klass, method_id, method_name, method_sig) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        method_id = (*env)->GetStaticMethodID(env, klass, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                                              method_name, method_sig); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        if (method_id == NULL) return NULL; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
int awtCreateX11Colormap(AwtGraphicsConfigDataPtr adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
static char *x11GraphicsConfigClassName = "sun/awt/X11GraphicsConfig";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
/* AWT and Xinerama
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * As of fix 4356756, AWT is Xinerama-aware.  X11GraphicsDevices are created for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * each screen of a Xinerama setup, though X11 itself still only sees a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * In many places where we talk to X11, a xinawareScreen variable is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * pass the correct Display value, depending on the circumstances (a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * X display, multiple X displays, or a single X display with multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * Xinerama screens).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * Solaris and Linux differ in the functions used to access Xinerama-related
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * data.  This is in part because at this time, the X consortium has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * finalized the "official" Xinerama API.  Once this spec is available, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * both OSes are conformant, one code base should be sufficient for Xinerama
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * operation on both OSes.  Until then, some of the Xinerama-related code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * is ifdef'd appropriately.  -bchristi, 7/12/01
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define MAXFRAMEBUFFERS 16
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   125
#if defined(__linux__) || defined(MACOSX)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   int   screen_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   short x_org;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   short y_org;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
   short width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
   short height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
} XineramaScreenInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
typedef XineramaScreenInfo* XineramaQueryScreensFunc(Display*, int*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
#else /* SOLARIS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
typedef Status XineramaGetInfoFunc(Display* display, int screen_number,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
         XRectangle* framebuffer_rects, unsigned char* framebuffer_hints,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
         int* num_framebuffers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
Bool usingXinerama = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
XRectangle fbrects[MAXFRAMEBUFFERS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    x11GraphicsConfigIDs.aData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    x11GraphicsConfigIDs.bitsPerPixel = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
   152
    CHECK_NULL(x11GraphicsConfigIDs.aData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
   154
    CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    if (x11GraphicsConfigIDs.aData == NULL ||
53673
e04d39094915 8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents: 52719
diff changeset
   157
            x11GraphicsConfigIDs.bitsPerPixel == NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            JNU_ThrowNoSuchFieldError(env, "Can't find a field");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
#ifndef HEADLESS
2802
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2760
diff changeset
   165
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
/*
2802
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2760
diff changeset
   167
 * XIOErrorHandler
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 */
2802
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 2760
diff changeset
   169
static int xioerror_handler(Display *disp)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    if (awtLockInited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (errno == EPIPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        /*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", "I/O error"); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
static AwtGraphicsConfigDataPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
findWithTemplate(XVisualInfo *vinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                 long mask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    XVisualInfo *visualList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    XColor color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    AwtGraphicsConfigDataPtr defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    int visualsMatched, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    visualList = XGetVisualInfo(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                mask, vinfo, &visualsMatched);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    if (visualList) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        defaultConfig = ZALLOC(_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        for (i = 0; i < visualsMatched; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            memcpy(&defaultConfig->awt_visInfo, &visualList[i], sizeof(XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            defaultConfig->awt_depth = visualList[i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            /* we can't use awtJNI_CreateColorData here, because it'll pull,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
               SystemColor, which in turn will cause toolkit to be reinitialized */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            if (awtCreateX11Colormap(defaultConfig)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                /* Allocate white and black pixels for this visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                color.flags = DoRed | DoGreen | DoBlue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                color.red = color.green = color.blue = 0x0000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                x11Screens[visualList[i].screen].blackpixel = color.pixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                color.flags = DoRed | DoGreen | DoBlue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                color.red = color.green = color.blue = 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                x11Screens[visualList[i].screen].whitepixel = color.pixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                XFree(visualList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        XFree(visualList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        free((void *)defaultConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
/* default config is based on X11 screen.  All Xinerama screens of that X11
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
   screen will have the same default config */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/* Need more notes about which fields of the structure are based on the X
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
   screen, and which are based on the Xinerama screen */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
static AwtGraphicsConfigDataPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
makeDefaultConfig(JNIEnv *env, int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    AwtGraphicsConfigDataPtr defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    int xinawareScreen = 0;
8745
6b9548badbaf 7022280: Parfait reports Format string argument mismatch in /jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
bae
parents: 5506
diff changeset
   230
    VisualID forcedVisualID = 0, defaultVisualID;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    char *forcedVisualStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    XVisualInfo vinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    long mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    xinawareScreen = usingXinerama ? 0 : screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    defaultVisualID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        XVisualIDFromVisual(DefaultVisual(awt_display, xinawareScreen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    memset(&vinfo, 0, sizeof(XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    vinfo.screen = xinawareScreen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    if ((forcedVisualStr = getenv("FORCEDEFVIS"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        mask = VisualIDMask | VisualScreenMask;
8745
6b9548badbaf 7022280: Parfait reports Format string argument mismatch in /jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
bae
parents: 5506
diff changeset
   244
        if (sscanf(forcedVisualStr, "%lx", &forcedVisualID) > 0 &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            forcedVisualID > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            vinfo.visualid = forcedVisualID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            vinfo.visualid = defaultVisualID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        VisualID bestGLXVisualID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (glxRequested &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            (bestGLXVisualID = GLXGC_FindBestVisual(env, xinawareScreen)) > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            /* we've found the best visual for use with GLX, so use it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            vinfo.visualid = bestGLXVisualID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            mask = VisualIDMask | VisualScreenMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            /* otherwise, continue looking for the best X11 visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            vinfo.depth = 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            vinfo.class = TrueColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            mask = VisualDepthMask | VisualScreenMask | VisualClassMask;
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
    /* try the best, or forced visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    defaultConfig = findWithTemplate(&vinfo, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    if (defaultConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /* try the default visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    vinfo.visualid = defaultVisualID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    mask = VisualIDMask | VisualScreenMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    defaultConfig = findWithTemplate(&vinfo, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    if (defaultConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /* try any TrueColor */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    vinfo.class = TrueColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    mask = VisualScreenMask | VisualClassMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    defaultConfig = findWithTemplate(&vinfo, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    if (defaultConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    /* try 8-bit PseudoColor */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    vinfo.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    vinfo.class = PseudoColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    mask = VisualDepthMask | VisualScreenMask | VisualClassMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    defaultConfig = findWithTemplate(&vinfo, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    if (defaultConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /* try any 8-bit */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    vinfo.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    mask = VisualDepthMask | VisualScreenMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    defaultConfig = findWithTemplate(&vinfo, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    if (defaultConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /* we tried everything, give up */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    JNU_ThrowInternalError(env, "Can't find supported visual");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    XCloseDisplay(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    awt_display = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    int n8p=0, n12p=0, n8s=0, n8gs=0, n8sg=0, n1sg=0, nTrue=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    int nConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    XVisualInfo *pVI8p, *pVI12p, *pVI8s, *pVITrue, *pVI8gs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                *pVI8sg, *pVI1sg = NULL, viTmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    AwtGraphicsConfigDataPtr *graphicsConfigs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    AwtGraphicsConfigDataPtr defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    int ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    char errmsg[128];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    int xinawareScreen;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   326
    void* xrenderLibHandle = NULL;
2955
9327f093140c 6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents: 2807
diff changeset
   327
    XRenderFindVisualFormatFunc* xrenderFindVisualFormat = NULL;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   328
    int major_opcode, first_event, first_error;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    if (usingXinerama) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        xinawareScreen = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        xinawareScreen = screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    AWT_LOCK ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    viTmp.screen = xinawareScreen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    viTmp.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    viTmp.class = PseudoColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    viTmp.colormap_size = 256;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    pVI8p = XGetVisualInfo (awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                            VisualDepthMask | VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                            VisualColormapSizeMask | VisualScreenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                            &viTmp, &n8p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    viTmp.depth = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    viTmp.class = PseudoColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    viTmp.colormap_size = 4096;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    pVI12p = XGetVisualInfo (awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                             VisualDepthMask | VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                             VisualColormapSizeMask | VisualScreenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                             &viTmp, &n12p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    viTmp.class = TrueColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    pVITrue = XGetVisualInfo (awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                              VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                              VisualScreenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                              &viTmp, &nTrue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    viTmp.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    viTmp.class = StaticColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    pVI8s = XGetVisualInfo (awt_display, VisualDepthMask | VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                            VisualScreenMask, &viTmp, &n8s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    viTmp.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    viTmp.class = GrayScale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    viTmp.colormap_size = 256;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    pVI8gs = XGetVisualInfo (awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                             VisualDepthMask | VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                             VisualColormapSizeMask | VisualScreenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                             &viTmp, &n8gs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    viTmp.depth = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    viTmp.class = StaticGray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    viTmp.colormap_size = 256;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    pVI8sg = XGetVisualInfo (awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                             VisualDepthMask | VisualClassMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                             VisualColormapSizeMask | VisualScreenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                             &viTmp, &n8sg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
/* REMIND.. remove when we have support for the color classes below */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
/*     viTmp.depth = 1; */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
/*     viTmp.class = StaticGray; */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
/*     pVI1sg = XGetVisualInfo (awt_display, VisualDepthMask | VisualClassMask, */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
/*                              viTmp, &n1sg); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    nConfig = n8p + n12p + n8s + n8gs + n8sg  + n1sg + nTrue + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    graphicsConfigs = (AwtGraphicsConfigDataPtr *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        calloc(nConfig, sizeof(AwtGraphicsConfigDataPtr));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    if (graphicsConfigs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                  NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    if (screenDataPtr->defaultConfig == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
         * After a display change event, the default config field will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
         * been reset, so we need to recreate the default config here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        screenDataPtr->defaultConfig = makeDefaultConfig(env, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    defaultConfig = screenDataPtr->defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    graphicsConfigs[0] = defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    nConfig = 1; /* reserve index 0 for default config */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   411
    // Only use the RENDER extension if it is available on the X server
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   412
    if (XQueryExtension(awt_display, "RENDER",
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   413
                        &major_opcode, &first_event, &first_error))
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   414
    {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   415
        xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   416
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   417
#ifdef MACOSX
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   418
#define XRENDER_LIB "/usr/X11/lib/libXrender.dylib"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   419
#else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   420
#define XRENDER_LIB "libXrender.so"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   421
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   422
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   423
        if (xrenderLibHandle == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   424
            xrenderLibHandle = dlopen(XRENDER_LIB,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   425
                                      RTLD_LAZY | RTLD_GLOBAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   426
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   427
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   428
#ifndef __linux__ /* SOLARIS */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   429
        if (xrenderLibHandle == NULL) {
41107
567f832618d7 8165161: Solaris: /usr/ccs /opt/sfw and /opt/csw are dead, references should be expunged
alanbur
parents: 40996
diff changeset
   430
            xrenderLibHandle = dlopen("/usr/lib/libXrender.so.1",
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   431
                                      RTLD_LAZY | RTLD_GLOBAL);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   432
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   433
#endif
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   434
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   435
        if (xrenderLibHandle != NULL) {
2955
9327f093140c 6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents: 2807
diff changeset
   436
            xrenderFindVisualFormat =
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   437
                (XRenderFindVisualFormatFunc*)dlsym(xrenderLibHandle,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   438
                                                    "XRenderFindVisualFormat");
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   439
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   440
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   441
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    for (i = 0; i < nTrue; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        if (XVisualIDFromVisual(pVITrue[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            pVITrue[i].depth == 12) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            /* Skip the non-supported 12-bit TrueColor visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        graphicsConfigs [ind]->awt_depth = pVITrue [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                sizeof (XVisualInfo));
2955
9327f093140c 6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents: 2807
diff changeset
   455
       if (xrenderFindVisualFormat != NULL) {
9327f093140c 6851515: awt_p.h incorporates a chunk of the XRender header
andrew
parents: 2807
diff changeset
   456
            XRenderPictFormat *format = xrenderFindVisualFormat (awt_display,
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   457
                    pVITrue [i].visual);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   458
            if (format &&
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   459
                format->type == PictTypeDirect &&
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   460
                format->direct.alphaMask)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   461
            {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   462
                graphicsConfigs [ind]->isTranslucencySupported = 1;
2807
db01a7f6d657 6839999: Cumulative fix for 6762511 and 6838003
anthony
parents: 2802
diff changeset
   463
                memcpy(&graphicsConfigs [ind]->renderPictFormat, format,
db01a7f6d657 6839999: Cumulative fix for 6762511 and 6838003
anthony
parents: 2802
diff changeset
   464
                        sizeof(*format));
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   465
            }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   466
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   467
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   468
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   469
    if (xrenderLibHandle != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   470
        dlclose(xrenderLibHandle);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
   471
        xrenderLibHandle = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    for (i = 0; i < n8p; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        if (XVisualIDFromVisual(pVI8p[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        graphicsConfigs [ind]->awt_depth = pVI8p [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8p [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    for (i = 0; i < n12p; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        if (XVisualIDFromVisual(pVI12p[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        graphicsConfigs [ind]->awt_depth = pVI12p [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI12p [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    for (i = 0; i < n8s; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (XVisualIDFromVisual(pVI8s[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        graphicsConfigs [ind]->awt_depth = pVI8s [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8s [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    for (i = 0; i < n8gs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        if (XVisualIDFromVisual(pVI8gs[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        graphicsConfigs [ind]->awt_depth = pVI8gs [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8gs [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    for (i = 0; i < n8sg; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        if (XVisualIDFromVisual(pVI8sg[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        graphicsConfigs [ind]->awt_depth = pVI8sg [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8sg [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    for (i = 0; i < n1sg; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        if (XVisualIDFromVisual(pVI1sg[i].visual) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            ind = nConfig++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        graphicsConfigs [ind]->awt_depth = pVI1sg [i].depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI1sg [i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                sizeof (XVisualInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    if (n8p != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
       XFree (pVI8p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    if (n12p != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
       XFree (pVI12p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    if (n8s != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
       XFree (pVI8s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    if (n8gs != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
       XFree (pVI8gs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    if (n8sg != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
       XFree (pVI8sg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    if (n1sg != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
       XFree (pVI1sg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    screenDataPtr->numConfigs = nConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    screenDataPtr->configs = graphicsConfigs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    AWT_UNLOCK ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
#ifndef HEADLESS
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   572
#if defined(__linux__) || defined(MACOSX)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
static void xinerama_init_linux()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
{
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   575
    void* libHandle = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    int32_t locNumScr = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    XineramaScreenInfo *xinInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    char* XineramaQueryScreensName = "XineramaQueryScreens";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    XineramaQueryScreensFunc* XineramaQueryScreens = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    /* load library */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   582
    libHandle = dlopen(VERSIONED_JNI_LIB_NAME("Xinerama", "1"),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   583
                       RTLD_LAZY | RTLD_GLOBAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   584
    if (libHandle == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   585
        libHandle = dlopen(JNI_LIB_NAME("Xinerama"), RTLD_LAZY | RTLD_GLOBAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   586
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   587
    if (libHandle != NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        XineramaQueryScreens = (XineramaQueryScreensFunc*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            dlsym(libHandle, XineramaQueryScreensName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        if (XineramaQueryScreens != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            DTRACE_PRINTLN("calling XineramaQueryScreens func on Linux");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            xinInfo = (*XineramaQueryScreens)(awt_display, &locNumScr);
556
0aaf0da3931d 6604044: java crashes talking to second X screen
tdv
parents: 552
diff changeset
   594
            if (xinInfo != NULL && locNumScr > XScreenCount(awt_display)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                int32_t idx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                DTRACE_PRINTLN("Enabling Xinerama support");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                usingXinerama = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                /* set global number of screens */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                DTRACE_PRINTLN1(" num screens = %i\n", locNumScr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                awt_numScreens = locNumScr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                /* stuff values into fbrects */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                for (idx = 0; idx < awt_numScreens; idx++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                    DASSERT(xinInfo[idx].screen_number == idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                    fbrects[idx].width = xinInfo[idx].width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                    fbrects[idx].height = xinInfo[idx].height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                    fbrects[idx].x = xinInfo[idx].x_org;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                    fbrects[idx].y = xinInfo[idx].y_org;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                DTRACE_PRINTLN("calling XineramaQueryScreens didn't work");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            DTRACE_PRINTLN("couldn't load XineramaQueryScreens symbol");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        dlclose(libHandle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
#endif
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   623
#if !defined(__linux__) && !defined(MACOSX) /* Solaris */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
static void xinerama_init_solaris()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
{
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   626
    void* libHandle = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    unsigned char fbhints[MAXFRAMEBUFFERS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    int32_t locNumScr = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /* load and run XineramaGetInfo */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    char* XineramaGetInfoName = "XineramaGetInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    XineramaGetInfoFunc* XineramaSolarisFunc = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    /* load library */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   634
    libHandle = dlopen(JNI_LIB_NAME("Xext"), RTLD_LAZY | RTLD_GLOBAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   635
    if (libHandle != NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        if (XineramaSolarisFunc != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            DTRACE_PRINTLN("calling XineramaGetInfo func on Solaris");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            if ((*XineramaSolarisFunc)(awt_display, 0, &fbrects[0],
556
0aaf0da3931d 6604044: java crashes talking to second X screen
tdv
parents: 552
diff changeset
   640
                                       &fbhints[0], &locNumScr) != 0 &&
0aaf0da3931d 6604044: java crashes talking to second X screen
tdv
parents: 552
diff changeset
   641
                locNumScr > XScreenCount(awt_display))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                DTRACE_PRINTLN("Enabling Xinerama support");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                usingXinerama = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                /* set global number of screens */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                DTRACE_PRINTLN1(" num screens = %i\n", locNumScr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                awt_numScreens = locNumScr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                DTRACE_PRINTLN("calling XineramaGetInfo didn't work");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            DTRACE_PRINTLN("couldn't load XineramaGetInfo symbol");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        dlclose(libHandle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
 * Checks if Xinerama is running and perform Xinerama-related
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
 * platform dependent initialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
static void xineramaInit(void) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    char* XinExtName = "XINERAMA";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    int32_t major_opcode, first_event, first_error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    Bool gotXinExt = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    gotXinExt = XQueryExtension(awt_display, XinExtName, &major_opcode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                                &first_event, &first_error);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    if (!gotXinExt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        DTRACE_PRINTLN("Xinerama extension is not available");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    DTRACE_PRINTLN("Xinerama extension is available");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   679
#if defined(__linux__) || defined(MACOSX)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    xinerama_init_linux();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
#else /* Solaris */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    xinerama_init_solaris();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   683
#endif /* __linux__ || MACOSX */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
Display *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
awt_init_Display(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    jclass klass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    Display *dpy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    char errmsg[128];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
#ifdef NETSCAPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    sigset_t alarm_set, oldset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    if (awt_display) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        return awt_display;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
#ifdef NETSCAPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    /* Disable interrupts during XtOpenDisplay to avoid bugs in unix os select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
       code: some unix systems don't implement SA_RESTART properly and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
       because of this, select returns with EINTR. Most implementations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
       gethostbyname don't cope with EINTR properly and as a result we get
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
       stuck (forever) in the gethostbyname code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    sigemptyset(&alarm_set);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    sigaddset(&alarm_set, SIGALRM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    sigprocmask(SIG_BLOCK, &alarm_set, &oldset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    /* Load AWT lock-related methods in SunToolkit */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    klass = (*env)->FindClass(env, "sun/awt/SunToolkit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    if (klass == NULL) return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    GET_STATIC_METHOD(klass, awtLockMID, "awtLock", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    GET_STATIC_METHOD(klass, awtUnlockMID, "awtUnlock", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    GET_STATIC_METHOD(klass, awtWaitMID, "awtLockWait", "(J)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    GET_STATIC_METHOD(klass, awtNotifyMID, "awtLockNotify", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    GET_STATIC_METHOD(klass, awtNotifyAllMID, "awtLockNotifyAll", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    tkClass = (*env)->NewGlobalRef(env, klass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    awtLockInited = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    if (getenv("_AWT_IGNORE_XKB") != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        strlen(getenv("_AWT_IGNORE_XKB")) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        if (XkbIgnoreExtension(True)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            printf("Ignoring XKB.\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    dpy = awt_display = XOpenDisplay(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
#ifdef NETSCAPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    sigprocmask(SIG_SETMASK, &oldset, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    if (!dpy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        jio_snprintf(errmsg,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                     sizeof(errmsg),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                     "Can't connect to X11 window server using '%s' as the value of the DISPLAY variable.",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                     (getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY"));
14160
249b30c4dea8 6818083: When DISPLAY is bad, InternalError thrown, not AWTError
anthony
parents: 12047
diff changeset
   741
        JNU_ThrowByName(env, "java/awt/AWTError", errmsg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    XSetIOErrorHandler(xioerror_handler);
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 14160
diff changeset
   746
    JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "init", "(J)V",
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 14160
diff changeset
   747
        ptr_to_jlong(awt_display));
28080
4baf6faff689 8064698: [parfait] JNI exception pending in jdk/src/java/desktop/unix/native: libawt_xawt/awt/, common/awt
azvegint
parents: 26751
diff changeset
   748
    JNU_CHECK_EXCEPTION_RETURN(env, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    /* set awt_numScreens, and whether or not we're using Xinerama */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    xineramaInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    if (!usingXinerama) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        awt_numScreens =  XScreenCount(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    DTRACE_PRINTLN1("allocating %i screens\n", awt_numScreens);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    /* Allocate screen data structure array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    x11Screens = calloc(awt_numScreens, sizeof(AwtScreenData));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    if (x11Screens == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                                  NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    for (i = 0; i < awt_numScreens; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if (usingXinerama) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            /* All Xinerama screens use the same X11 root for now */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            x11Screens[i].root = RootWindow(awt_display, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            x11Screens[i].root = RootWindow(awt_display, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        x11Screens[i].defaultConfig = makeDefaultConfig(env, i);
28080
4baf6faff689 8064698: [parfait] JNI exception pending in jdk/src/java/desktop/unix/native: libawt_xawt/awt/, common/awt
azvegint
parents: 26751
diff changeset
   775
        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    return dpy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
 * Method:    getDefaultScreenNum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    return DefaultScreen(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
static void ensureConfigsInited(JNIEnv* env, int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
   if (x11Screens[screen].numConfigs == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
       if (env == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
           env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
       getAllConfigs (env, screen, &(x11Screens[screen]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
void* getDefaultConfig(int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
AwtGraphicsConfigDataPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
getDefaultConfig(int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    ensureConfigsInited(NULL, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    return x11Screens[screen].defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
AwtScreenDataPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
getScreenData(int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    return &(x11Screens[screen]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
 * Method:    initDisplay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
Java_sun_awt_X11GraphicsEnvironment_initDisplay(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                                                jboolean glxReq)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    glxRequested = glxReq;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    (void) awt_init_Display(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
 * Method:    initGLX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
Java_sun_awt_X11GraphicsEnvironment_initGLX(JNIEnv *env, jclass x11ge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    jboolean glxAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    glxAvailable = GLXGC_IsGLXAvailable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    return glxAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
 * Method:    getNumScreens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
Java_sun_awt_X11GraphicsEnvironment_getNumScreens(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    return awt_numScreens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
 * Method:    getDisplay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
 * Signature: ()J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
Java_sun_awt_X11GraphicsDevice_getDisplay(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    return ptr_to_jlong(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
static jint canUseShmExt = UNSET_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
static jint canUseShmExtPixmaps = UNSET_MITSHM;
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   896
static jboolean xshmAttachFailed = JNI_FALSE;
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   897
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   898
int XShmAttachXErrHandler(Display *display, XErrorEvent *xerr) {
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   899
    if (xerr->minor_code == X_ShmAttach) {
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   900
        xshmAttachFailed = JNI_TRUE;
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   901
    }
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   902
    return 0;
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   903
}
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   904
jboolean isXShmAttachFailed() {
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   905
    return xshmAttachFailed;
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   906
}
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   907
void resetXShmAttachFailed() {
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   908
    xshmAttachFailed = JNI_FALSE;
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   909
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
18184
75811cab0180 8001034: Memory management improvements
bae
parents: 14160
diff changeset
   911
extern int mitShmPermissionMask;
75811cab0180 8001034: Memory management improvements
bae
parents: 14160
diff changeset
   912
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    XShmSegmentInfo shminfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    int XShmMajor, XShmMinor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    int a, b, c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    if (canUseShmExt != UNSET_MITSHM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        *shmExt = canUseShmExt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        *shmPixmaps = canUseShmExtPixmaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    *shmExt = canUseShmExt = CANT_USE_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    *shmPixmaps = canUseShmExtPixmaps = CANT_USE_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
19006
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 18295
diff changeset
   929
    if (awt_display == (Display *)NULL) {
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 18295
diff changeset
   930
        AWT_NOFLUSH_UNLOCK();
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 18295
diff changeset
   931
        return;
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 18295
diff changeset
   932
    }
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 18295
diff changeset
   933
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * XShmQueryExtension returns False in remote server case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * Unfortunately it also returns True in ssh case, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * we need to test that we can actually do XShmAttach.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    if (XShmQueryExtension(awt_display)) {
18184
75811cab0180 8001034: Memory management improvements
bae
parents: 14160
diff changeset
   940
        shminfo.shmid = shmget(IPC_PRIVATE, 0x10000,
75811cab0180 8001034: Memory management improvements
bae
parents: 14160
diff changeset
   941
                               IPC_CREAT|mitShmPermissionMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        if (shminfo.shmid < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                           "TryInitMITShm: shmget has failed: %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                           strerror(errno));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        if (shminfo.shmaddr == ((char *) -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            shmctl(shminfo.shmid, IPC_RMID, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                           "TryInitMITShm: shmat has failed: %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                           strerror(errno));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        shminfo.readOnly = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   960
        resetXShmAttachFailed();
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   961
        /**
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   962
         * The J2DXErrHandler handler will set xshmAttachFailed
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   963
         * to JNI_TRUE if any Shm error has occured.
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   964
         */
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   965
        EXEC_WITH_XERROR_HANDLER(XShmAttachXErrHandler,
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   966
                                 XShmAttach(awt_display, &shminfo));
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   967
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
         * Get rid of the id now to reduce chances of leaking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
         * system resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        shmctl(shminfo.shmid, IPC_RMID, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 19006
diff changeset
   974
        if (isXShmAttachFailed() == JNI_FALSE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            canUseShmExt = CAN_USE_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            /* check if we can use shared pixmaps */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            XShmQueryVersion(awt_display, &XShmMajor, &XShmMinor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                             (Bool*)&canUseShmExtPixmaps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            canUseShmExtPixmaps = canUseShmExtPixmaps &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                (XShmPixmapFormat(awt_display) == ZPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
            XShmDetach(awt_display, &shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        shmdt(shminfo.shmaddr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        *shmExt = canUseShmExt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        *shmPixmaps = canUseShmExtPixmaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
 * Method:    checkShmExt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
Java_sun_awt_X11GraphicsEnvironment_checkShmExt(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    int shmExt = NOEXT_MITSHM, shmPixmaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    TryInitMITShm(env, &shmExt, &shmPixmaps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    return shmExt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
 * Method:    getDisplayString
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
 * Signature: ()Ljava/lang/String
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
Java_sun_awt_X11GraphicsEnvironment_getDisplayString
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
  (JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    return (jstring)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    return (*env)->NewStringUTF(env, DisplayString(awt_display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
 * Method:    getNumConfigs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
Java_sun_awt_X11GraphicsDevice_getNumConfigs(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
JNIEnv *env, jobject this, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    ensureConfigsInited(env, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    return x11Screens[screen].numConfigs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
 * Method:    getConfigVisualId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
 * Signature: (I)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
Java_sun_awt_X11GraphicsDevice_getConfigVisualId(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
JNIEnv *env, jobject this, jint index, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    int visNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    ensureConfigsInited(env, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    if (index == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.visualid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        return ((jint)x11Screens[screen].configs[index]->awt_visInfo.visualid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
 * Method:    getConfigDepth
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
 * Signature: (I)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
Java_sun_awt_X11GraphicsDevice_getConfigDepth(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
JNIEnv *env, jobject this, jint index, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    int visNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    ensureConfigsInited(env, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    if (index == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        return ((jint)x11Screens[screen].configs[index]->awt_visInfo.depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
 * Method:    getConfigColormap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
 * Signature: (I)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
Java_sun_awt_X11GraphicsDevice_getConfigColormap(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
JNIEnv *env, jobject this, jint index, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    int visNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    ensureConfigsInited(env, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    if (index == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        return ((jint)x11Screens[screen].defaultConfig->awt_cmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        return ((jint)x11Screens[screen].configs[index]->awt_cmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
 * Method:    resetNativeData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
Java_sun_awt_X11GraphicsDevice_resetNativeData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    (JNIEnv *env, jclass x11gd, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * Reset references to the various configs; the actual native config data
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * will be free'd later by the Disposer mechanism when the Java-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * X11GraphicsConfig objects go away.  By setting these values to NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * we ensure that they will be reinitialized as necessary (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * see the getNumConfigs() method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    if (x11Screens[screen].configs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        free(x11Screens[screen].configs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        x11Screens[screen].configs = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    x11Screens[screen].defaultConfig = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    x11Screens[screen].numConfigs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
 * Method:    dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
Java_sun_awt_X11GraphicsConfig_dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
    (JNIEnv *env, jclass x11gc, jlong configData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    AwtGraphicsConfigDataPtr aData = (AwtGraphicsConfigDataPtr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        jlong_to_ptr(configData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    if (aData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    if (aData->awt_cmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        XFreeColormap(awt_display, aData->awt_cmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    if (aData->awtImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        free(aData->awtImage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    if (aData->monoImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        XFree(aData->monoImage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    if (aData->monoPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        XFreePixmap(awt_display, aData->monoPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    if (aData->monoPixmapGC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        XFreeGC(awt_display, aData->monoPixmapGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    if (aData->color_data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
        free(aData->color_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    if (aData->glxInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
         * The native GLXGraphicsConfig data needs to be disposed separately
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
         * on the OGL queue flushing thread (should not be called while
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
         * the AWT lock is held).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        JNU_CallStaticMethodByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                                   "sun/java2d/opengl/OGLRenderQueue",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                                   "disposeGraphicsConfig", "(J)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                                   ptr_to_jlong(aData->glxInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    free(aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
 * Method:    getXResolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
JNIEXPORT jdouble JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
Java_sun_awt_X11GraphicsConfig_getXResolution(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
JNIEnv *env, jobject this, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    return (jdouble)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    return ((DisplayWidth(awt_display, screen) * 25.4) /
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
            DisplayWidthMM(awt_display, screen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
 * Method:    getYResolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
JNIEXPORT jdouble JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
Java_sun_awt_X11GraphicsConfig_getYResolution(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
JNIEnv *env, jobject this, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    return (jdouble)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    return ((DisplayHeight(awt_display, screen) * 25.4) /
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
            DisplayHeightMM(awt_display, screen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
 * Method:    getNumColors
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
Java_sun_awt_X11GraphicsConfig_getNumColors(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
    return (jint)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    AwtGraphicsConfigData *adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    adata = (AwtGraphicsConfigData *) JNU_GetLongFieldAsPtr(env, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                                              x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    return adata->awt_num_colors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
 * Method:    init
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
Java_sun_awt_X11GraphicsConfig_init(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
JNIEnv *env, jobject this, jint visualNum, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
    AwtGraphicsConfigData *adata = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    AwtScreenData asd = x11Screens[screen];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    int i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
    int depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
    XImage * tempImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
    /* If haven't gotten all of the configs yet, do it now. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
    if (asd.numConfigs == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        getAllConfigs (env, screen, &asd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
    /* Check the graphicsConfig for this visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
    for (i = 0; i < asd.numConfigs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
        AwtGraphicsConfigDataPtr agcPtr = asd.configs[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        if ((jint)agcPtr->awt_visInfo.visualid == visualNum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
           adata = agcPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
           break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
    /* If didn't find the visual, throw an exception... */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
    if (adata == (AwtGraphicsConfigData *) NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        JNU_ThrowIllegalArgumentException(env, "Unknown Visual Specified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
    /*  adata->awt_cmap initialization has been deferred to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     *  makeColorModel call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
    JNU_SetLongFieldFromPtr(env, this, x11GraphicsConfigIDs.aData, adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
    depth = adata->awt_visInfo.depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    tempImage = XCreateImage(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
                             adata->awt_visInfo.visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
                             depth, ZPixmap, 0, NULL, 1, 1, 32, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    adata->pixelStride = (tempImage->bits_per_pixel + 7) / 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    (*env)->SetIntField(env, this, x11GraphicsConfigIDs.bitsPerPixel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                        (jint)tempImage->bits_per_pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    XDestroyImage(tempImage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
#endif /* !HEADLESS */
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
 * Method:    makeColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
 * Signature: ()Ljava/awt/image/ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
Java_sun_awt_X11GraphicsConfig_makeColorModel(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
    AwtGraphicsConfigData *adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    jobject colorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
     * If awt is not locked yet, return null since the toolkit is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * initialized yet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    if (!awtLockInited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    AWT_LOCK ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
    adata = (AwtGraphicsConfigData *) JNU_GetLongFieldAsPtr(env, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
                                              x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
    /* If colormap entry of adata is NULL, need to create it now */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
    if (adata->awt_cmap == (Colormap) NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        awtJNI_CreateColorData (env, adata, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    /* Make Color Model object for this GraphicsConfiguration */
26348
da1711644b77 8046887: JNI exception pending in jdk/src/solaris/native/sun/awt: awt_DrawingSurface.c, awt_GraphicsEnv.c, awt_InputMethod.c, sun_awt_X11_GtkFileDialogPeer.c
serb
parents: 24130
diff changeset
  1335
    colorModel = (*env)->ExceptionCheck(env)
da1711644b77 8046887: JNI exception pending in jdk/src/solaris/native/sun/awt: awt_DrawingSurface.c, awt_GraphicsEnv.c, awt_InputMethod.c, sun_awt_X11_GtkFileDialogPeer.c
serb
parents: 24130
diff changeset
  1336
                 ? NULL : awtJNI_GetColorModel (env, adata);
da1711644b77 8046887: JNI exception pending in jdk/src/solaris/native/sun/awt: awt_DrawingSurface.c, awt_GraphicsEnv.c, awt_InputMethod.c, sun_awt_X11_GtkFileDialogPeer.c
serb
parents: 24130
diff changeset
  1337
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    AWT_UNLOCK ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    return colorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
 * Method:    getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
 * Signature: ()Ljava/awt/Rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
    jmethodID mid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    jobject bounds = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    AwtGraphicsConfigDataPtr adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    adata = (AwtGraphicsConfigDataPtr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
        JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    clazz = (*env)->FindClass(env, "java/awt/Rectangle");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  1365
    CHECK_NULL_RETURN(clazz, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
    mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
    if (mid != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
        if (usingXinerama) {
18135
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1369
            if (0 <= screen && screen < awt_numScreens) {
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1370
                bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x,
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1371
                                                            fbrects[screen].y,
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1372
                                                            fbrects[screen].width,
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1373
                                                            fbrects[screen].height);
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1374
            } else {
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1375
                jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1376
                if (exceptionClass != NULL) {
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1377
                    (*env)->ThrowNew(env, exceptionClass, "Illegal screen index");
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1378
                }
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1379
            }
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17679
diff changeset
  1380
        } else {
11083
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1381
            XWindowAttributes xwa;
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1382
            memset(&xwa, 0, sizeof(xwa));
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1383
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1384
            AWT_LOCK ();
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1385
            XGetWindowAttributes(awt_display,
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1386
                    RootWindow(awt_display, adata->awt_visInfo.screen),
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1387
                    &xwa);
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1388
            AWT_UNLOCK ();
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1389
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
            bounds = (*env)->NewObject(env, clazz, mid, 0, 0,
11083
34aa99149ff2 7045370: Java Statically Determines Display Size on Linux platforms
anthony
parents: 9035
diff changeset
  1391
                    xwa.width, xwa.height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
        if ((*env)->ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    return bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
 * Method:    createBackBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
 * Signature: (JI)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
Java_sun_awt_X11GraphicsConfig_createBackBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
    (JNIEnv *env, jobject this, jlong window, jint swapAction)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
    int32_t v1, v2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
    XdbeBackBuffer ret = (unsigned long) 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    Window w = (Window)window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
    if (!XdbeQueryExtension(awt_display, &v1, &v2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        JNU_ThrowByName(env, "java/lang/Exception",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
                        "Could not query double-buffer extension");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
        return (jlong)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
    ret = XdbeAllocateBackBufferName(awt_display, w,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                                     (XdbeSwapAction)swapAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
    return (jlong)ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
 * Method:    destroyBackBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
Java_sun_awt_X11GraphicsConfig_destroyBackBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
    (JNIEnv *env, jobject this, jlong backBuffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    XdbeDeallocateBackBufferName(awt_display, (XdbeBackBuffer)backBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
 * Class:     sun_awt_X11GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
 * Method:    swapBuffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
 * Signature: (JI)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
Java_sun_awt_X11GraphicsConfig_swapBuffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
    (JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
     jlong window, jint swapAction)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
    XdbeSwapInfo swapInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
    XdbeBeginIdiom(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    swapInfo.swap_window = (Window)window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    swapInfo.swap_action = (XdbeSwapAction)swapAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
    if (!XdbeSwapBuffers(awt_display, &swapInfo, 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        JNU_ThrowInternalError(env, "Could not swap buffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
    XdbeEndIdiom(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
/*
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1467
 * Class:     sun_awt_X11GraphicsConfig
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1468
 * Method:    isTranslucencyCapable
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1469
 * Signature: (J)V
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1470
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1471
JNIEXPORT jboolean JNICALL
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1472
Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1473
    (JNIEnv *env, jobject this, jlong configData)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1474
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1475
#ifdef HEADLESS
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1476
    return JNI_FALSE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1477
#else
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1478
    AwtGraphicsConfigDataPtr aData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(configData);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1479
    if (aData == NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1480
        return JNI_FALSE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1481
    }
28081
b20407c53c23 8064699: [parfait] JNI primitive type mismatch in jdk/src/java/desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
azvegint
parents: 28080
diff changeset
  1482
    return aData->isTranslucencySupported ? JNI_TRUE : JNI_FALSE;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1483
#endif
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1484
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1485
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 715
diff changeset
  1486
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
 * Method:    isDBESupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
Java_sun_awt_X11GraphicsDevice_isDBESupported(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
    int opcode = 0, firstEvent = 0, firstError = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
    jboolean ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    ret = (jboolean)XQueryExtension(awt_display, "DOUBLE-BUFFER",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
                                    &opcode, &firstEvent, &firstError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
 * Method:    getDoubleBufferVisuals
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
    jobject this, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
    jmethodID midAddVisual;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
    Window rootWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
    int i, n = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
    XdbeScreenVisualInfo* visScreenInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
    int xinawareScreen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
    if (usingXinerama) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
        xinawareScreen = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
        xinawareScreen = screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
    clazz = (*env)->GetObjectClass(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
    midAddVisual = (*env)->GetMethodID(env, clazz, "addDoubleBufferVisual",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
        "(I)V");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  1535
    CHECK_NULL(midAddVisual);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
    rootWindow = RootWindow(awt_display, xinawareScreen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    visScreenInfo = XdbeGetVisualInfo(awt_display, &rootWindow, &n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
    if (visScreenInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
        JNU_ThrowInternalError(env, "Could not get visual info");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
    for (i = 0; i < visScreenInfo->count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        XdbeVisualInfo* visInfo = visScreenInfo->visinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
        (*env)->CallVoidMethod(env, this, midAddVisual, (visInfo[i]).visual);
32123
92824eb030c5 8130507: closed/java/awt/font/JNICheck/JNICheck.sh test reports some warnings
psadhukhan
parents: 30486
diff changeset
  1548
        if ((*env)->ExceptionCheck(env)) {
92824eb030c5 8130507: closed/java/awt/font/JNICheck/JNICheck.sh test reports some warnings
psadhukhan
parents: 30486
diff changeset
  1549
            break;
92824eb030c5 8130507: closed/java/awt/font/JNICheck/JNICheck.sh test reports some warnings
psadhukhan
parents: 30486
diff changeset
  1550
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
 * Class:     sun_awt_X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
 * Method:    pRunningXinerama
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
    jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
#ifdef HEADLESS
28081
b20407c53c23 8064699: [parfait] JNI primitive type mismatch in jdk/src/java/desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
azvegint
parents: 28080
diff changeset
  1565
    return JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
#else
28081
b20407c53c23 8064699: [parfait] JNI primitive type mismatch in jdk/src/java/desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
azvegint
parents: 28080
diff changeset
  1567
    return usingXinerama ? JNI_TRUE : JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
 * Begin DisplayMode/FullScreen support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  1577
#ifndef NO_XRANDR
52658
2d18e5ed0f8d 8213944: Fix AIX build after the removal of Xrandr.h and add a configure check for it
simonis
parents: 52533
diff changeset
  1578
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
#define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
4265
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1580
#define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1582
typedef Status
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1583
    (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
typedef XRRScreenConfiguration*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
    (*XRRGetScreenInfoType)(Display *dpy, Drawable root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
typedef void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
    (*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
typedef short*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
    (*XRRConfigRatesType)(XRRScreenConfiguration *config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
                          int sizeID, int *nrates);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
typedef short
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    (*XRRConfigCurrentRateType)(XRRScreenConfiguration *config);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
typedef XRRScreenSize*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    (*XRRConfigSizesType)(XRRScreenConfiguration *config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
                          int *nsizes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
typedef SizeID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    (*XRRConfigCurrentConfigurationType)(XRRScreenConfiguration *config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
                                         Rotation *rotation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
typedef Status
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
    (*XRRSetScreenConfigAndRateType)(Display *dpy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
                                     XRRScreenConfiguration *config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
                                     Drawable draw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
                                     int size_index,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
                                     Rotation rotation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                                     short rate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                                     Time timestamp);
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  1607
typedef Rotation
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  1608
    (*XRRConfigRotationsType)(XRRScreenConfiguration *config,
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  1609
                              Rotation *current_rotation);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1611
typedef XRRScreenResources* (*XRRGetScreenResourcesType)(Display *dpy,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1612
                                                                 Window window);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1613
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1614
typedef void (*XRRFreeScreenResourcesType)(XRRScreenResources *resources);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1615
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1616
typedef XRROutputInfo * (*XRRGetOutputInfoType)(Display *dpy,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1617
                                XRRScreenResources *resources, RROutput output);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1618
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1619
typedef void (*XRRFreeOutputInfoType)(XRROutputInfo *outputInfo);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1620
41793
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1621
typedef XRRCrtcInfo* (*XRRGetCrtcInfoType)(Display *dpy,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1622
                                    XRRScreenResources *resources, RRCrtc crtc);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1623
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1624
typedef void (*XRRFreeCrtcInfoType)(XRRCrtcInfo *crtcInfo);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1625
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1626
static XRRQueryVersionType               awt_XRRQueryVersion;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
static XRRGetScreenInfoType              awt_XRRGetScreenInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
static XRRFreeScreenConfigInfoType       awt_XRRFreeScreenConfigInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
static XRRConfigRatesType                awt_XRRConfigRates;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
static XRRConfigCurrentRateType          awt_XRRConfigCurrentRate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
static XRRConfigSizesType                awt_XRRConfigSizes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
static XRRConfigCurrentConfigurationType awt_XRRConfigCurrentConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
static XRRSetScreenConfigAndRateType     awt_XRRSetScreenConfigAndRate;
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  1634
static XRRConfigRotationsType            awt_XRRConfigRotations;
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1635
static XRRGetScreenResourcesType         awt_XRRGetScreenResources;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1636
static XRRFreeScreenResourcesType        awt_XRRFreeScreenResources;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1637
static XRRGetOutputInfoType              awt_XRRGetOutputInfo;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1638
static XRRFreeOutputInfoType             awt_XRRFreeOutputInfo;
41793
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1639
static XRRGetCrtcInfoType                awt_XRRGetCrtcInfo;
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1640
static XRRFreeCrtcInfoType               awt_XRRFreeCrtcInfo;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
#define LOAD_XRANDR_FUNC(f) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
        awt_##f = (f##Type)dlsym(pLibRandR, #f); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
        if (awt_##f == NULL) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
            J2dRlsTraceLn1(J2D_TRACE_ERROR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
                           "X11GD_InitXrandrFuncs: Could not load %s", #f); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
            dlclose(pLibRandR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
            return JNI_FALSE; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
X11GD_InitXrandrFuncs(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
{
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1656
    int rr_maj_ver = 0, rr_min_ver = 0;
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1657
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
  1658
    void *pLibRandR = dlopen(VERSIONED_JNI_LIB_NAME("Xrandr", "2"),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
  1659
                             RTLD_LAZY | RTLD_LOCAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
  1660
    if (pLibRandR == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
  1661
        pLibRandR = dlopen(JNI_LIB_NAME("Xrandr"), RTLD_LAZY | RTLD_LOCAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
  1662
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
    if (pLibRandR == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
                      "X11GD_InitXrandrFuncs: Could not open libXrandr.so.2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1669
    LOAD_XRANDR_FUNC(XRRQueryVersion);
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1670
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1671
    if (!(*awt_XRRQueryVersion)(awt_display, &rr_maj_ver, &rr_min_ver)) {
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1672
        J2dRlsTraceLn(J2D_TRACE_ERROR,
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1673
                      "X11GD_InitXrandrFuncs: XRRQueryVersion returned an error status");
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1674
        dlclose(pLibRandR);
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1675
        return JNI_FALSE;
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1676
    }
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1677
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1678
    if (usingXinerama) {
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1679
        /*
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1680
         * We can proceed as long as this is RANDR 1.2 or above.
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1681
         * As of Xorg server 1.3 onwards the Xinerama backend may actually be
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1682
         * a fake one provided by RANDR itself. See Java bug 6636469 for info.
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1683
         */
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1684
        if (!(rr_maj_ver > 1 || (rr_maj_ver == 1 && rr_min_ver >= 2))) {
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1685
            J2dRlsTraceLn2(J2D_TRACE_INFO, "X11GD_InitXrandrFuncs: Can't use Xrandr. "
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1686
                           "Xinerama is active and Xrandr version is %d.%d",
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1687
                           rr_maj_ver, rr_min_ver);
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1688
            dlclose(pLibRandR);
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1689
            return JNI_FALSE;
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1690
        }
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1691
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1692
        /*
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1693
         * REMIND: Fullscreen mode doesn't work quite right with multi-monitor
30486
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1694
         * setups and RANDR 1.2.
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1695
         */
30486
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1696
        if ((rr_maj_ver == 1 && rr_min_ver <= 2) && awt_numScreens > 1) {
552
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1697
            J2dRlsTraceLn(J2D_TRACE_INFO, "X11GD_InitXrandrFuncs: Can't use Xrandr. "
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1698
                          "Multiple screens in use");
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1699
            dlclose(pLibRandR);
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1700
            return JNI_FALSE;
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1701
        }
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1702
    }
7213834c854f 6636469: Java Fullscreen Exclusive Mode not working with Xorg server 1.3.0 and above
tdv
parents: 2
diff changeset
  1703
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
    LOAD_XRANDR_FUNC(XRRGetScreenInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    LOAD_XRANDR_FUNC(XRRFreeScreenConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    LOAD_XRANDR_FUNC(XRRConfigRates);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
    LOAD_XRANDR_FUNC(XRRConfigCurrentRate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
    LOAD_XRANDR_FUNC(XRRConfigSizes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
    LOAD_XRANDR_FUNC(XRRConfigCurrentConfiguration);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
    LOAD_XRANDR_FUNC(XRRSetScreenConfigAndRate);
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  1711
    LOAD_XRANDR_FUNC(XRRConfigRotations);
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1712
    LOAD_XRANDR_FUNC(XRRGetScreenResources);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1713
    LOAD_XRANDR_FUNC(XRRFreeScreenResources);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1714
    LOAD_XRANDR_FUNC(XRRGetOutputInfo);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1715
    LOAD_XRANDR_FUNC(XRRFreeOutputInfo);
41793
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1716
    LOAD_XRANDR_FUNC(XRRGetCrtcInfo);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1717
    LOAD_XRANDR_FUNC(XRRFreeCrtcInfo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
static jobject
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
X11GD_CreateDisplayMode(JNIEnv *env, jint width, jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
                        jint bitDepth, jint refreshRate)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
    jclass displayModeClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    jmethodID cid;
4265
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1728
    jint validRefreshRate = refreshRate;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  1731
    CHECK_NULL_RETURN(displayModeClass, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
    if (JNU_IsNull(env, displayModeClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
        JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
                               "Could not get display mode class");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    cid = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  1739
    CHECK_NULL_RETURN(cid, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
    if (cid == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
        JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
                               "Could not get display mode constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
4265
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1746
    // early versions of xrandr may report "empty" rates (6880694)
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1747
    if (validRefreshRate <= 0) {
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1748
        validRefreshRate = REFRESH_RATE_UNKNOWN;
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1749
    }
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1750
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
    return (*env)->NewObject(env, displayModeClass, cid,
4265
8950a3d33a86 6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
dcherepanov
parents: 2955
diff changeset
  1752
                             width, height, bitDepth, validRefreshRate);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
X11GD_AddDisplayMode(JNIEnv *env, jobject arrayList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
                     jint width, jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
                     jint bitDepth, jint refreshRate)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
    jobject displayMode = X11GD_CreateDisplayMode(env, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
                                                  bitDepth, refreshRate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
    if (!JNU_IsNull(env, displayMode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
        jclass arrayListClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
        jmethodID mid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
        arrayListClass = (*env)->GetObjectClass(env, arrayList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
        if (JNU_IsNull(env, arrayListClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
            JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
                                   "Could not get class java.util.ArrayList");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
        mid = (*env)->GetMethodID(env, arrayListClass, "add",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
                                  "(Ljava/lang/Object;)Z");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  1773
        CHECK_NULL(mid);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
        if (mid == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
            JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
                "Could not get method java.util.ArrayList.add()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
        (*env)->CallObjectMethod(env, arrayList, mid, displayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
        (*env)->DeleteLocalRef(env, displayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  1784
#endif /* !NO_XRANDR */
52658
2d18e5ed0f8d 8213944: Fix AIX build after the removal of Xrandr.h and add a configure check for it
simonis
parents: 52533
diff changeset
  1785
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
X11GD_SetFullscreenMode(Window win, jboolean enabled)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
    Atom wmState = XInternAtom(awt_display, "_NET_WM_STATE", False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
    Atom wmStateFs = XInternAtom(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
                                 "_NET_WM_STATE_FULLSCREEN", False);
30486
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1792
    XWindowAttributes attr;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
    XEvent event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
30486
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1795
    if (wmState == None || wmStateFs == None
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1796
            || !XGetWindowAttributes(awt_display, win, &attr)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
    memset(&event, 0, sizeof(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
    event.xclient.type = ClientMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
    event.xclient.message_type = wmState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
    event.xclient.display = awt_display;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
    event.xclient.window = win;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    event.xclient.format = 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
    event.xclient.data.l[0] = enabled ? 1 : 0; // 1==add, 0==remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
    event.xclient.data.l[1] = wmStateFs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
30486
95884a96b883 8051617: Fullscreen mode is not working properly on Xorg
azvegint
parents: 28081
diff changeset
  1809
    XSendEvent(awt_display, attr.root, False,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
               SubstructureRedirectMask | SubstructureNotifyMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
               &event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
 * Method:    initXrandrExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
Java_sun_awt_X11GraphicsDevice_initXrandrExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
    (JNIEnv *env, jclass x11gd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
{
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  1825
#if defined(HEADLESS) || defined(NO_XRANDR)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
    int opcode = 0, firstEvent = 0, firstError = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
    jboolean ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
    ret = (jboolean)XQueryExtension(awt_display, "RANDR",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
                                    &opcode, &firstEvent, &firstError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
    if (ret) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
        ret = X11GD_InitXrandrFuncs(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
 * Method:    getCurrentDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
 * Signature: (I)Ljava/awt/DisplayMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
    (JNIEnv* env, jclass x11gd, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
{
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  1852
#if defined(HEADLESS) || defined(NO_XRANDR)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
    XRRScreenConfiguration *config;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
    jobject displayMode = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
41793
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1860
    if (usingXinerama && XScreenCount(awt_display) > 0) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1861
        XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1862
                                                    RootWindow(awt_display, 0));
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1863
        if (res) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1864
            if (res->noutput > screen) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1865
                XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1866
                                                     res, res->outputs[screen]);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1867
                if (output_info) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1868
                    if (output_info->crtc) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1869
                        XRRCrtcInfo *crtc_info =
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1870
                                    awt_XRRGetCrtcInfo (awt_display, res,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1871
                                                        output_info->crtc);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1872
                        if (crtc_info) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1873
                            if (crtc_info->mode) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1874
                                int i;
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1875
                                for (i = 0; i < res->nmode; i++) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1876
                                    XRRModeInfo *mode = &res->modes[i];
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1877
                                    if (mode->id == crtc_info->mode) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1878
                                        float rate = 0;
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1879
                                        if (mode->hTotal && mode->vTotal) {
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1880
                                             rate = ((float)mode->dotClock /
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1881
                                                    ((float)mode->hTotal *
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1882
                                                    (float)mode->vTotal));
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1883
                                        }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1884
                                        displayMode = X11GD_CreateDisplayMode(
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1885
                                                           env,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1886
                                                           mode->width,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1887
                                                           mode->height,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1888
                                                           BIT_DEPTH_MULTI,
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1889
                                                           (int)(rate +.2));
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1890
                                        break;
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1891
                                    }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1892
                                }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1893
                            }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1894
                            awt_XRRFreeCrtcInfo(crtc_info);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1895
                        }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1896
                    }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1897
                    awt_XRRFreeOutputInfo(output_info);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1898
                }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1899
            }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1900
            awt_XRRFreeScreenResources(res);
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1901
        }
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1902
    } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
37553
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1904
        config = awt_XRRGetScreenInfo(awt_display,
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1905
                                      RootWindow(awt_display, screen));
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1906
        if (config != NULL) {
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1907
            Rotation rotation;
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1908
            short curRate;
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1909
            SizeID curSizeIndex;
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1910
            XRRScreenSize *sizes;
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1911
            int nsizes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
37553
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1913
            curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation);
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1914
            sizes = awt_XRRConfigSizes(config, &nsizes);
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1915
            curRate = awt_XRRConfigCurrentRate(config);
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1916
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1917
            if ((sizes != NULL) &&
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1918
                (curSizeIndex < nsizes))
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1919
            {
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1920
                XRRScreenSize curSize = sizes[curSizeIndex];
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1921
                displayMode = X11GD_CreateDisplayMode(env,
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1922
                                                      curSize.width,
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1923
                                                      curSize.height,
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1924
                                                      BIT_DEPTH_MULTI,
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1925
                                                      curRate);
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1926
            }
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1927
44868bf2423d 8151333: Some AWT functions may access an array outside of its bounds
ssadetsky
parents: 36869
diff changeset
  1928
            awt_XRRFreeScreenConfigInfo(config);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
    return displayMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
 * Method:    enumDisplayModes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
 * Signature: (ILjava/util/ArrayList;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
Java_sun_awt_X11GraphicsDevice_enumDisplayModes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
    (JNIEnv* env, jclass x11gd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
     jint screen, jobject arrayList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
{
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  1948
#if !defined(HEADLESS) && !defined(NO_XRANDR)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1952
    if (usingXinerama && XScreenCount(awt_display) > 0) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1953
        XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1954
                                                    RootWindow(awt_display, 0));
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1955
        if (res) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1956
           if (res->noutput > screen) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1957
                XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1958
                                                     res, res->outputs[screen]);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1959
                if (output_info) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1960
                    int i;
41793
7b9c71553d63 8167486: Device.getDisplayMode() doesn't report refresh rate on Linux in case of dual screen
ssadetsky
parents: 41107
diff changeset
  1961
                    for (i = 0; i < output_info->nmode; i++) {
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1962
                        RRMode m = output_info->modes[i];
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1963
                        int j;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1964
                        XRRModeInfo *mode;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1965
                        for (j = 0; j < res->nmode; j++) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1966
                            mode = &res->modes[j];
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1967
                            if (mode->id == m) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1968
                                 float rate = 0;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1969
                                 if (mode->hTotal && mode->vTotal) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1970
                                     rate = ((float)mode->dotClock /
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1971
                                                   ((float)mode->hTotal *
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1972
                                                          (float)mode->vTotal));
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1973
                                 }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1974
                                 X11GD_AddDisplayMode(env, arrayList,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1975
                                        mode->width, mode->height,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1976
                                              BIT_DEPTH_MULTI, (int)(rate +.2));
44150
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  1977
                                 if ((*env)->ExceptionCheck(env)) {
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  1978
                                     goto ret0;
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  1979
                                 }
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1980
                                 break;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1981
                            }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1982
                        }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1983
                    }
44150
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  1984
ret0:
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1985
                    awt_XRRFreeOutputInfo(output_info);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1986
                }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1987
            }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1988
            awt_XRRFreeScreenResources(res);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1989
        }
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1990
    } else {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1991
        XRRScreenConfiguration *config;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1993
        config = awt_XRRGetScreenInfo(awt_display,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1994
                                      RootWindow(awt_display, screen));
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1995
        if (config != NULL) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1996
            int nsizes, i, j;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1997
            XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  1999
            if (sizes != NULL) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2000
                for (i = 0; i < nsizes; i++) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2001
                    int nrates;
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2002
                    XRRScreenSize size = sizes[i];
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2003
                    short *rates = awt_XRRConfigRates(config, i, &nrates);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2004
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2005
                    for (j = 0; j < nrates; j++) {
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2006
                        X11GD_AddDisplayMode(env, arrayList,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2007
                                             size.width,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2008
                                             size.height,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2009
                                             BIT_DEPTH_MULTI,
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2010
                                             rates[j]);
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2011
                        if ((*env)->ExceptionCheck(env)) {
44150
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  2012
                            goto ret1;
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2013
                        }
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 21939
diff changeset
  2014
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
            }
44150
022f5ba40098 8175513: JNI exception pending in awt_GraphicsEnv.c:2021
vadim
parents: 41793
diff changeset
  2017
ret1:
39556
50963eeaefca 8022810: Cannot list all the available display modes on Ubuntu linux in case of two screen devices
ssadetsky
parents: 37553
diff changeset
  2018
            awt_XRRFreeScreenConfigInfo(config);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
 * Method:    configDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
 * Signature: (IIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
Java_sun_awt_X11GraphicsDevice_configDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
    (JNIEnv* env, jclass x11gd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
     jint screen, jint width, jint height, jint refreshRate)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
{
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  2036
#if !defined(HEADLESS) && !defined(NO_XRANDR)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
    jboolean success = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
    XRRScreenConfiguration *config;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
    Drawable root;
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  2040
    Rotation currentRotation = RR_Rotate_0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
    root = RootWindow(awt_display, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
    config = awt_XRRGetScreenInfo(awt_display, root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
    if (config != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
        jboolean foundConfig = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
        int chosenSizeIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
        short chosenRate = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
        int nsizes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
        XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes);
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  2052
        awt_XRRConfigRotations(config, &currentRotation);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
        if (sizes != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
            int i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
            /* find the size index that matches the requested dimensions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
            for (i = 0; i < nsizes; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
                XRRScreenSize size = sizes[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
                if ((size.width == width) && (size.height == height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
                    /* we've found our size index... */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
                    int nrates;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
                    short *rates = awt_XRRConfigRates(config, i, &nrates);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
                    /* now find rate that matches requested refresh rate */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
                    for (j = 0; j < nrates; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
                        if (rates[j] == refreshRate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
                            /* we've found our rate; break out of the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
                            chosenSizeIndex = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
                            chosenRate = rates[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
                            foundConfig = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
        if (foundConfig) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
            Status status =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
                awt_XRRSetScreenConfigAndRate(awt_display, config, root,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
                                              chosenSizeIndex,
4266
b105f9beb20f 6882909: Resetting a full-screen window to normal rotates screen to normal orientation.
dcherepanov
parents: 4265
diff changeset
  2086
                                              currentRotation,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
                                              chosenRate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
                                              CurrentTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
            /* issue XSync to ensure immediate mode change */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
            XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
            if (status == RRSetConfigSuccess) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
                success = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
        awt_XRRFreeScreenConfigInfo(config);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
    AWT_FLUSH_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
26348
da1711644b77 8046887: JNI exception pending in jdk/src/solaris/native/sun/awt: awt_DrawingSurface.c, awt_GraphicsEnv.c, awt_InputMethod.c, sun_awt_X11_GtkFileDialogPeer.c
serb
parents: 24130
diff changeset
  2103
    if (!success && !(*env)->ExceptionCheck(env)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
        JNU_ThrowInternalError(env, "Could not set display mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
 * Method:    enterFullScreenExclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
 * Signature: (J)V
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_X11GraphicsDevice_enterFullScreenExclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
    (JNIEnv* env, jclass x11gd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
     jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
    Window win = (Window)window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
    XSync(awt_display, False); /* ensures window is visible first */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
    X11GD_SetFullscreenMode(win, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
 * Class:     sun_awt_X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
 * Method:    exitFullScreenExclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
    (JNIEnv* env, jclass x11gd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
     jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
    Window win = (Window)window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
    X11GD_SetFullscreenMode(win, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
 * End DisplayMode/FullScreen support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
 */
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2151
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2152
static char *get_output_screen_name(JNIEnv *env, int screen) {
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  2153
#ifdef NO_XRANDR
52658
2d18e5ed0f8d 8213944: Fix AIX build after the removal of Xrandr.h and add a configure check for it
simonis
parents: 52533
diff changeset
  2154
    return NULL;
2d18e5ed0f8d 8213944: Fix AIX build after the removal of Xrandr.h and add a configure check for it
simonis
parents: 52533
diff changeset
  2155
#else
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2156
    if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2157
        return NULL;
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2158
    }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2159
    char *name = NULL;
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2160
    AWT_LOCK();
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2161
    int scr = 0, out = 0;
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2162
    if (usingXinerama && XScreenCount(awt_display) > 0) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2163
        out = screen;
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2164
    } else {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2165
        scr = screen;
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2166
    }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2167
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2168
    XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2169
                                                  RootWindow(awt_display, scr));
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2170
    if (res) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2171
       if (res->noutput > out) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2172
            XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2173
                                                        res, res->outputs[out]);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2174
            if (output_info) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2175
                if (output_info->name) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2176
                    name = strdup(output_info->name);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2177
                }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2178
                awt_XRRFreeOutputInfo(output_info);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2179
            }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2180
        }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2181
        awt_XRRFreeScreenResources(res);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2182
    }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2183
    AWT_UNLOCK();
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2184
    return name;
52719
91ae63450fa8 8214343: Handle the absence of Xrandr more generically
simonis
parents: 52658
diff changeset
  2185
#endif /* NO_XRANDR */
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2186
}
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2187
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2188
/*
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2189
 * Class:     sun_awt_X11GraphicsDevice
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2190
 * Method:    getNativeScaleFactor
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2191
 * Signature: (I)D
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2192
 */
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2193
JNIEXPORT jdouble JNICALL
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2194
Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2195
    (JNIEnv *env, jobject this, jint screen) {
40996
60d53c39c1b3 8163100: [hidpi] Linux: display-wise scaling factor issues
ssadetsky
parents: 39844
diff changeset
  2196
    // in case of Xinerama individual screen scales are not supported
60d53c39c1b3 8163100: [hidpi] Linux: display-wise scaling factor issues
ssadetsky
parents: 39844
diff changeset
  2197
    char *name = get_output_screen_name(env, usingXinerama ? 0 : screen);
39844
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2198
    double scale = getNativeScaleFactor(name);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2199
    if (name) {
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2200
        free(name);
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2201
    }
a3cc7e551a48 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account
ssadetsky
parents: 39556
diff changeset
  2202
    return scale;
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32123
diff changeset
  2203
}