46 import sun.java2d.SunGraphicsEnvironment;
47
48 /**
49 * This is an implementation of a GraphicsDevice object for a single
50 * X11 screen.
51 *
52 * @see GraphicsEnvironment
53 * @see GraphicsConfiguration
54 */
55 public final class X11GraphicsDevice extends GraphicsDevice
56 implements DisplayChangedListener {
57 int screen;
58 HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
59
60 private static AWTPermission fullScreenExclusivePermission;
61 private static Boolean xrandrExtSupported;
62 private final Object configLock = new Object();
63 private SunDisplayChanger topLevels = new SunDisplayChanger();
64 private DisplayMode origDisplayMode;
65 private boolean shutdownHookRegistered;
66 private final int scale;
67
68 public X11GraphicsDevice(int screennum) {
69 this.screen = screennum;
70 this.scale = initScaleFactor();
71 }
72
73 /*
74 * Initialize JNI field and method IDs for fields that may be
75 * accessed from C.
76 */
77 private static native void initIDs();
78
79 static {
80 if (!GraphicsEnvironment.isHeadless()) {
81 initIDs();
82 }
83 }
84
85 /**
86 * Returns the X11 screen of the device.
471 }
472 DisplayMode[] modes = getDisplayModes();
473 for (DisplayMode mode : modes) {
474 if (dm.equals(mode) ||
475 (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
476 dm.getWidth() == mode.getWidth() &&
477 dm.getHeight() == mode.getHeight() &&
478 dm.getBitDepth() == mode.getBitDepth()))
479 {
480 return mode;
481 }
482 }
483 return null;
484 }
485
486 /**
487 * From the DisplayChangedListener interface; called from
488 * X11GraphicsEnvironment when the display mode has been changed.
489 */
490 public synchronized void displayChanged() {
491 // On X11 the visuals do not change, and therefore we don't need
492 // to reset the defaultConfig, config, doubleBufferVisuals,
493 // neither do we need to reset the native data.
494
495 // pass on to all top-level windows on this screen
496 topLevels.notifyListeners();
497 }
498
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 */
|
46 import sun.java2d.SunGraphicsEnvironment;
47
48 /**
49 * This is an implementation of a GraphicsDevice object for a single
50 * X11 screen.
51 *
52 * @see GraphicsEnvironment
53 * @see GraphicsConfiguration
54 */
55 public final class X11GraphicsDevice extends GraphicsDevice
56 implements DisplayChangedListener {
57 int screen;
58 HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
59
60 private static AWTPermission fullScreenExclusivePermission;
61 private static Boolean xrandrExtSupported;
62 private final Object configLock = new Object();
63 private SunDisplayChanger topLevels = new SunDisplayChanger();
64 private DisplayMode origDisplayMode;
65 private boolean shutdownHookRegistered;
66 private int scale;
67
68 public X11GraphicsDevice(int screennum) {
69 this.screen = screennum;
70 this.scale = initScaleFactor();
71 }
72
73 /*
74 * Initialize JNI field and method IDs for fields that may be
75 * accessed from C.
76 */
77 private static native void initIDs();
78
79 static {
80 if (!GraphicsEnvironment.isHeadless()) {
81 initIDs();
82 }
83 }
84
85 /**
86 * Returns the X11 screen of the device.
471 }
472 DisplayMode[] modes = getDisplayModes();
473 for (DisplayMode mode : modes) {
474 if (dm.equals(mode) ||
475 (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
476 dm.getWidth() == mode.getWidth() &&
477 dm.getHeight() == mode.getHeight() &&
478 dm.getBitDepth() == mode.getBitDepth()))
479 {
480 return mode;
481 }
482 }
483 return null;
484 }
485
486 /**
487 * From the DisplayChangedListener interface; called from
488 * X11GraphicsEnvironment when the display mode has been changed.
489 */
490 public synchronized void displayChanged() {
491 if (SunGraphicsEnvironment.isUIScaleEnabled()) {
492 scale = initScaleFactor();
493 }
494 // On X11 the visuals do not change, and therefore we don't need
495 // to reset the defaultConfig, config, doubleBufferVisuals,
496 // neither do we need to reset the native data.
497
498 // pass on to all top-level windows on this screen
499 topLevels.notifyListeners();
500 }
501
502 /**
503 * From the DisplayChangedListener interface; devices do not need
504 * to react to this event.
505 */
506 public void paletteChanged() {
507 }
508
509 /**
510 * Add a DisplayChangeListener to be notified when the display settings
511 * are changed. Typically, only top-level containers need to be added
512 * to X11GraphicsDevice.
513 */
|