30 lines
544 B
Go
30 lines
544 B
Go
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
|
|
}
|