xrandr/resolution.go

30 lines
544 B
Go
Raw Permalink Normal View History

2023-12-18 23:08:42 +01:00
package xrandr
type Resolution struct {
Width int `json:"width"`
Height int `json:"height"`
}
func NewResolutionFromString(width, height string) *Resolution {
if width == "" || height == "" {
return nil
}
return NewResolution(atoi(width), atoi(height))
}
func NewResolution(width, height int) *Resolution {
return &Resolution{width, height}
}
func (r *Resolution) Equivalent(o *Resolution) bool {
if r == o {
return true
}
if (r == nil) != (o == nil) {
return false
}
return r.Width == o.Width && r.Height == o.Height
}