< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, 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


1860 #endif /* HEADLESS */
1861 }
1862 
1863 /*
1864  * Class:     sun_awt_X11GraphicsDevice
1865  * Method:    getCurrentDisplayMode
1866  * Signature: (I)Ljava/awt/DisplayMode;
1867  */
1868 JNIEXPORT jobject JNICALL
1869 Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
1870     (JNIEnv* env, jclass x11gd, jint screen)
1871 {
1872 #ifdef HEADLESS
1873     return NULL;
1874 #else
1875     XRRScreenConfiguration *config;
1876     jobject displayMode = NULL;
1877 
1878     AWT_LOCK();
1879 


1880     config = awt_XRRGetScreenInfo(awt_display,
1881                                   RootWindow(awt_display, screen));
1882     if (config != NULL) {
1883         Rotation rotation;
1884         short curRate;
1885         SizeID curSizeIndex;
1886         XRRScreenSize *sizes;
1887         int nsizes;
1888 
1889         curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation);
1890         sizes = awt_XRRConfigSizes(config, &nsizes);
1891         curRate = awt_XRRConfigCurrentRate(config);
1892 
1893         if ((sizes != NULL) &&
1894             (curSizeIndex < nsizes))
1895         {
1896             XRRScreenSize curSize = sizes[curSizeIndex];
1897             displayMode = X11GD_CreateDisplayMode(env,
1898                                                   curSize.width,
1899                                                   curSize.height,
1900                                                   BIT_DEPTH_MULTI,
1901                                                   curRate);
1902         }
1903 
1904         awt_XRRFreeScreenConfigInfo(config);

1905     }
1906 
1907     AWT_FLUSH_UNLOCK();
1908 
1909     return displayMode;
1910 #endif /* HEADLESS */
1911 }
1912 
1913 /*
1914  * Class:     sun_awt_X11GraphicsDevice
1915  * Method:    enumDisplayModes
1916  * Signature: (ILjava/util/ArrayList;)V
1917  */
1918 JNIEXPORT void JNICALL
1919 Java_sun_awt_X11GraphicsDevice_enumDisplayModes
1920     (JNIEnv* env, jclass x11gd,
1921      jint screen, jobject arrayList)
1922 {
1923 #ifndef HEADLESS
1924     XRRScreenConfiguration *config;


   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


1860 #endif /* HEADLESS */
1861 }
1862 
1863 /*
1864  * Class:     sun_awt_X11GraphicsDevice
1865  * Method:    getCurrentDisplayMode
1866  * Signature: (I)Ljava/awt/DisplayMode;
1867  */
1868 JNIEXPORT jobject JNICALL
1869 Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
1870     (JNIEnv* env, jclass x11gd, jint screen)
1871 {
1872 #ifdef HEADLESS
1873     return NULL;
1874 #else
1875     XRRScreenConfiguration *config;
1876     jobject displayMode = NULL;
1877 
1878     AWT_LOCK();
1879 
1880     if (screen < ScreenCount(awt_display)) {
1881 
1882         config = awt_XRRGetScreenInfo(awt_display,
1883                                       RootWindow(awt_display, screen));
1884         if (config != NULL) {
1885             Rotation rotation;
1886             short curRate;
1887             SizeID curSizeIndex;
1888             XRRScreenSize *sizes;
1889             int nsizes;
1890 
1891             curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation);
1892             sizes = awt_XRRConfigSizes(config, &nsizes);
1893             curRate = awt_XRRConfigCurrentRate(config);
1894 
1895             if ((sizes != NULL) &&
1896                 (curSizeIndex < nsizes))
1897             {
1898                 XRRScreenSize curSize = sizes[curSizeIndex];
1899                 displayMode = X11GD_CreateDisplayMode(env,
1900                                                       curSize.width,
1901                                                       curSize.height,
1902                                                       BIT_DEPTH_MULTI,
1903                                                       curRate);
1904             }
1905 
1906             awt_XRRFreeScreenConfigInfo(config);
1907         }
1908     }
1909 
1910     AWT_FLUSH_UNLOCK();
1911 
1912     return displayMode;
1913 #endif /* HEADLESS */
1914 }
1915 
1916 /*
1917  * Class:     sun_awt_X11GraphicsDevice
1918  * Method:    enumDisplayModes
1919  * Signature: (ILjava/util/ArrayList;)V
1920  */
1921 JNIEXPORT void JNICALL
1922 Java_sun_awt_X11GraphicsDevice_enumDisplayModes
1923     (JNIEnv* env, jclass x11gd,
1924      jint screen, jobject arrayList)
1925 {
1926 #ifndef HEADLESS
1927     XRRScreenConfiguration *config;


< prev index next >