1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include "jni_util.h"
27 #include "awt_p.h"
28 #include "awt.h"
29 #include "color.h"
30 #include <java_awt_DisplayMode.h>
31 #include <sun_awt_X11GraphicsEnvironment.h>
32 #include <sun_awt_X11GraphicsDevice.h>
33 #include <sun_awt_X11GraphicsConfig.h>
34 #ifndef HEADLESS
35 #include <X11/extensions/Xdbe.h>
36 #include <X11/XKBlib.h>
37 #include <X11/extensions/Xrandr.h>
38 #include "GLXGraphicsConfig.h"
39 #endif /* !HEADLESS */
40
41 #include <jni.h>
42 #include <jni_util.h>
43 #include <jvm.h>
44 #include <jvm_md.h>
45 #include <jlong.h>
46 #include "systemScale.h"
47 #include <stdlib.h>
48
49 #include "awt_GraphicsEnv.h"
50 #include "awt_util.h"
51 #include "gdefs.h"
52 #include <dlfcn.h>
53 #include "Trace.h"
54
55 #ifdef NETSCAPE
56 #include <signal.h>
57 extern int awt_init_xt;
1608 if (XineramaSolarisCenterFunc != NULL) {
1609 (XineramaSolarisCenterFunc)(awt_display, 0, &x, &y);
1610 point = JNU_NewObjectByName(env, "java/awt/Point","(II)V", x, y);
1611 DASSERT(point);
1612 } else {
1613 DTRACE_PRINTLN("unable to call XineramaSolarisCenterFunc: symbol is null");
1614 }
1615 AWT_FLUSH_UNLOCK();
1616 #endif /* __linux __ || MACOSX */
1617 #endif /* HEADLESS */
1618 return point;
1619 }
1620
1621
1622 /**
1623 * Begin DisplayMode/FullScreen support
1624 */
1625
1626 #ifndef HEADLESS
1627
1628 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
1629 #define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
1630
1631 typedef Status
1632 (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
1633 typedef XRRScreenConfiguration*
1634 (*XRRGetScreenInfoType)(Display *dpy, Drawable root);
1635 typedef void
1636 (*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config);
1637 typedef short*
1638 (*XRRConfigRatesType)(XRRScreenConfiguration *config,
1639 int sizeID, int *nrates);
1640 typedef short
1641 (*XRRConfigCurrentRateType)(XRRScreenConfiguration *config);
1642 typedef XRRScreenSize*
1643 (*XRRConfigSizesType)(XRRScreenConfiguration *config,
1644 int *nsizes);
1645 typedef SizeID
1646 (*XRRConfigCurrentConfigurationType)(XRRScreenConfiguration *config,
1647 Rotation *rotation);
1813 jmethodID mid;
1814 arrayListClass = (*env)->GetObjectClass(env, arrayList);
1815 if (JNU_IsNull(env, arrayListClass)) {
1816 JNU_ThrowInternalError(env,
1817 "Could not get class java.util.ArrayList");
1818 return;
1819 }
1820 mid = (*env)->GetMethodID(env, arrayListClass, "add",
1821 "(Ljava/lang/Object;)Z");
1822 CHECK_NULL(mid);
1823 if (mid == NULL) {
1824 JNU_ThrowInternalError(env,
1825 "Could not get method java.util.ArrayList.add()");
1826 return;
1827 }
1828 (*env)->CallObjectMethod(env, arrayList, mid, displayMode);
1829 (*env)->DeleteLocalRef(env, displayMode);
1830 }
1831 }
1832
1833 static void
1834 X11GD_SetFullscreenMode(Window win, jboolean enabled)
1835 {
1836 Atom wmState = XInternAtom(awt_display, "_NET_WM_STATE", False);
1837 Atom wmStateFs = XInternAtom(awt_display,
1838 "_NET_WM_STATE_FULLSCREEN", False);
1839 XWindowAttributes attr;
1840 XEvent event;
1841
1842 if (wmState == None || wmStateFs == None
1843 || !XGetWindowAttributes(awt_display, win, &attr)) {
1844 return;
1845 }
1846
1847 memset(&event, 0, sizeof(event));
1848 event.xclient.type = ClientMessage;
1849 event.xclient.message_type = wmState;
1850 event.xclient.display = awt_display;
1851 event.xclient.window = win;
1852 event.xclient.format = 32;
1853 event.xclient.data.l[0] = enabled ? 1 : 0; // 1==add, 0==remove
1854 event.xclient.data.l[1] = wmStateFs;
1855
1856 XSendEvent(awt_display, attr.root, False,
1857 SubstructureRedirectMask | SubstructureNotifyMask,
1858 &event);
1859 XSync(awt_display, False);
1860 }
1861 #endif /* !HEADLESS */
1862
1863 /*
1864 * Class: sun_awt_X11GraphicsDevice
1865 * Method: initXrandrExtension
1866 * Signature: ()Z
1867 */
1868 JNIEXPORT jboolean JNICALL
1869 Java_sun_awt_X11GraphicsDevice_initXrandrExtension
1870 (JNIEnv *env, jclass x11gd)
1871 {
1872 #ifdef HEADLESS
1873 return JNI_FALSE;
1874 #else
1875 int opcode = 0, firstEvent = 0, firstError = 0;
1876 jboolean ret;
1877
1878 AWT_LOCK();
1879 ret = (jboolean)XQueryExtension(awt_display, "RANDR",
1880 &opcode, &firstEvent, &firstError);
1881 if (ret) {
1882 ret = X11GD_InitXrandrFuncs(env);
1883 }
1884 AWT_FLUSH_UNLOCK();
1885
1886 return ret;
1887 #endif /* HEADLESS */
1888 }
1889
1890 /*
1891 * Class: sun_awt_X11GraphicsDevice
1892 * Method: getCurrentDisplayMode
1893 * Signature: (I)Ljava/awt/DisplayMode;
1894 */
1895 JNIEXPORT jobject JNICALL
1896 Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
1897 (JNIEnv* env, jclass x11gd, jint screen)
1898 {
1899 #ifdef HEADLESS
1900 return NULL;
1901 #else
1902 XRRScreenConfiguration *config;
1903 jobject displayMode = NULL;
1904
1905 AWT_LOCK();
1906
1907 if (usingXinerama && XScreenCount(awt_display) > 0) {
1908 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
1909 RootWindow(awt_display, 0));
1910 if (res) {
1911 if (res->noutput > screen) {
1912 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
1913 res, res->outputs[screen]);
1914 if (output_info) {
1915 if (output_info->crtc) {
1916 XRRCrtcInfo *crtc_info =
1917 awt_XRRGetCrtcInfo (awt_display, res,
1918 output_info->crtc);
1919 if (crtc_info) {
1975 awt_XRRFreeScreenConfigInfo(config);
1976 }
1977 }
1978
1979 AWT_FLUSH_UNLOCK();
1980
1981 return displayMode;
1982 #endif /* HEADLESS */
1983 }
1984
1985 /*
1986 * Class: sun_awt_X11GraphicsDevice
1987 * Method: enumDisplayModes
1988 * Signature: (ILjava/util/ArrayList;)V
1989 */
1990 JNIEXPORT void JNICALL
1991 Java_sun_awt_X11GraphicsDevice_enumDisplayModes
1992 (JNIEnv* env, jclass x11gd,
1993 jint screen, jobject arrayList)
1994 {
1995 #ifndef HEADLESS
1996
1997 AWT_LOCK();
1998
1999 if (usingXinerama && XScreenCount(awt_display) > 0) {
2000 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
2001 RootWindow(awt_display, 0));
2002 if (res) {
2003 if (res->noutput > screen) {
2004 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
2005 res, res->outputs[screen]);
2006 if (output_info) {
2007 int i;
2008 for (i = 0; i < output_info->nmode; i++) {
2009 RRMode m = output_info->modes[i];
2010 int j;
2011 XRRModeInfo *mode;
2012 for (j = 0; j < res->nmode; j++) {
2013 mode = &res->modes[j];
2014 if (mode->id == m) {
2015 float rate = 0;
2063 }
2064 ret1:
2065 awt_XRRFreeScreenConfigInfo(config);
2066 }
2067 }
2068
2069 AWT_FLUSH_UNLOCK();
2070 #endif /* !HEADLESS */
2071 }
2072
2073 /*
2074 * Class: sun_awt_X11GraphicsDevice
2075 * Method: configDisplayMode
2076 * Signature: (IIII)V
2077 */
2078 JNIEXPORT void JNICALL
2079 Java_sun_awt_X11GraphicsDevice_configDisplayMode
2080 (JNIEnv* env, jclass x11gd,
2081 jint screen, jint width, jint height, jint refreshRate)
2082 {
2083 #ifndef HEADLESS
2084 jboolean success = JNI_FALSE;
2085 XRRScreenConfiguration *config;
2086 Drawable root;
2087 Rotation currentRotation = RR_Rotate_0;
2088
2089 AWT_LOCK();
2090
2091 root = RootWindow(awt_display, screen);
2092 config = awt_XRRGetScreenInfo(awt_display, root);
2093 if (config != NULL) {
2094 jboolean foundConfig = JNI_FALSE;
2095 int chosenSizeIndex = -1;
2096 short chosenRate = -1;
2097 int nsizes;
2098 XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes);
2099 awt_XRRConfigRotations(config, ¤tRotation);
2100
2101 if (sizes != NULL) {
2102 int i, j;
2103
2180 */
2181 JNIEXPORT void JNICALL
2182 Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive
2183 (JNIEnv* env, jclass x11gd,
2184 jlong window)
2185 {
2186 #ifndef HEADLESS
2187 Window win = (Window)window;
2188
2189 AWT_LOCK();
2190 X11GD_SetFullscreenMode(win, JNI_FALSE);
2191 AWT_UNLOCK();
2192 #endif /* !HEADLESS */
2193 }
2194
2195 /**
2196 * End DisplayMode/FullScreen support
2197 */
2198
2199 static char *get_output_screen_name(JNIEnv *env, int screen) {
2200 if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) {
2201 return NULL;
2202 }
2203 char *name = NULL;
2204 AWT_LOCK();
2205 int scr = 0, out = 0;
2206 if (usingXinerama && XScreenCount(awt_display) > 0) {
2207 out = screen;
2208 } else {
2209 scr = screen;
2210 }
2211
2212 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
2213 RootWindow(awt_display, scr));
2214 if (res) {
2215 if (res->noutput > out) {
2216 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
2217 res, res->outputs[out]);
2218 if (output_info) {
2219 if (output_info->name) {
2220 name = strdup(output_info->name);
2221 }
2222 awt_XRRFreeOutputInfo(output_info);
2223 }
2224 }
2225 awt_XRRFreeScreenResources(res);
2226 }
2227 AWT_UNLOCK();
2228 return name;
2229 }
2230
2231 /*
2232 * Class: sun_awt_X11GraphicsDevice
2233 * Method: getNativeScaleFactor
2234 * Signature: (I)D
2235 */
2236 JNIEXPORT jdouble JNICALL
2237 Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
2238 (JNIEnv *env, jobject this, jint screen) {
2239 // in case of Xinerama individual screen scales are not supported
2240 char *name = get_output_screen_name(env, usingXinerama ? 0 : screen);
2241 double scale = getNativeScaleFactor(name);
2242 if (name) {
2243 free(name);
2244 }
2245 return scale;
2246 }
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include "jni_util.h"
27 #include "awt_p.h"
28 #include "awt.h"
29 #include "color.h"
30 #include <java_awt_DisplayMode.h>
31 #include <sun_awt_X11GraphicsEnvironment.h>
32 #include <sun_awt_X11GraphicsDevice.h>
33 #include <sun_awt_X11GraphicsConfig.h>
34 #ifndef HEADLESS
35 #include <X11/extensions/Xdbe.h>
36 #include <X11/XKBlib.h>
37 #ifndef _AIX
38 #include <X11/extensions/Xrandr.h>
39 #endif
40 #include "GLXGraphicsConfig.h"
41 #endif /* !HEADLESS */
42
43 #include <jni.h>
44 #include <jni_util.h>
45 #include <jvm.h>
46 #include <jvm_md.h>
47 #include <jlong.h>
48 #include "systemScale.h"
49 #include <stdlib.h>
50
51 #include "awt_GraphicsEnv.h"
52 #include "awt_util.h"
53 #include "gdefs.h"
54 #include <dlfcn.h>
55 #include "Trace.h"
56
57 #ifdef NETSCAPE
58 #include <signal.h>
59 extern int awt_init_xt;
1610 if (XineramaSolarisCenterFunc != NULL) {
1611 (XineramaSolarisCenterFunc)(awt_display, 0, &x, &y);
1612 point = JNU_NewObjectByName(env, "java/awt/Point","(II)V", x, y);
1613 DASSERT(point);
1614 } else {
1615 DTRACE_PRINTLN("unable to call XineramaSolarisCenterFunc: symbol is null");
1616 }
1617 AWT_FLUSH_UNLOCK();
1618 #endif /* __linux __ || MACOSX */
1619 #endif /* HEADLESS */
1620 return point;
1621 }
1622
1623
1624 /**
1625 * Begin DisplayMode/FullScreen support
1626 */
1627
1628 #ifndef HEADLESS
1629
1630 #ifndef _AIX
1631
1632 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
1633 #define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
1634
1635 typedef Status
1636 (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
1637 typedef XRRScreenConfiguration*
1638 (*XRRGetScreenInfoType)(Display *dpy, Drawable root);
1639 typedef void
1640 (*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config);
1641 typedef short*
1642 (*XRRConfigRatesType)(XRRScreenConfiguration *config,
1643 int sizeID, int *nrates);
1644 typedef short
1645 (*XRRConfigCurrentRateType)(XRRScreenConfiguration *config);
1646 typedef XRRScreenSize*
1647 (*XRRConfigSizesType)(XRRScreenConfiguration *config,
1648 int *nsizes);
1649 typedef SizeID
1650 (*XRRConfigCurrentConfigurationType)(XRRScreenConfiguration *config,
1651 Rotation *rotation);
1817 jmethodID mid;
1818 arrayListClass = (*env)->GetObjectClass(env, arrayList);
1819 if (JNU_IsNull(env, arrayListClass)) {
1820 JNU_ThrowInternalError(env,
1821 "Could not get class java.util.ArrayList");
1822 return;
1823 }
1824 mid = (*env)->GetMethodID(env, arrayListClass, "add",
1825 "(Ljava/lang/Object;)Z");
1826 CHECK_NULL(mid);
1827 if (mid == NULL) {
1828 JNU_ThrowInternalError(env,
1829 "Could not get method java.util.ArrayList.add()");
1830 return;
1831 }
1832 (*env)->CallObjectMethod(env, arrayList, mid, displayMode);
1833 (*env)->DeleteLocalRef(env, displayMode);
1834 }
1835 }
1836
1837 #endif /* !_AIX */
1838
1839 static void
1840 X11GD_SetFullscreenMode(Window win, jboolean enabled)
1841 {
1842 Atom wmState = XInternAtom(awt_display, "_NET_WM_STATE", False);
1843 Atom wmStateFs = XInternAtom(awt_display,
1844 "_NET_WM_STATE_FULLSCREEN", False);
1845 XWindowAttributes attr;
1846 XEvent event;
1847
1848 if (wmState == None || wmStateFs == None
1849 || !XGetWindowAttributes(awt_display, win, &attr)) {
1850 return;
1851 }
1852
1853 memset(&event, 0, sizeof(event));
1854 event.xclient.type = ClientMessage;
1855 event.xclient.message_type = wmState;
1856 event.xclient.display = awt_display;
1857 event.xclient.window = win;
1858 event.xclient.format = 32;
1859 event.xclient.data.l[0] = enabled ? 1 : 0; // 1==add, 0==remove
1860 event.xclient.data.l[1] = wmStateFs;
1861
1862 XSendEvent(awt_display, attr.root, False,
1863 SubstructureRedirectMask | SubstructureNotifyMask,
1864 &event);
1865 XSync(awt_display, False);
1866 }
1867 #endif /* !HEADLESS */
1868
1869 /*
1870 * Class: sun_awt_X11GraphicsDevice
1871 * Method: initXrandrExtension
1872 * Signature: ()Z
1873 */
1874 JNIEXPORT jboolean JNICALL
1875 Java_sun_awt_X11GraphicsDevice_initXrandrExtension
1876 (JNIEnv *env, jclass x11gd)
1877 {
1878 #if defined(HEADLESS) || defined(_AIX)
1879 return JNI_FALSE;
1880 #else
1881 int opcode = 0, firstEvent = 0, firstError = 0;
1882 jboolean ret;
1883
1884 AWT_LOCK();
1885 ret = (jboolean)XQueryExtension(awt_display, "RANDR",
1886 &opcode, &firstEvent, &firstError);
1887 if (ret) {
1888 ret = X11GD_InitXrandrFuncs(env);
1889 }
1890 AWT_FLUSH_UNLOCK();
1891
1892 return ret;
1893 #endif /* HEADLESS */
1894 }
1895
1896 /*
1897 * Class: sun_awt_X11GraphicsDevice
1898 * Method: getCurrentDisplayMode
1899 * Signature: (I)Ljava/awt/DisplayMode;
1900 */
1901 JNIEXPORT jobject JNICALL
1902 Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
1903 (JNIEnv* env, jclass x11gd, jint screen)
1904 {
1905 #if defined(HEADLESS) || defined(_AIX)
1906 return NULL;
1907 #else
1908 XRRScreenConfiguration *config;
1909 jobject displayMode = NULL;
1910
1911 AWT_LOCK();
1912
1913 if (usingXinerama && XScreenCount(awt_display) > 0) {
1914 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
1915 RootWindow(awt_display, 0));
1916 if (res) {
1917 if (res->noutput > screen) {
1918 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
1919 res, res->outputs[screen]);
1920 if (output_info) {
1921 if (output_info->crtc) {
1922 XRRCrtcInfo *crtc_info =
1923 awt_XRRGetCrtcInfo (awt_display, res,
1924 output_info->crtc);
1925 if (crtc_info) {
1981 awt_XRRFreeScreenConfigInfo(config);
1982 }
1983 }
1984
1985 AWT_FLUSH_UNLOCK();
1986
1987 return displayMode;
1988 #endif /* HEADLESS */
1989 }
1990
1991 /*
1992 * Class: sun_awt_X11GraphicsDevice
1993 * Method: enumDisplayModes
1994 * Signature: (ILjava/util/ArrayList;)V
1995 */
1996 JNIEXPORT void JNICALL
1997 Java_sun_awt_X11GraphicsDevice_enumDisplayModes
1998 (JNIEnv* env, jclass x11gd,
1999 jint screen, jobject arrayList)
2000 {
2001 #if !defined(HEADLESS) && !defined(_AIX)
2002
2003 AWT_LOCK();
2004
2005 if (usingXinerama && XScreenCount(awt_display) > 0) {
2006 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
2007 RootWindow(awt_display, 0));
2008 if (res) {
2009 if (res->noutput > screen) {
2010 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
2011 res, res->outputs[screen]);
2012 if (output_info) {
2013 int i;
2014 for (i = 0; i < output_info->nmode; i++) {
2015 RRMode m = output_info->modes[i];
2016 int j;
2017 XRRModeInfo *mode;
2018 for (j = 0; j < res->nmode; j++) {
2019 mode = &res->modes[j];
2020 if (mode->id == m) {
2021 float rate = 0;
2069 }
2070 ret1:
2071 awt_XRRFreeScreenConfigInfo(config);
2072 }
2073 }
2074
2075 AWT_FLUSH_UNLOCK();
2076 #endif /* !HEADLESS */
2077 }
2078
2079 /*
2080 * Class: sun_awt_X11GraphicsDevice
2081 * Method: configDisplayMode
2082 * Signature: (IIII)V
2083 */
2084 JNIEXPORT void JNICALL
2085 Java_sun_awt_X11GraphicsDevice_configDisplayMode
2086 (JNIEnv* env, jclass x11gd,
2087 jint screen, jint width, jint height, jint refreshRate)
2088 {
2089 #if !defined(HEADLESS) && !defined(_AIX)
2090 jboolean success = JNI_FALSE;
2091 XRRScreenConfiguration *config;
2092 Drawable root;
2093 Rotation currentRotation = RR_Rotate_0;
2094
2095 AWT_LOCK();
2096
2097 root = RootWindow(awt_display, screen);
2098 config = awt_XRRGetScreenInfo(awt_display, root);
2099 if (config != NULL) {
2100 jboolean foundConfig = JNI_FALSE;
2101 int chosenSizeIndex = -1;
2102 short chosenRate = -1;
2103 int nsizes;
2104 XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes);
2105 awt_XRRConfigRotations(config, ¤tRotation);
2106
2107 if (sizes != NULL) {
2108 int i, j;
2109
2186 */
2187 JNIEXPORT void JNICALL
2188 Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive
2189 (JNIEnv* env, jclass x11gd,
2190 jlong window)
2191 {
2192 #ifndef HEADLESS
2193 Window win = (Window)window;
2194
2195 AWT_LOCK();
2196 X11GD_SetFullscreenMode(win, JNI_FALSE);
2197 AWT_UNLOCK();
2198 #endif /* !HEADLESS */
2199 }
2200
2201 /**
2202 * End DisplayMode/FullScreen support
2203 */
2204
2205 static char *get_output_screen_name(JNIEnv *env, int screen) {
2206 #ifdef _AIX
2207 return NULL;
2208 #else
2209 if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) {
2210 return NULL;
2211 }
2212 char *name = NULL;
2213 AWT_LOCK();
2214 int scr = 0, out = 0;
2215 if (usingXinerama && XScreenCount(awt_display) > 0) {
2216 out = screen;
2217 } else {
2218 scr = screen;
2219 }
2220
2221 XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
2222 RootWindow(awt_display, scr));
2223 if (res) {
2224 if (res->noutput > out) {
2225 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
2226 res, res->outputs[out]);
2227 if (output_info) {
2228 if (output_info->name) {
2229 name = strdup(output_info->name);
2230 }
2231 awt_XRRFreeOutputInfo(output_info);
2232 }
2233 }
2234 awt_XRRFreeScreenResources(res);
2235 }
2236 AWT_UNLOCK();
2237 return name;
2238 #endif /* _AIX */
2239 }
2240
2241 /*
2242 * Class: sun_awt_X11GraphicsDevice
2243 * Method: getNativeScaleFactor
2244 * Signature: (I)D
2245 */
2246 JNIEXPORT jdouble JNICALL
2247 Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
2248 (JNIEnv *env, jobject this, jint screen) {
2249 // in case of Xinerama individual screen scales are not supported
2250 char *name = get_output_screen_name(env, usingXinerama ? 0 : screen);
2251 double scale = getNativeScaleFactor(name);
2252 if (name) {
2253 free(name);
2254 }
2255 return scale;
2256 }
|