< prev index next >

src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java

Print this page




 264                             doubleBuffer);
 265                 } else {
 266                     defaultConfig = X11GraphicsConfig.getConfig(this, visNum,
 267                                         depth, getConfigColormap(0, screen),
 268                                         doubleBuffer);
 269                 }
 270             }
 271         }
 272     }
 273 
 274     private static native void enterFullScreenExclusive(long window);
 275     private static native void exitFullScreenExclusive(long window);
 276     private static native boolean initXrandrExtension();
 277     private static native DisplayMode getCurrentDisplayMode(int screen);
 278     private static native void enumDisplayModes(int screen,
 279                                                 ArrayList<DisplayMode> modes);
 280     private static native void configDisplayMode(int screen,
 281                                                  int width, int height,
 282                                                  int displayMode);
 283     private static native void resetNativeData(int screen);
 284     private static native int getNativeScaleFactor(int screen);
 285 
 286     /**
 287      * Returns true only if:
 288      *   - the Xrandr extension is present
 289      *   - the necessary Xrandr functions were loaded successfully
 290      */
 291     private static synchronized boolean isXrandrExtensionSupported() {
 292         if (xrandrExtSupported == null) {
 293             xrandrExtSupported =
 294                 Boolean.valueOf(initXrandrExtension());
 295         }
 296         return xrandrExtSupported.booleanValue();
 297     }
 298 
 299     @Override
 300     public boolean isFullScreenSupported() {
 301         boolean fsAvailable = isXrandrExtensionSupported();
 302         if (fsAvailable) {
 303             SecurityManager security = System.getSecurityManager();
 304             if (security != null) {


 499     /**
 500      * From the DisplayChangedListener interface; devices do not need
 501      * to react to this event.
 502      */
 503     public void paletteChanged() {
 504     }
 505 
 506     /**
 507      * Add a DisplayChangeListener to be notified when the display settings
 508      * are changed.  Typically, only top-level containers need to be added
 509      * to X11GraphicsDevice.
 510      */
 511     public void addDisplayChangedListener(DisplayChangedListener client) {
 512         topLevels.add(client);
 513     }
 514 
 515     public int getScaleFactor() {
 516         return scale;
 517     }
 518 





 519     private int initScaleFactor() {
 520 
 521         if (SunGraphicsEnvironment.isUIScaleEnabled()) {
 522 
 523             double debugScale = SunGraphicsEnvironment.getDebugScale();
 524 
 525             if (debugScale >= 1) {
 526                 return (int) debugScale;
 527             }
 528 
 529             int nativeScale = getNativeScaleFactor(screen);
 530             return nativeScale >= 1 ? nativeScale : 1;
 531         }
 532 
 533         return 1;
 534     }
 535 
 536     /**
 537      * Remove a DisplayChangeListener from this X11GraphicsDevice.
 538      */
 539     public void removeDisplayChangedListener(DisplayChangedListener client) {
 540         topLevels.remove(client);
 541     }
 542 
 543     public String toString() {
 544         return ("X11GraphicsDevice[screen="+screen+"]");
 545     }
 546 }


 264                             doubleBuffer);
 265                 } else {
 266                     defaultConfig = X11GraphicsConfig.getConfig(this, visNum,
 267                                         depth, getConfigColormap(0, screen),
 268                                         doubleBuffer);
 269                 }
 270             }
 271         }
 272     }
 273 
 274     private static native void enterFullScreenExclusive(long window);
 275     private static native void exitFullScreenExclusive(long window);
 276     private static native boolean initXrandrExtension();
 277     private static native DisplayMode getCurrentDisplayMode(int screen);
 278     private static native void enumDisplayModes(int screen,
 279                                                 ArrayList<DisplayMode> modes);
 280     private static native void configDisplayMode(int screen,
 281                                                  int width, int height,
 282                                                  int displayMode);
 283     private static native void resetNativeData(int screen);
 284     private static native double getNativeScaleFactor(int screen);
 285 
 286     /**
 287      * Returns true only if:
 288      *   - the Xrandr extension is present
 289      *   - the necessary Xrandr functions were loaded successfully
 290      */
 291     private static synchronized boolean isXrandrExtensionSupported() {
 292         if (xrandrExtSupported == null) {
 293             xrandrExtSupported =
 294                 Boolean.valueOf(initXrandrExtension());
 295         }
 296         return xrandrExtSupported.booleanValue();
 297     }
 298 
 299     @Override
 300     public boolean isFullScreenSupported() {
 301         boolean fsAvailable = isXrandrExtensionSupported();
 302         if (fsAvailable) {
 303             SecurityManager security = System.getSecurityManager();
 304             if (security != null) {


 499     /**
 500      * From the DisplayChangedListener interface; devices do not need
 501      * to react to this event.
 502      */
 503     public void paletteChanged() {
 504     }
 505 
 506     /**
 507      * Add a DisplayChangeListener to be notified when the display settings
 508      * are changed.  Typically, only top-level containers need to be added
 509      * to X11GraphicsDevice.
 510      */
 511     public void addDisplayChangedListener(DisplayChangedListener client) {
 512         topLevels.add(client);
 513     }
 514 
 515     public int getScaleFactor() {
 516         return scale;
 517     }
 518 
 519     public int getNativeScale() {
 520         isXrandrExtensionSupported();
 521         return (int)Math.round(getNativeScaleFactor(screen));
 522     }
 523 
 524     private int initScaleFactor() {
 525 
 526         if (SunGraphicsEnvironment.isUIScaleEnabled()) {
 527 
 528             double debugScale = SunGraphicsEnvironment.getDebugScale();
 529 
 530             if (debugScale >= 1) {
 531                 return (int) debugScale;
 532             }
 533             int nativeScale = getNativeScale();

 534             return nativeScale >= 1 ? nativeScale : 1;
 535         }
 536 
 537         return 1;
 538     }
 539 
 540     /**
 541      * Remove a DisplayChangeListener from this X11GraphicsDevice.
 542      */
 543     public void removeDisplayChangedListener(DisplayChangedListener client) {
 544         topLevels.remove(client);
 545     }
 546 
 547     public String toString() {
 548         return ("X11GraphicsDevice[screen="+screen+"]");
 549     }
 550 }
< prev index next >