Files
niri/model_output.go

71 lines
1.9 KiB
Go

package niri
import "encoding/json"
type OutputName = string
type Output struct {
Name OutputName `json:"name"`
Make string `json:"make"`
Model string `json:"model"`
Serial string `json:"serial"`
PhysicalSize [2]int `json:"physical_size"`
Modes []OutputMode `json:"modes"`
CurrentMode int `json:"current_mode"`
VrrSupported bool `json:"vrr_supported"`
VrrEnabled bool `json:"vrr_enabled"`
Logical OutputLogical `json:"logical"`
}
func (m Output) String() string {
data, _ := json.MarshalIndent(m, "", "\t")
return string(data)
}
type OutputMode struct {
Width int `json:"width"`
Height int `json:"height"`
RefreshRate int `json:"refresh_rate"`
IsPreferred bool `json:"is_preferred"`
}
func (m OutputMode) Configured() ConfiguredMode {
return ConfiguredMode{
Width: m.Width,
Height: m.Height,
Refresh: OptionOf(float64(m.RefreshRate) / 100),
}
}
func (m OutputMode) String() string {
data, _ := json.MarshalIndent(m, "", "\t")
return string(data)
}
type OutputLogical struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
Scale float64 `json:"scale"`
Transform OutputTransform `json:"transform"`
}
func (m OutputLogical) String() string {
data, _ := json.MarshalIndent(m, "", "\t")
return string(data)
}
type OutputTransform string
const (
TransformNormal OutputTransform = "Normal"
Transform90 OutputTransform = "90"
Transform180 OutputTransform = "180"
Transform270 OutputTransform = "270"
TransformFlipped OutputTransform = "Flipped"
TransformFlipped90 OutputTransform = "Flipped90"
TransformFlipped180 OutputTransform = "Flipped180"
TransformFlipped270 OutputTransform = "Flipped270"
)