-
Notifications
You must be signed in to change notification settings - Fork 1
/
surface.go
185 lines (142 loc) · 3.89 KB
/
surface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package main
import (
"io"
"iter"
"deedles.dev/wlr"
"deedles.dev/ximage/geom"
)
type ViewSurface interface {
io.Closer
Title() string
PID() int
Surface() wlr.Surface
SetResizing(bool)
SetMinimized(bool)
SetMaximized(bool)
Resize(w, h int)
Geometry() geom.Rect[int]
MinWidth() float64
MinHeight() float64
Mapped() bool
Activated() bool
SetActivated(bool)
Surfaces() iter.Seq[wlr.IterSurface]
SurfaceAt(geom.Point[float64]) (s wlr.Surface, sp geom.Point[float64], ok bool)
HasSurface(wlr.Surface) bool
}
type viewSurfaceXDG struct {
s wlr.XDGSurface
}
func (s *viewSurfaceXDG) PID() int {
client := s.s.Resource().GetClient()
pid, _, _ := client.GetCredentials()
return pid
}
func (s *viewSurfaceXDG) HasSurface(surface wlr.Surface) (has bool) {
return s.s.HasSurface(surface)
}
func (s *viewSurfaceXDG) Close() error {
s.s.Toplevel().SendClose()
return nil
}
func (s *viewSurfaceXDG) Title() string {
return s.s.Toplevel().Title()
}
func (s *viewSurfaceXDG) Resize(w, h int) {
s.s.Toplevel().SetSize(int32(w), int32(h))
}
func (s *viewSurfaceXDG) SetResizing(resizing bool) {
s.s.Toplevel().SetResizing(resizing)
}
func (s *viewSurfaceXDG) SetMinimized(m bool) {
// Apparently XDG clients can't be minimized. Huh.
}
func (s *viewSurfaceXDG) SetMaximized(m bool) {
s.s.Toplevel().SetMaximized(m)
}
func (s *viewSurfaceXDG) Geometry() geom.Rect[int] {
return geom.FromImageRect(s.s.GetGeometry())
}
func (s *viewSurfaceXDG) MinWidth() float64 {
return float64(s.s.Toplevel().Current().MinWidth())
}
func (s *viewSurfaceXDG) MinHeight() float64 {
return float64(s.s.Toplevel().Current().MinHeight())
}
func (s *viewSurfaceXDG) Surface() wlr.Surface {
return s.s.Surface()
}
func (s *viewSurfaceXDG) Mapped() bool {
return s.s.Surface().Mapped()
}
func (s *viewSurfaceXDG) SetActivated(a bool) {
s.s.Toplevel().SetActivated(a)
}
func (s *viewSurfaceXDG) Activated() bool {
return s.s.Toplevel().Current().Activated()
}
func (s *viewSurfaceXDG) Surfaces() iter.Seq[wlr.IterSurface] {
return s.s.Surfaces()
}
func (s *viewSurfaceXDG) SurfaceAt(p geom.Point[float64]) (surface wlr.Surface, sp geom.Point[float64], ok bool) {
surface, sx, sy, ok := s.s.SurfaceAt(p.X, p.Y)
return surface, geom.Pt(sx, sy), ok
}
type viewSurfaceXwayland struct {
s wlr.XwaylandSurface
activated bool
}
func (s *viewSurfaceXwayland) PID() int {
return -1 // There doesn't seem to be a way to get this...
}
func (s *viewSurfaceXwayland) HasSurface(surface wlr.Surface) (has bool) {
return s.s.Surface().HasSurface(surface)
}
func (s *viewSurfaceXwayland) Close() error {
s.s.Close()
return nil
}
func (s *viewSurfaceXwayland) Title() string {
return s.s.Title()
}
func (s *viewSurfaceXwayland) Resize(w, h int) {
s.s.Configure(0, 0, uint16(w), uint16(h))
}
func (s *viewSurfaceXwayland) SetResizing(resizing bool) {
// Doesn't make sense for Xwayland clients, it seems.
}
func (s *viewSurfaceXwayland) SetMinimized(m bool) {
s.s.SetMinimized(m)
}
func (s *viewSurfaceXwayland) SetMaximized(m bool) {
s.s.SetMaximized(m)
}
func (s *viewSurfaceXwayland) Geometry() geom.Rect[int] {
return geom.Rt(0, 0, s.s.Width(), s.s.Height())
}
func (s *viewSurfaceXwayland) MinWidth() float64 {
return MinWidth
}
func (s *viewSurfaceXwayland) MinHeight() float64 {
return MinHeight
}
func (s *viewSurfaceXwayland) Surface() wlr.Surface {
return s.s.Surface()
}
func (s *viewSurfaceXwayland) Mapped() bool {
return s.s.Surface().Mapped()
}
func (s *viewSurfaceXwayland) SetActivated(a bool) {
s.s.Activate(a)
s.activated = a
}
func (s *viewSurfaceXwayland) Activated() bool {
return s.activated
}
func (s *viewSurfaceXwayland) Surfaces() iter.Seq[wlr.IterSurface] {
return s.s.Surface().Surfaces()
}
func (s *viewSurfaceXwayland) SurfaceAt(p geom.Point[float64]) (surface wlr.Surface, sp geom.Point[float64], ok bool) {
surface, sx, sy, ok := s.s.Surface().SurfaceAt(p.X, p.Y)
return surface, geom.Pt(sx, sy), ok
}