Skip to content

screen ​

go
import "github.com/tangoui/tango/sys/screen"

本页由 site/tools/apigen 从源码注释生成(按 darwin 构建标签选文件),请勿手改。

Package screen lists the displays attached to the computer.

Coordinates are logical (DIP) pixels with the origin at the top-left corner of the primary display; displays left of or above it have negative coordinates. Scale is the ratio of physical to logical pixels.

Functions are safe from any goroutine once the app runs. They return ErrUnsupported when the backend cannot list displays (mobile, minimal backends) and tango.ErrNotRunning after the app quit. Display changes (a monitor plugged in, the arrangement or scale changed) arrive as tango.EventDisplaysChanged; OnChange is a shortcut for listening to them.

变量 ​

go
var ErrNoDisplay = errors.New("tango: no display")

ErrNoDisplay is returned when the system reports no display at all (a headless session).

go
var ErrUnsupported = platform.ErrUnsupported

ErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.

函数 ​

func OnChange ​

go
func OnChange(a *tango.App, fn func())

OnChange calls fn on the main thread whenever displays are added, removed, rearranged or rescaled.

类型 ​

Display ​

go
type Display = platform.Display

Display is one monitor. WorkArea excludes the menu bar, dock and taskbars.

func All ​

go
func All(a *tango.App) ([]Display, error)

All returns every display; the primary one is first.

func At ​

go
func At(a *tango.App, x, y int) (Display, error)

At returns the display containing the point (x, y), or the display nearest to it when the point is on none.

func Primary ​

go
func Primary(a *tango.App) (Display, error)

Primary returns the primary display (the one with the menu bar on macOS, the main taskbar on Windows).

Rect ​

go
type Rect = platform.Rect

Rect is a rectangle in logical pixels.

以 MIT 许可发布