jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
changeset 39844 a3cc7e551a48
parent 39556 50963eeaefca
child 40996 60d53c39c1b3
equal deleted inserted replaced
39843:6f69de78d0eb 39844:a3cc7e551a48
  2139 
  2139 
  2140 /**
  2140 /**
  2141  * End DisplayMode/FullScreen support
  2141  * End DisplayMode/FullScreen support
  2142  */
  2142  */
  2143 
  2143 
       
  2144 static char *get_output_screen_name(JNIEnv *env, int screen) {
       
  2145     if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) {
       
  2146         return NULL;
       
  2147     }
       
  2148     char *name = NULL;
       
  2149     AWT_LOCK();
       
  2150     int scr = 0, out = 0;
       
  2151     if (usingXinerama && XScreenCount(awt_display) > 0) {
       
  2152         out = screen;
       
  2153     } else {
       
  2154         scr = screen;
       
  2155     }
       
  2156 
       
  2157     XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
       
  2158                                                   RootWindow(awt_display, scr));
       
  2159     if (res) {
       
  2160        if (res->noutput > out) {
       
  2161             XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
       
  2162                                                         res, res->outputs[out]);
       
  2163             if (output_info) {
       
  2164                 if (output_info->name) {
       
  2165                     name = strdup(output_info->name);
       
  2166                 }
       
  2167                 awt_XRRFreeOutputInfo(output_info);
       
  2168             }
       
  2169         }
       
  2170         awt_XRRFreeScreenResources(res);
       
  2171     }
       
  2172     AWT_UNLOCK();
       
  2173     return name;
       
  2174 }
  2144 
  2175 
  2145 /*
  2176 /*
  2146  * Class:     sun_awt_X11GraphicsDevice
  2177  * Class:     sun_awt_X11GraphicsDevice
  2147  * Method:    getNativeScaleFactor
  2178  * Method:    getNativeScaleFactor
  2148  * Signature: (I)I
  2179  * Signature: (I)D
  2149  */
  2180  */
  2150 JNIEXPORT jint JNICALL
  2181 JNIEXPORT jdouble JNICALL
  2151 Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
  2182 Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
  2152     (JNIEnv *env, jobject this, jint screen) {
  2183     (JNIEnv *env, jobject this, jint screen) {
  2153 
  2184     char *name = get_output_screen_name(env, screen);
  2154     return getNativeScaleFactor();
  2185     double scale = getNativeScaleFactor(name);
  2155 }
  2186     if (name) {
       
  2187         free(name);
       
  2188     }
       
  2189     return scale;
       
  2190 }