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