Top Description Fields Constructors Methods
sun.awt

public final Class X11GraphicsDevice

extends GraphicsDevice
implements DisplayChangedListener
Class Inheritance
All Implemented Interfaces
sun.awt.DisplayChangedListener, java.util.EventListener
Imports
java.awt.AWTPermission, .DisplayMode, .GraphicsConfiguration, .GraphicsDevice, .GraphicsEnvironment, .Insets, .Rectangle, .Window, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .HashMap, .HashSet, .Objects, sun.awt.util.ThreadGroupUtils, sun.java2d.SunGraphicsEnvironment, sun.java2d.loops.SurfaceType, sun.awt.X11.XToolkit, sun.java2d.opengl.GLXGraphicsConfig, sun.java2d.pipe.Region, sun.java2d.xr.XRGraphicsConfig

This is an implementation of a GraphicsDevice object for a single X11 screen.
See Also
GraphicsEnvironment, GraphicsConfiguration

Field Summary

Modifier and TypeField and Description
private volatile Rectangle
pack-priv GraphicsConfiguration[]
pack-priv GraphicsConfiguration
pack-priv HashSet<Integer>
private static AWTPermission
private volatile Insets
private DisplayMode
private int
private volatile int
screen

X11 screen number.

private boolean
private SunDisplayChanger
pack-priv HashMap<SurfaceType, Object>
private static Boolean
Inherited from java.awt.GraphicsDevice:
TYPE_IMAGE_BUFFERTYPE_PRINTERTYPE_RASTER_SCREEN

Constructor Summary

AccessConstructor and Description
public
X11GraphicsDevice(int screennum)

Method Summary

Modifier and TypeMethod and Description
public void
addDisplayChangedListener(DisplayChangedListener client)

Add a DisplayChangeListener to be notified when the display settings are changed.

private void
private static native void
configDisplayMode(int screen, int width, int height, int displayMode)

public synchronized void
displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

From the DisplayChangedListener interface; called from X11GraphicsEnvironment when the display mode has been changed.
private static native void
private static void
private static native void
private static native void
private static void
public Rectangle
private Rectangle
private native int
getConfigColormap(int index, int screen)

private native int
getConfigDepth(int index, int screen)

public GraphicsConfiguration[]
getConfigurations()

Implements abstract java.awt.GraphicsDevice.getConfigurations.

Returns all of the graphics configurations associated with this graphics device.
public native int
getConfigVisualId(int index, int screen)

private static native DisplayMode
public GraphicsConfiguration
getDefaultConfiguration()

Implements abstract java.awt.GraphicsDevice.getDefaultConfiguration.

Returns the default graphics configuration associated with this graphics device.
private DisplayMode
public native long
getDisplay()

Returns the X11 Display of this device.

public synchronized DisplayMode
getDisplayMode()

Overrides java.awt.GraphicsDevice.getDisplayMode.

Returns the current display mode of this GraphicsDevice.
public synchronized DisplayMode[]
getDisplayModes()

Overrides java.awt.GraphicsDevice.getDisplayModes.

Returns all display modes available for this GraphicsDevice.
private native void
public String
getIDstring()

Implements abstract java.awt.GraphicsDevice.getIDstring.

Returns the identification string associated with this graphics device.
public Insets
private synchronized DisplayMode
public int
private static native double
public native int
getNumConfigs(int screen)

public Object
public int
public int
getScreen()

Returns the X11 screen of the device.

public int
getType()

Implements abstract java.awt.GraphicsDevice.getType.

Returns the type of the graphics device.
private int
private static native boolean
public void
pack-priv static native boolean
public boolean
isDisplayChangeSupported()

Overrides java.awt.GraphicsDevice.isDisplayChangeSupported.

Returns true if this GraphicsDevice supports low-level display changes.
public boolean
isFullScreenSupported()

Overrides java.awt.GraphicsDevice.isFullScreenSupported.

Returns true if this GraphicsDevice supports full-screen exclusive mode.
private static synchronized boolean
isXrandrExtensionSupported()

Returns true only if: - the Xrandr extension is present - the necessary Xrandr functions were loaded successfully

private void
private void
public void
paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

From the DisplayChangedListener interface; devices do not need to react to this event.
private native Rectangle
pGetBounds(int screenNum)

public void
removeDisplayChangedListener(DisplayChangedListener client)

Remove a DisplayChangeListener from this X11GraphicsDevice.

public void
public int
scaleDown(int x)

public int
scaleUp(int x)

public synchronized void
setDisplayMode(DisplayMode
The new display mode of this graphics device.
dm
)

Overrides java.awt.GraphicsDevice.setDisplayMode.

Sets the display mode of this graphics device.
public synchronized void
setFullScreenWindow(Window
a window to use as the full-screen window; null if returning to windowed mode. Some platforms expect the fullscreen window to be a top-level component (i.e., a Frame); therefore it is preferable to use a Frame here rather than a Window.
w
)

Overrides java.awt.GraphicsDevice.setFullScreenWindow.

Enter full-screen mode, or return to windowed mode.
public void
setInsets(Insets newInsets)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.awt.GraphicsDevice:
getAvailableAcceleratedMemorygetBestConfigurationgetFullScreenWindowisWindowTranslucencySupported

Field Detail

boundsback to summary
private volatile Rectangle bounds
configsback to summary
pack-priv GraphicsConfiguration[] configs
defaultConfigback to summary
pack-priv GraphicsConfiguration defaultConfig
doubleBufferVisualsback to summary
pack-priv HashSet<Integer> doubleBufferVisuals
fullScreenExclusivePermissionback to summary
private static AWTPermission fullScreenExclusivePermission
insetsback to summary
private volatile Insets insets
origDisplayModeback to summary
private DisplayMode origDisplayMode
scaleback to summary
private int scale
screenback to summary
private volatile int screen

X11 screen number. This identifier can become non-valid at any time therefore methods, which is using this id should be ready to it.

shutdownHookRegisteredback to summary
private boolean shutdownHookRegistered
topLevelsback to summary
private SunDisplayChanger topLevels
x11ProxyKeyMapback to summary
pack-priv HashMap<SurfaceType, Object> x11ProxyKeyMap
xrandrExtSupportedback to summary
private static Boolean xrandrExtSupported

Constructor Detail

X11GraphicsDeviceback to summary
public X11GraphicsDevice(int screennum)

Method Detail

addDisplayChangedListenerback to summary
public void addDisplayChangedListener(DisplayChangedListener client)

Add a DisplayChangeListener to be notified when the display settings are changed. Typically, only top-level containers need to be added to X11GraphicsDevice.

addDoubleBufferVisualback to summary
private void addDoubleBufferVisual(int visNum)
configDisplayModeback to summary
private static native void configDisplayMode(int screen, int width, int height, int displayMode)
displayChangedback to summary
public synchronized void displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

From the DisplayChangedListener interface; called from X11GraphicsEnvironment when the display mode has been changed.

Annotations
@Override
enterFullScreenExclusiveback to summary
private static native void enterFullScreenExclusive(long window)
enterFullScreenExclusiveback to summary
private static void enterFullScreenExclusive(Window w)
enumDisplayModesback to summary
private static native void enumDisplayModes(int screen, ArrayList<DisplayMode> modes)
exitFullScreenExclusiveback to summary
private static native void exitFullScreenExclusive(long window)
exitFullScreenExclusiveback to summary
private static void exitFullScreenExclusive(Window w)
getBoundsback to summary
public Rectangle getBounds()
getBoundsImplback to summary
private Rectangle getBoundsImpl()
getConfigColormapback to summary
private native int getConfigColormap(int index, int screen)
getConfigDepthback to summary
private native int getConfigDepth(int index, int screen)
getConfigurationsback to summary
public GraphicsConfiguration[] getConfigurations()

Implements abstract java.awt.GraphicsDevice.getConfigurations.

Returns all of the graphics configurations associated with this graphics device.

Returns:GraphicsConfiguration[]

Doc from java.awt.GraphicsDevice.getConfigurations.

an array of GraphicsConfiguration objects that are associated with this GraphicsDevice.

Annotations
@Override
getConfigVisualIdback to summary
public native int getConfigVisualId(int index, int screen)
getCurrentDisplayModeback to summary
private static native DisplayMode getCurrentDisplayMode(int screen)
getDefaultConfigurationback to summary
public GraphicsConfiguration getDefaultConfiguration()

Implements abstract java.awt.GraphicsDevice.getDefaultConfiguration.

Returns the default graphics configuration associated with this graphics device.

Returns:GraphicsConfiguration

Doc from java.awt.GraphicsDevice.getDefaultConfiguration.

the default GraphicsConfiguration of this GraphicsDevice.

Annotations
@Override
getDefaultDisplayModeback to summary
private DisplayMode getDefaultDisplayMode()
getDisplayback to summary
public native long getDisplay()

Returns the X11 Display of this device. This method is also in MDrawingSurfaceInfo but need it here to be able to allow a GraphicsConfigTemplate to get the Display.

getDisplayModeback to summary
public synchronized DisplayMode getDisplayMode()

Overrides java.awt.GraphicsDevice.getDisplayMode.

Doc from java.awt.GraphicsDevice.getDisplayMode.

Returns the current display mode of this GraphicsDevice. The returned display mode is allowed to have a refresh rate DisplayMode#REFRESH_RATE_UNKNOWN if it is indeterminate. Likewise, the returned display mode is allowed to have a bit depth DisplayMode#BIT_DEPTH_MULTI if it is indeterminate or if multiple bit depths are supported.

Returns:DisplayMode

the current display mode of this graphics device.

Annotations
@Override
getDisplayModesback to summary
public synchronized DisplayMode[] getDisplayModes()

Overrides java.awt.GraphicsDevice.getDisplayModes.

Doc from java.awt.GraphicsDevice.getDisplayModes.

Returns all display modes available for this GraphicsDevice. The returned display modes are allowed to have a refresh rate DisplayMode#REFRESH_RATE_UNKNOWN if it is indeterminate. Likewise, the returned display modes are allowed to have a bit depth DisplayMode#BIT_DEPTH_MULTI if it is indeterminate or if multiple bit depths are supported.

Returns:DisplayMode[]

all of the display modes available for this graphics device.

Annotations
@Override
getDoubleBufferVisualsback to summary
private native void getDoubleBufferVisuals(int screen)
getIDstringback to summary
public String getIDstring()

Implements abstract java.awt.GraphicsDevice.getIDstring.

Returns the identification string associated with this graphics device.

Returns:String

Doc from java.awt.GraphicsDevice.getIDstring.

a String that is the identification of this GraphicsDevice.

Annotations
@Override
getInsetsback to summary
public Insets getInsets()
getMatchingDisplayModeback to summary
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm)
getNativeScaleback to summary
public int getNativeScale()
getNativeScaleFactorback to summary
private static native double getNativeScaleFactor(int screen)
getNumConfigsback to summary
public native int getNumConfigs(int screen)
getProxyKeyForback to summary
public Object getProxyKeyFor(SurfaceType st)
getScaleFactorback to summary
public int getScaleFactor()
getScreenback to summary
public int getScreen()

Returns the X11 screen of the device.

getTypeback to summary
public int getType()

Implements abstract java.awt.GraphicsDevice.getType.

Returns the type of the graphics device.

Returns:int

Doc from java.awt.GraphicsDevice.getType.

the type of this GraphicsDevice, which can either be TYPE_RASTER_SCREEN, TYPE_PRINTER or TYPE_IMAGE_BUFFER.

Annotations
@Override
See Also
TYPE_RASTER_SCREEN, TYPE_PRINTER, TYPE_IMAGE_BUFFER
initScaleFactorback to summary
private int initScaleFactor()
initXrandrExtensionback to summary
private static native boolean initXrandrExtension()
invalidateback to summary
public void invalidate(X11GraphicsDevice device)
isDBESupportedback to summary
pack-priv static native boolean isDBESupported()
isDisplayChangeSupportedback to summary
public boolean isDisplayChangeSupported()

Overrides java.awt.GraphicsDevice.isDisplayChangeSupported.

Doc from java.awt.GraphicsDevice.isDisplayChangeSupported.

Returns true if this GraphicsDevice supports low-level display changes. On some platforms low-level display changes may only be allowed in full-screen exclusive mode (i.e., if isFullScreenSupported() returns true and the application has already entered full-screen mode using setFullScreenWindow).

Returns:boolean

whether low-level display changes are supported for this graphics device.

Annotations
@Override
isFullScreenSupportedback to summary
public boolean isFullScreenSupported()

Overrides java.awt.GraphicsDevice.isFullScreenSupported.

Doc from java.awt.GraphicsDevice.isFullScreenSupported.

Returns true if this GraphicsDevice supports full-screen exclusive mode. If a SecurityManager is installed, its checkPermission method will be called with AWTPermission("fullScreenExclusive"). isFullScreenSupported returns true only if that permission is granted.

Returns:boolean

whether full-screen exclusive mode is available for this graphics device

Annotations
@Override
isXrandrExtensionSupportedback to summary
private static synchronized boolean isXrandrExtensionSupported()

Returns true only if: - the Xrandr extension is present - the necessary Xrandr functions were loaded successfully

makeConfigurationsback to summary
private void makeConfigurations()
makeDefaultConfigurationback to summary
private void makeDefaultConfiguration()
paletteChangedback to summary
public void paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

From the DisplayChangedListener interface; devices do not need to react to this event.

Annotations
@Override
pGetBoundsback to summary
private native Rectangle pGetBounds(int screenNum)
removeDisplayChangedListenerback to summary
public void removeDisplayChangedListener(DisplayChangedListener client)

Remove a DisplayChangeListener from this X11GraphicsDevice.

resetInsetsback to summary
public void resetInsets()
scaleDownback to summary
public int scaleDown(int x)
scaleUpback to summary
public int scaleUp(int x)
setDisplayModeback to summary
public synchronized void setDisplayMode(DisplayMode dm)

Overrides java.awt.GraphicsDevice.setDisplayMode.

Doc from java.awt.GraphicsDevice.setDisplayMode.

Sets the display mode of this graphics device. This is only allowed if isDisplayChangeSupported() returns true and may require first entering full-screen exclusive mode using setFullScreenWindow providing that full-screen exclusive mode is supported (i.e., isFullScreenSupported() returns true).

The display mode must be one of the display modes returned by getDisplayModes(), with one exception: passing a display mode with DisplayMode#REFRESH_RATE_UNKNOWN refresh rate will result in selecting a display mode from the list of available display modes with matching width, height and bit depth. However, passing a display mode with DisplayMode#BIT_DEPTH_MULTI for bit depth is only allowed if such mode exists in the list returned by getDisplayModes().

Example code:


Frame frame;
DisplayMode newDisplayMode;
GraphicsDevice gd;
// create a Frame, select desired DisplayMode from the list of modes
// returned by gd.getDisplayModes() ...

if (gd.isFullScreenSupported()) {
    gd.setFullScreenWindow(frame);
} else {
   // proceed in non-full-screen mode
   frame.setSize(...);
   frame.setLocation(...);
   frame.setVisible(true);
}

if (gd.isDisplayChangeSupported()) {
    gd.setDisplayMode(newDisplayMode);
}
Parameters
dm:DisplayMode

The new display mode of this graphics device.

Annotations
@SuppressWarnings:removal
@Override
setFullScreenWindowback to summary
public synchronized void setFullScreenWindow(Window w)

Overrides java.awt.GraphicsDevice.setFullScreenWindow.

Doc from java.awt.GraphicsDevice.setFullScreenWindow.

Enter full-screen mode, or return to windowed mode. The entered full-screen mode may be either exclusive or simulated. Exclusive mode is only available if isFullScreenSupported returns true.

Exclusive mode implies:

  • Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order.
  • There can be only one full-screen window on a device at any time, so calling this method while there is an existing full-screen Window will cause the existing full-screen window to return to windowed mode.
  • Input method windows are disabled. It is advisable to call Component.enableInputMethods(false) to make a component a non-client of the input method framework.

The simulated full-screen mode places and resizes the window to the maximum possible visible area of the screen. However, the native windowing system may modify the requested geometry-related data, so that the Window object is placed and sized in a way that corresponds closely to the desktop settings.

When entering full-screen mode, if the window to be used as a full-screen window is not visible, this method will make it visible. It will remain visible when returning to windowed mode.

When entering full-screen mode, all the translucency effects are reset for the window. Its shape is set to null, the opacity value is set to 1.0f, and the background color alpha is set to 255 (completely opaque). These values are not restored when returning to windowed mode.

It is unspecified and platform-dependent how decorated windows operate in full-screen mode. For this reason, it is recommended to turn off the decorations in a Frame or Dialog object by using the setUndecorated method.

When returning to windowed mode from an exclusive full-screen window, any display changes made by calling setDisplayMode are automatically restored to their original state.

Parameters
w:Window

a window to use as the full-screen window; null if returning to windowed mode. Some platforms expect the fullscreen window to be a top-level component (i.e., a Frame); therefore it is preferable to use a Frame here rather than a Window.

Annotations
@Override
setInsetsback to summary
public void setInsets(Insets newInsets)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object