display

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package display wraps the chrome.system.display API.

Functions require a chrome.Conn with permission to use the chrome.system.display API. chrome.Chrome.TestAPIConn has such permission and may be passed here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFakeDisplayID

func IsFakeDisplayID(id string) bool

IsFakeDisplayID checks if a display is fake or not by its id.

func PhysicalDisplayConnected

func PhysicalDisplayConnected(ctx context.Context, tconn *chrome.TestConn) (bool, error)

PhysicalDisplayConnected checks the display info and returns true if at least one physical display is connected.

func RotateToLandscape

func RotateToLandscape(ctx context.Context, tconn *chrome.TestConn) (func(context.Context) error, error)

RotateToLandscape rotates the display only if current orientation type is "portrait", and returns a function that restores the original orientation setting.

func SetDisplayProperties

func SetDisplayProperties(ctx context.Context, tconn *chrome.TestConn, id string, dp DisplayProperties) error

SetDisplayProperties updates the properties for the display specified by id. See https://developer.chrome.com/docs/extensions/reference/system_display/#method-setDisplayProperties. Some properties, like rotation, will be performed in an async way. For rotation in particular, you should call display.WaitForDisplayRotation() to know when the rotation animation finishes.

func SetDisplayRotationSync

func SetDisplayRotationSync(ctx context.Context, tconn *chrome.TestConn, dispID string, rot RotationAngle) error

SetDisplayRotationSync rotates the display to a certain angle and waits until the rotation animation finished. c must be a connection with both system.display and autotestPrivate permissions.

func WaitForDisplayRotation

func WaitForDisplayRotation(ctx context.Context, tconn *chrome.TestConn, dispID string, rot RotationAngle) error

WaitForDisplayRotation waits for the display rotation animation. If it is not animating, it returns immediately. Returns an error if incorrect parameters are passed, or the display rotation ends up with a different rotation from the specified one.

Types

type DisplayMode

type DisplayMode struct {
	Width                int     `json:"width"`
	Height               int     `json:"height"`
	WidthInNativePixels  int     `json:"widthInNativePixels"`
	HeightInNativePixels int     `json:"heightInNativePixels"`
	UIScale              float64 `json:"uiScale,omitempty"`
	DeviceScaleFactor    float64 `json:"deviceScaleFactor"`
	RefreshRate          float64 `json:"refreshRate"`
	IsNative             bool    `json:"isNative"`
	IsSelected           bool    `json:"isSelected"`
	IsInterlaced         bool    `json:"isInterlaced,omitempty"`
}

DisplayMode holds a mode supported by the display. See https://developer.chrome.com/docs/extensions/reference/system_display/#type-DisplayMode.

type DisplayProperties

type DisplayProperties struct {
	IsUnified         *bool        `json:"isUnified,omitempty"`
	MirroringSourceID *string      `json:"mirroringSourceId,omitempty"`
	IsPrimary         *bool        `json:"isPrimary,omitempty"`
	Overscan          *Insets      `json:"overscan,omitempty"`
	Rotation          *int         `json:"rotation,omitempty"`
	BoundsOriginX     *int         `json:"boundsOriginX,omitempty"`
	BoundsOriginY     *int         `json:"boundsOriginY,omitempty"`
	DisplayMode       *DisplayMode `json:"displayMode,omitempty"`
	DisplayZoomFactor *float64     `json:"displayZoomFactor,omitempty"`
}

DisplayProperties holds properties to change and is passed to SetDisplayProperties. nil fields are ignored. See https://developer.chrome.com/docs/extensions/reference/system_display/#type-DisplayProperties.

type Info

type Info struct {
	ID                          string         `json:"id"`
	Name                        string         `json:"name"`
	MirroringSourceID           string         `json:"mirroringSourceId"`
	IsPrimary                   bool           `json:"isPrimary"`
	IsInternal                  bool           `json:"isInternal"`
	IsEnabled                   bool           `json:"isEnabled"`
	IsUnified                   bool           `json:"isUnified"`
	DPIX                        float64        `json:"dpiX"`
	DPIY                        float64        `json:"dpiY"`
	Rotation                    int            `json:"rotation"`
	Bounds                      coords.Rect    `json:"bounds"`
	Overscan                    *Insets        `json:"overscan"`
	WorkArea                    coords.Rect    `json:"workArea"`
	Modes                       []*DisplayMode `json:"modes"`
	HasTouchSupport             bool           `json:"hasTouchSupport"`
	AvailableDisplayZoomFactors []float64      `json:"availableDisplayZoomFactors"`
	DisplayZoomFactor           float64        `json:"displayZoomFactor"`
}

Info holds information about a display and is returned by GetInfo. See https://developer.chrome.com/docs/extensions/reference/system_display/#type-DisplayUnitInfo.

func FindInfo

func FindInfo(ctx context.Context, tconn *chrome.TestConn, predicate func(info *Info) bool) (*Info, error)

FindInfo returns information about the display that satisfies the given predicate.

func GetInfo

func GetInfo(ctx context.Context, tconn *chrome.TestConn) ([]Info, error)

GetInfo calls chrome.system.display.getInfo to get information about connected displays. See https://developer.chrome.com/docs/extensions/reference/system_display/#method-getInfo.

func GetInternalInfo

func GetInternalInfo(ctx context.Context, tconn *chrome.TestConn) (*Info, error)

GetInternalInfo returns information about the internal display. An error is returned if no internal display is present.

func GetPrimaryInfo

func GetPrimaryInfo(ctx context.Context, tconn *chrome.TestConn) (*Info, error)

GetPrimaryInfo returns information about the primary display.

func (*Info) GetEffectiveDeviceScaleFactor

func (info *Info) GetEffectiveDeviceScaleFactor() (float64, error)

GetEffectiveDeviceScaleFactor computes the ratio of a DIP (device independent pixel) to a physical pixel, which is DisplayZoomFactor x DeviceScaleFactor. See also ui/display/manager/managed_display_info.h in Chromium.

func (*Info) GetSelectedMode

func (info *Info) GetSelectedMode() (*DisplayMode, error)

GetSelectedMode returns the currently selected display mode. It returns nil if no such mode is found.

type Insets

type Insets struct {
	Left   int `json:"left"`
	Top    int `json:"top"`
	Right  int `json:"right"`
	Bottom int `json:"bottom"`
}

Insets holds onscreen insets. See https://developer.chrome.com/docs/extensions/reference/system_display/#type-Insets.

type Orientation

type Orientation struct {
	// Angle is an angle in degrees of the display counterclockwise from the
	// orientation of the display panel.
	Angle int `json:"angle"`
	// Type is an OrientationType representing the display orientation.
	Type OrientationType `json:"type"`
}

Orientation holds information obtained from the screen orientation API. See https://w3c.github.io/screen-orientation/#screenorientation-interface

func GetOrientation

func GetOrientation(ctx context.Context, tconn *chrome.TestConn) (*Orientation, error)

GetOrientation returns the Orientation of the display.

type OrientationType

type OrientationType string

OrientationType represents a display orientation.

const (
	OrientationPortraitPrimary    OrientationType = "portrait-primary"
	OrientationPortraitSecondary  OrientationType = "portrait-secondary"
	OrientationLandscapePrimary   OrientationType = "landscape-primary"
	OrientationLandscapeSecondary OrientationType = "landscape-secondary"
)

OrientationType values as "enum OrientationType" defined in https://w3c.github.io/screen-orientation/#screenorientation-interface

type RotationAngle

type RotationAngle string

RotationAngle represents the supported rotation angles by SetDisplayRotationSync.

const (
	// RotateAny represents the auto-rotation to the device angle. Valid only in
	// tablet mode.
	RotateAny RotationAngle = "RotateAny"
	// Rotate0 represents rotation angle 0.
	Rotate0 RotationAngle = "Rotate0"
	// Rotate90 represents rotation angle 90.
	Rotate90 RotationAngle = "Rotate90"
	// Rotate180 represents rotation angle 180.
	Rotate180 RotationAngle = "Rotate180"
	// Rotate270 represents rotation angle 270.
	Rotate270 RotationAngle = "Rotate270"
)

Rotation values as defined in: https://cs.chromium.org/chromium/src/out/Debug/gen/chrome/common/extensions/api/autotest_private.h

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL