Top Description Inners Fields Constructors Methods
org.lwjgl.opengl

public Class XRandR

extends Object
Class Inheritance
Imports
org.lwjgl.LWJGLUtil, java.io.BufferedReader, .IOException, .InputStreamReader, java.util.*, java.util.regex.Matcher, .Pattern

Utility for working with the xrandr commmand-line utility. Assumes xrandr v1.2 or higher.
Author
ryanm

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
XRandR.Screen

Encapsulates the configuration of a monitor.

Field Summary

Modifier and TypeField and Description
private static XRandR.Screen[]
private static final Pattern
private static String
primaryScreenIdentifier

Either the screen marked as "primary" (if it is turned on) or the one with the largest (current) resolution.

private static XRandR.Screen[]
savedConfiguration

Used to save the configuration of all output devices to restore it on exit or in case of crash.

private static final Pattern
private static final Pattern
private static Map<String, XRandR.Screen[]>
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static XRandR.Screen
private static XRandR.Screen
public static XRandR.Screen[]

Returns:

The current screen configuration of the primary device, or an empty array if xrandr is not supported
getConfiguration
()

public static XRandR.Screen[]

Returns:

the possible resolutions of the named screen, or null if there is no such screen
getResolutions
(String name)

public static String[]

Returns:

the name of connected screens, or an empty array if xrandr is not supported
getScreenNames
()

private static void
parseScreenHeader(int[]
the int-array to write the position into
screenPosition
,
String
String containing resolution and position, from xrandr
resPos
)

Parses a screen configuration header and extracts information about the position of the screen.

private static void
parseScreenModeline(List<XRandR.Screen>
the list to add the Screen to if it's valid
allModes
,
List<XRandR.Screen>
the list to add the current screen config to
current
,
String
the name of this screen
name
,
int width, int height, String[]
config string
modeLine
,
int[]
position of this screen
screenPosition
)

Parses a screen configuration and adds it to one of the lists if valid.

private static void
public static void
restoreConfiguration()

Restores the configuration for all connected display devices.

public static void
saveConfiguration()

Saves the current configuration for all connected display devices.

pack-priv static DisplayMode
public static void
setConfiguration(boolean
if screens not included in screens should be turned off (true) or left alone (false)
disableOthers
,
XRandR.Screen...
The desired screen set, may not be null
screens
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private static XRandR.Screen[] current
FREQ_PATTERNback to summary
private static final Pattern FREQ_PATTERN
primaryScreenIdentifierback to summary
private static String primaryScreenIdentifier

Either the screen marked as "primary" (if it is turned on) or the one with the largest (current) resolution.

savedConfigurationback to summary
private static XRandR.Screen[] savedConfiguration

Used to save the configuration of all output devices to restore it on exit or in case of crash.

SCREEN_HEADER_PATTERNback to summary
private static final Pattern SCREEN_HEADER_PATTERN
SCREEN_MODELINE_PATTERNback to summary
private static final Pattern SCREEN_MODELINE_PATTERN
screensback to summary
private static Map<String, XRandR.Screen[]> screens
WHITESPACE_PATTERNback to summary
private static final Pattern WHITESPACE_PATTERN

Constructor Detail

XRandRback to summary
public XRandR()

Method Detail

DisplayModetoScreenback to summary
pack-priv static XRandR.Screen DisplayModetoScreen(DisplayMode mode)
findPrimaryback to summary
private static XRandR.Screen findPrimary(XRandR.Screen... screens)
getConfigurationback to summary
public static XRandR.Screen[] getConfiguration()
Returns:XRandR.Screen[]

The current screen configuration of the primary device, or an empty array if xrandr is not supported

getResolutionsback to summary
public static XRandR.Screen[] getResolutions(String name)
Returns:XRandR.Screen[]

the possible resolutions of the named screen, or null if there is no such screen

getScreenNamesback to summary
public static String[] getScreenNames()
Returns:String[]

the name of connected screens, or an empty array if xrandr is not supported

parseScreenHeaderback to summary
private static void parseScreenHeader(int[] screenPosition, String resPos)

Parses a screen configuration header and extracts information about the position of the screen.

Parameters
screenPosition:int[]

the int-array to write the position into

resPos:String

String containing resolution and position, from xrandr

parseScreenModelineback to summary
private static void parseScreenModeline(List<XRandR.Screen> allModes, List<XRandR.Screen> current, String name, int width, int height, String[] modeLine, int[] screenPosition)

Parses a screen configuration and adds it to one of the lists if valid.

Parameters
allModes:List<XRandR.Screen>

the list to add the Screen to if it's valid

current:List<XRandR.Screen>

the list to add the current screen config to

name:String

the name of this screen

modeLine:String[]

config string

screenPosition:int[]

position of this screen

populateback to summary
private static void populate()
restoreConfigurationback to summary
public static void restoreConfiguration()

Restores the configuration for all connected display devices. Used on exit or in case of a crash to reset all devices.

saveConfigurationback to summary
public static void saveConfiguration()

Saves the current configuration for all connected display devices. This configuration can be restored on exit/crash by calling restoreConfiguration()

ScreentoDisplayModeback to summary
pack-priv static DisplayMode ScreentoDisplayMode(XRandR.Screen... screens)
setConfigurationback to summary
public static void setConfiguration(boolean disableOthers, XRandR.Screen... screens)
Parameters
disableOthers:boolean

if screens not included in screens should be turned off (true) or left alone (false)

screens:XRandR.Screen[]

The desired screen set, may not be null

Exceptions
IllegalArgumentException:
if no screens are specified
org.lwjgl.opengl back to summary

public Class XRandR.Screen

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable

Encapsulates the configuration of a monitor. Resolution and freq are fixed, position is mutable
Author
ryanm

Field Summary

Modifier and TypeField and Description
public final int
freq

Frequency in Hz

public final int
height

Height in pixels

public final String
name

Name for this output

public final int
width

Width in pixels

public int
xPos

Position on the x-axis, in pixels

public int
yPos

Position on the y-axis, in pixels

Constructor Summary

AccessConstructor and Description
pack-priv
Screen(String name, int width, int height, int freq, int xPos, int yPos)

Method Summary

Modifier and TypeMethod and Description
private void
getArgs(List<String> argList)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

freqback to summary
public final int freq

Frequency in Hz

heightback to summary
public final int height

Height in pixels

nameback to summary
public final String name

Name for this output

widthback to summary
public final int width

Width in pixels

xPosback to summary
public int xPos

Position on the x-axis, in pixels

yPosback to summary
public int yPos

Position on the y-axis, in pixels

Constructor Detail

Screenback to summary
pack-priv Screen(String name, int width, int height, int freq, int xPos, int yPos)

Method Detail

getArgsback to summary
private void getArgs(List<String> argList)
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