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