chrome.system.display

Description: Use the system.display API to query display metadata.
Availability: Stable since Chrome 30.
Permissions: "system.display"

Summary

Types
Bounds
Insets
Methods
getInfo chrome.system.display.getInfo(function callback)
setDisplayProperties chrome.system.display.setDisplayProperties(string id, object info, function callback)
Events
onDisplayChanged

Types

Bounds

properties
integer left The x-coordinate of the upper-left corner.
integer top The y-coordinate of the upper-left corner.
integer width The width of the display in pixels.
integer height The height of the display in pixels.

Insets

properties
integer left The x-axis distance from the left bound.
integer top The y-axis distance from the top bound.
integer right The x-axis distance from the right bound.
integer bottom The y-axis distance from the bottom bound.

Methods

getInfo

chrome.system.display.getInfo(function callback)

Get the information of all attached display devices.

Parameters
function callback

The callback parameter should be a function that looks like this:

function(array of object displayInfo) {...};
array of object displayInfo

Properties of each object

string id The unique identifier of the display.
string name The user-friendly name (e.g. "HP LCD monitor").
string mirroringSourceId Identifier of the display that is being mirrored on the display unit. If mirroring is not in progress, set to an empty string. Currently exposed only on ChromeOS. Will be empty string on other platforms.
boolean isPrimary True if this is the primary display.
boolean isInternal True if this is an internal display.
boolean isEnabled True if this display is enabled.
double dpiX The number of pixels per inch along the x-axis.
double dpiY The number of pixels per inch along the y-axis.
integer rotation The display's clockwise rotation in degrees relative to the vertical position. Currently exposed only on ChromeOS. Will be set to 0 on other platforms.
Bounds bounds The display's logical bounds.
Insets overscan The display's insets within its screen's bounds. Currently exposed only on ChromeOS. Will be set to empty insets on other platforms.
Bounds workArea The usable work area of the display within the display bounds. The work area excludes areas of the display reserved for OS, for example taskbar and launcher.

setDisplayProperties

chrome.system.display.setDisplayProperties(string id, object info, function callback)

Updates the properties for the display specified by |id|, according to the information provided in |info|. On failure, runtime.lastError will be set.

Parameters
string id The display's unique identifier.
object info The information about display properties that should be changed. A property will be changed only if a new value for it is specified in |info|.
string (optional) mirroringSourceId If set and not empty, starts mirroring between this and the display with the provided id (the system will determine which of the displays is actually mirrored). If set and not empty, stops mirroring between this and the display with the specified id (if mirroring is in progress). If set, no other parameter may be set.
boolean (optional) isPrimary If set to true, makes the display primary. No-op if set to false.
Insets (optional) overscan If set, sets the display's overscan insets to the provided values. Note that overscan values may not be negative or larger than a half of the screen's size. Overscan cannot be changed on the internal monitor. It's applied after isPrimary parameter.
integer (optional) rotation If set, updates the display's rotation. Legal values are [0, 90, 180, 270]. The rotation is set clockwise, relative to the display's vertical position. It's applied after overscan paramter.
integer (optional) boundsOriginX If set, updates the display's logical bounds origin along x-axis. Applied together with boundsOriginY, if boundsOriginY is set. Note that, when updating the display origin, some constraints will be applied, so the final bounds origin may be different than the one set. The final bounds can be retrieved using getInfo. The bounds origin is applied after rotation. The bounds origin cannot be changed on the primary display. Note that is also invalid to set bounds origin values if isPrimary is also set (as isPrimary parameter is applied first).
integer (optional) boundsOriginY If set, updates the display's logical bounds origin along y-axis. See documentation for boundsOriginX parameter.
function (optional) callback Empty function called when the function finishes. To find out whether the function succeeded, runtime.lastError should be queried.

If you specify the callback parameter, it should be a function that looks like this:

function() {...};

Events

onDisplayChanged

Fired when anything changes to the display configuration.

addListener

chrome.system.display.onDisplayChanged.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function() {...};