display

package
v0.0.0-...-20e650a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ColorTemperatureModeNone 不调整色温
	ColorTemperatureModeNone int32 = iota
	// ColorTemperatureModeAuto 自动调整色温
	ColorTemperatureModeAuto
	// ColorTemperatureModeManual 手动调整色温
	ColorTemperatureModeManual
)
View Source
const (
	AccuracyLevelNone         = 0
	AccuracyLevelCountry      = 1
	AccuracyLevelCity         = 4
	AccuracyLevelNeighborhood = 5
	AccuracyLevelStreet       = 6
	AccuracyLevelExact        = 8
)
View Source
const (
	KeyModeMirror        = "Mirror"
	KeyModeExtend        = "Extend"
	KeyModeOnlyOnePrefix = "OnlyOne-"
	KeySingle            = "Single"
)
View Source
const (
	DisplayModeCustom uint8 = iota
	DisplayModeMirror
	DisplayModeExtend
	DisplayModeOnlyOne
	DisplayModeUnknown
)
View Source
const (
	// 1:自动旋转;即未主动调用 SetRotation() 接口(由内部触发)发生的旋转操作,如根据重力传感器自动设定旋转方向
	RotationFinishModeAuto uint8 = iota + 1
	// 2:手动旋转;即主动调用 SetRotation() 接口完成旋转,如控制中心下拉框方式旋转屏幕
	RotationFinishModeManual
)
View Source
const (
	BusTypeUnknown uint8 = iota
	BusTypeUSB
)
View Source
const (
	OutputDeviceTransformNormal     = 0
	OutputDeviceTransform90         = 1
	OutputDeviceTransform180        = 2
	OutputDeviceTransform270        = 3
	OutputDeviceTransformFlipped    = 4
	OutputDeviceTransformFlipped90  = 5
	OutputDeviceTransformFlipped180 = 6
	OutputDeviceTransformFlipped270 = 7
)
View Source
const (
	OutputDeviceModeCurrent   = 1 << 0
	OutputDeviceModePreferred = 1 << 1
)
View Source
const DisplayModeInvalid uint8 = 0

DisplayModeInvalid 无效的模式

Variables

View Source
var ScaleFactorsHelper scaleFactorsHelper

ScaleFactorsHelper 全局的 scale factors 相关 helper,要传给 xsettings 模块。

Functions

func GetForceScaleFactor

func GetForceScaleFactor() (float64, error)

GetForceScaleFactor 允许用户通过 force-scale-factor.ini 强制设置全局缩放

func GetRecommendedScaleFactor

func GetRecommendedScaleFactor() float64

func Init

func Init(xConn *x.Conn, useWayland bool, inVM bool)

func SetGreeterMode

func SetGreeterMode(val bool)

func SetLogLevel

func SetLogLevel(level log.Priority)

func Start

func Start(service *dbusutil.Service) error

func StartPart2

func StartPart2() error

Types

type ConfigV3D3

type ConfigV3D3 map[string]*ScreenConfigV3D3

type ConfigV4

type ConfigV4 map[string]*ScreenConfigV4

type ConfigV5

type ConfigV5 map[string]*ScreenConfigV5

type ConfigV6

type ConfigV6 struct {
	ConfigV5 ConfigV5
	FillMode *FillModeConfigsV5
}

type ConnectInfo

type ConnectInfo struct {
	Connects           map[string]bool
	LastConnectedTimes map[string]time.Time
}

type CrtcInfo

type CrtcInfo randr.GetCrtcInfoReply

type CustomModeConfig

type CustomModeConfig struct {
	Name     string
	Monitors []*MonitorConfigV5
}

type ExtendModeConfig

type ExtendModeConfig struct {
	Monitors []*MonitorConfigV5
}

type FillModeConfigsV5

type FillModeConfigsV5 struct {
	FillModeMap map[string]string
}

type InvalidOutputNameError

type InvalidOutputNameError struct {
	Name string
}

func (InvalidOutputNameError) Error

func (err InvalidOutputNameError) Error() string

type KModeInfo

type KModeInfo struct {
	Id          int32 `json:"id"`
	Width       int32 `json:"width"`
	Height      int32 `json:"height"`
	RefreshRate int32 `json:"refresh_rate"`
	Flags       int32 `json:"flags"`
}

type KOutputInfo

type KOutputInfo struct {
	UUID         string      `json:"uuid"`
	Name         string      `json:"name"`
	EdidBase64   string      `json:"edid_base64"`
	Enabled      int32       `json:"enabled"`
	X            int32       `json:"x"`
	Y            int32       `json:"y"`
	Width        int32       `json:"width"`
	Height       int32       `json:"height"`
	RefreshRate  int32       `json:"refresh_rate"`
	Manufacturer string      `json:"manufacturer"`
	Model        string      `json:"model"`
	ModeInfos    []KModeInfo `json:"ModeInfo"`
	PhysHeight   int32       `json:"phys_height"`
	PhysWidth    int32       `json:"phys_width"`
	Transform    int32       `json:"transform"`
	Scale        float64     `json:"scale"`
	// contains filtered or unexported fields
}

type KOutputInfos

type KOutputInfos []*KOutputInfo

type Manager

type Manager struct {
	PropsMu sync.RWMutex

	// dbusutil-gen: equal=objPathsEqual
	Monitors []dbus.ObjectPath
	// dbusutil-gen: equal=nil
	CustomIdList []string
	HasChanged   bool
	DisplayMode  byte
	// dbusutil-gen: equal=nil
	Brightness map[string]float64
	// dbusutil-gen: equal=nil
	Touchscreens dxTouchscreens
	// dbusutil-gen: equal=nil
	TouchscreensV2 dxTouchscreens
	// dbusutil-gen: equal=nil
	TouchMap map[string]string

	CurrentCustomId        string
	Primary                string
	PrimaryRect            x.Rectangle
	ScreenWidth            uint16
	ScreenHeight           uint16
	MaxBacklightBrightness uint32

	// method of adjust color temperature according to time and location
	ColorTemperatureMode int32
	// adjust color temperature by manual adjustment
	ColorTemperatureManual int32

	ColorTemperatureEnabled bool `prop:"access:rw"`
	SupportColorTemperature bool
	// contains filtered or unexported fields
}

func (*Manager) ApplyChanges

func (m *Manager) ApplyChanges() *dbus.Error

func (*Manager) AssociateTouch

func (m *Manager) AssociateTouch(outputName, touchSerial string) *dbus.Error

func (*Manager) AssociateTouchByUUID

func (m *Manager) AssociateTouchByUUID(outputName, touchUUID string) *dbus.Error

func (*Manager) CanRotate

func (m *Manager) CanRotate() (bool, *dbus.Error)

func (*Manager) CanSetBrightness

func (m *Manager) CanSetBrightness(outputName string) (bool, *dbus.Error)

func (*Manager) ChangeBrightness

func (m *Manager) ChangeBrightness(raised bool) *dbus.Error

ChangeBrightness 通过键盘控制所有显示器一起亮度加或减,保存配置。

func (*Manager) DeleteCustomMode

func (m *Manager) DeleteCustomMode(name string) *dbus.Error

DeleteCustomMode 废弃方法

func (*Manager) GetBrightness

func (m *Manager) GetBrightness() (map[string]float64, *dbus.Error)

func (*Manager) GetBuiltinMonitor

func (m *Manager) GetBuiltinMonitor() (string, dbus.ObjectPath, *dbus.Error)

func (*Manager) GetExportedMethods

func (v *Manager) GetExportedMethods() dbusutil.ExportedMethods

func (*Manager) GetInterfaceName

func (m *Manager) GetInterfaceName() string

func (*Manager) GetRealDisplayMode

func (m *Manager) GetRealDisplayMode() (uint8, *dbus.Error)

func (*Manager) ListOutputNames

func (m *Manager) ListOutputNames() ([]string, *dbus.Error)

func (*Manager) ListOutputsCommonModes

func (m *Manager) ListOutputsCommonModes() ([]ModeInfo, *dbus.Error)

func (*Manager) ModifyConfigName

func (m *Manager) ModifyConfigName(name, newName string) *dbus.Error

ModifyConfigName 废弃方法

func (*Manager) RefreshBrightness

func (m *Manager) RefreshBrightness() *dbus.Error

RefreshBrightness 重置亮度,主要被 session/power 模块调用。从配置恢复亮度。

func (*Manager) Reset

func (m *Manager) Reset() *dbus.Error

func (*Manager) ResetChanges

func (m *Manager) ResetChanges() *dbus.Error

func (*Manager) Save

func (m *Manager) Save() *dbus.Error

func (*Manager) SetAndSaveBrightness

func (m *Manager) SetAndSaveBrightness(outputName string, value float64) *dbus.Error

SetAndSaveBrightness 设置并保持亮度

func (*Manager) SetBrightness

func (m *Manager) SetBrightness(outputName string, value float64) *dbus.Error

SetBrightness 设置亮度但是不保存, 主要被 session/power 模块调用。

func (*Manager) SetColorTemperature

func (m *Manager) SetColorTemperature(value int32) *dbus.Error

func (*Manager) SetMethodAdjustCCT

func (m *Manager) SetMethodAdjustCCT(adjustMethod int32) *dbus.Error

func (*Manager) SetPrimary

func (m *Manager) SetPrimary(outputName string) *dbus.Error

func (*Manager) SupportSetColorTemperature

func (m *Manager) SupportSetColorTemperature() (bool, *dbus.Error)

func (*Manager) SwitchMode

func (m *Manager) SwitchMode(mode byte, name string) *dbus.Error

type MirrorModeConfig

type MirrorModeConfig struct {
	Monitors []*MonitorConfigV5
}

type ModeConfigsV5

type ModeConfigsV5 struct {
	Monitors MonitorConfigsV5
}

type ModeInfo

type ModeInfo struct {
	Id uint32

	Width  uint16
	Height uint16
	Rate   float64
	// contains filtered or unexported fields
}

type ModeInfos

type ModeInfos []ModeInfo

func (ModeInfos) Len

func (infos ModeInfos) Len() int

func (ModeInfos) Less

func (infos ModeInfos) Less(i, j int) bool

func (ModeInfos) Swap

func (infos ModeInfos) Swap(i, j int)

type Monitor

type Monitor struct {
	PropsMu sync.RWMutex

	ID        uint32
	Name      string
	Connected bool

	Manufacturer string
	Model        string
	// dbusutil-gen: equal=uint16SliceEqual
	Rotations []uint16
	// dbusutil-gen: equal=uint16SliceEqual
	Reflects []uint16
	BestMode ModeInfo
	// dbusutil-gen: equal=modeInfosEqual
	Modes []ModeInfo
	// dbusutil-gen: equal=modeInfosEqual
	PreferredModes []ModeInfo
	MmWidth        uint32
	MmHeight       uint32

	Enabled           bool
	X                 int16
	Y                 int16
	Width             uint16
	Height            uint16
	Rotation          uint16
	Reflect           uint16
	RefreshRate       float64
	Brightness        float64
	CurrentRotateMode uint8

	CurrentMode     ModeInfo
	CurrentFillMode string `prop:"access:rw"`
	// dbusutil-gen: equal=method:Equal
	AvailableFillModes strv.Strv
	// contains filtered or unexported fields
}

func (*Monitor) Enable

func (m *Monitor) Enable(enabled bool) *dbus.Error

func (*Monitor) GetExportedMethods

func (v *Monitor) GetExportedMethods() dbusutil.ExportedMethods

func (*Monitor) GetInterfaceName

func (m *Monitor) GetInterfaceName() string

func (*Monitor) SetMode

func (m *Monitor) SetMode(mode uint32) *dbus.Error

func (*Monitor) SetModeBySize

func (m *Monitor) SetModeBySize(width, height uint16) *dbus.Error

func (*Monitor) SetPosition

func (m *Monitor) SetPosition(X, y int16) *dbus.Error

func (*Monitor) SetReflect

func (m *Monitor) SetReflect(value uint16) *dbus.Error

func (*Monitor) SetRefreshRate

func (m *Monitor) SetRefreshRate(value float64) *dbus.Error

func (*Monitor) SetRotation

func (m *Monitor) SetRotation(value uint16) *dbus.Error

func (*Monitor) String

func (m *Monitor) String() string

type MonitorBackup

type MonitorBackup struct {
	Enabled    bool
	Mode       ModeInfo
	X, Y       int16
	Reflect    uint16
	Rotation   uint16
	Brightness float64
}

type MonitorConfigV3D3

type MonitorConfigV3D3 struct {
	UUID        string // sum md5 of name and modes, for config
	Name        string
	Enabled     bool
	X           int16
	Y           int16
	Width       uint16
	Height      uint16
	Rotation    uint16
	Reflect     uint16
	RefreshRate float64
}

type MonitorConfigV5

type MonitorConfigV5 struct {
	UUID        string
	Name        string
	Enabled     bool
	X           int16
	Y           int16
	Width       uint16
	Height      uint16
	Rotation    uint16
	Reflect     uint16
	RefreshRate float64
	Brightness  float64
	Primary     bool

	ColorTemperatureMode   int32
	ColorTemperatureManual int32
}

type MonitorConfigsV5

type MonitorConfigsV5 []*MonitorConfigV5

type MonitorInfo

type MonitorInfo struct {
	Enabled            bool
	ID                 uint32
	UUID               string // UUID V1
	UuidV0             string
	Name               string
	Connected          bool // 实际的是否连接,对应于 Monitor 的 realConnected
	VirtualConnected   bool // 用于前端,对应于 Monitor 的 Connected
	Modes              []ModeInfo
	CurrentMode        ModeInfo
	PreferredMode      ModeInfo
	X                  int16
	Y                  int16
	Width              uint16
	Height             uint16
	Rotation           uint16
	Rotations          uint16
	MmHeight           uint32
	MmWidth            uint32
	EDID               []byte
	Manufacturer       string
	Model              string
	CurrentFillMode    string
	AvailableFillModes []string
	// contains filtered or unexported fields
}

MonitorInfo X 和 Wayland 共用的显示器信息

type Monitors

type Monitors []*Monitor

func (Monitors) GetById

func (monitors Monitors) GetById(id uint32) *Monitor

func (Monitors) GetByName

func (monitors Monitors) GetByName(name string) *Monitor

func (Monitors) GetByUuid

func (monitors Monitors) GetByUuid(uuid string) *Monitor

type OnlyOneModeConfig

type OnlyOneModeConfig struct {
	Monitors []*MonitorConfigV5
}

type OutputInfo

type OutputInfo randr.GetOutputInfoReply

func (*OutputInfo) PreferredMode

func (oi *OutputInfo) PreferredMode() randr.Mode

type RateFilterMap

type RateFilterMap map[string]map[string][]float64

RateFilterMap pciId => (size => rates)

type ScreenConfigV3D3

type ScreenConfigV3D3 struct {
	Name      string
	Primary   string
	BaseInfos []*MonitorConfigV3D3
}

type ScreenConfigV4

type ScreenConfigV4 struct {
	Custom  []*CustomModeConfig `json:",omitempty"`
	Mirror  *MirrorModeConfig   `json:",omitempty"`
	Extend  *ExtendModeConfig   `json:",omitempty"`
	OnlyOne *OnlyOneModeConfig  `json:",omitempty"`
	Single  *MonitorConfigV5    `json:",omitempty"`
}

type ScreenConfigV5

type ScreenConfigV5 struct {
	Mirror  *ModeConfigsV5      `json:",omitempty"`
	Extend  *ModeConfigsV5      `json:",omitempty"`
	OnlyOne *ModeConfigsV5      `json:",omitempty"`
	Single  *SingleModeConfigV5 `json:",omitempty"`
}

type SingleModeConfigV5

type SingleModeConfigV5 struct {
	// 这里其实不能用 Monitors,因为是单数
	Monitor                *MonitorConfigV5 `json:"Monitors"` // 单屏时,该配置文件中色温相关数据未生效;增加json的tag是为了兼容之前配置文件
	ColorTemperatureMode   int32
	ColorTemperatureManual int32
}

type Size

type Size struct {
	// contains filtered or unexported fields
}

type SysCache

type SysCache struct {
	BuiltinMonitor string
	ConnectTime    map[string]time.Time
}

type SysConfig

type SysConfig struct {
	DisplayMode  byte
	Screens      map[string]*SysScreenConfig
	ScaleFactors map[string]float64 // 缩放比例
	FillModes    map[string]string  // key 是特殊的 fillMode Key
	Cache        SysCache
}

SysConfig v1

type SysMonitorConfig

type SysMonitorConfig struct {
	UUID        string
	Name        string
	Enabled     bool
	X           int16
	Y           int16
	Width       uint16
	Height      uint16
	Rotation    uint16
	Reflect     uint16
	RefreshRate float64
	Brightness  float64
	Primary     bool
}

type SysMonitorConfigs

type SysMonitorConfigs []*SysMonitorConfig

type SysMonitorModeConfig

type SysMonitorModeConfig struct {
	Monitors SysMonitorConfigs
}

type SysRootConfig

type SysRootConfig struct {
	Version  string
	Config   SysConfig
	UpdateAt string
	// contains filtered or unexported fields
}

type SysScreenConfig

type SysScreenConfig struct {
	Mirror      *SysMonitorModeConfig            `json:",omitempty"`
	Extend      *SysMonitorModeConfig            `json:",omitempty"`
	Single      *SysMonitorModeConfig            `json:",omitempty"`
	OnlyOneMap  map[string]*SysMonitorModeConfig `json:",omitempty"`
	OnlyOneUuid string                           `json:",omitempty"`
}

SysScreenConfig 系统级屏幕配置 NOTE: Single 可以看作是特殊的显示模式,和 Mirror,Extend 等模式共用 SysMonitorModeConfig 结构可以保持设计上的统一,不必在乎里面有 Monitors

type Touchscreen

type Touchscreen struct {
	Id         int32
	Name       string
	DeviceNode string
	Serial     string
	UUID       string
	// contains filtered or unexported fields
}

type TransformationMatrix

type TransformationMatrix [9]float32

type UserConfig

type UserConfig struct {
	Version string
	Screens map[string]UserScreenConfig
}

UserConfig v1

type UserMonitorModeConfig

type UserMonitorModeConfig struct {
	ColorTemperatureMode   int32
	ColorTemperatureManual int32
	ColorTemperatureModeOn int32 //记录用户开启色温时的模式

}

type UserScreenConfig

type UserScreenConfig map[string]*UserMonitorModeConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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