30 lines
444 B
Go
30 lines
444 B
Go
package xrandr
|
|
|
|
type Position struct {
|
|
X int `json:"x"`
|
|
Y int `json:"y"`
|
|
}
|
|
|
|
func NewPositionFromString(x, y string) *Position {
|
|
if x == "" || y == "" {
|
|
return nil
|
|
}
|
|
return NewPosition(atoi(x), atoi(y))
|
|
}
|
|
|
|
func NewPosition(x, y int) *Position {
|
|
return &Position{x, y}
|
|
}
|
|
|
|
func (p *Position) Equivalent(o *Position) bool {
|
|
if p == o {
|
|
return true
|
|
}
|
|
|
|
if (p == nil) != (o == nil) {
|
|
return false
|
|
}
|
|
|
|
return p.X == o.X && p.Y == o.Y
|
|
}
|