1package ports
2
3import "time"
4
5// ClientCommand carries core → wayland commands.
6type ClientCommand interface{ clientCommand() }
7
8// ShortcutsInhibitState carries core → wayland whether a window's
9// shortcuts inhibitor is in effect (it has keyboard focus).
10type ShortcutsInhibitState struct {
11 Window WindowID
12 Active bool
13}
14
15func (ShortcutsInhibitState) clientCommand() {}
16
17// UserActivity carries core → wayland that the user touched an input
18// device, for idle notifications (ext_idle_notifier_v1). Core sends at
19// most one per ActivityInterval.
20type UserActivity struct{}
21
22func (UserActivity) clientCommand() {}
23
24// ActivityInterval is the most often core reports UserActivity: idle
25// timers may start up to this much early, so no idle timeout is shorter.
26const ActivityInterval = 100 * time.Millisecond
27
28// ConfigureWindow carries core → wayland geometry and state. Output is the
29// connector showing the window, empty while it is hidden.
30type ConfigureWindow struct {
31 ID WindowID
32 Width, Height int
33 Fullscreen, Activated bool
34 // Floating windows are not tiled: no tiled states.
35 Floating bool
36 // Output is the output the window belongs to, kept while it is not
37 // visible (scale, foreign toplevel).
38 Output string
39 // Visible is set while part of the window is on its output: not on a
40 // hidden workspace, scrolled off, behind a maximized column or a
41 // hidden float. An invisible window is suspended and throttled.
42 Visible bool
43 // Captured marks a window drawn only for a capture session (its
44 // workspace is not on screen): Visible stays the physical truth.
45 Captured bool
46}
47
48func (ConfigureWindow) clientCommand() {}
49
50// OutputPlacement is one output in the global layout. X, Y, Width and
51// Height are logical; physical = logical × Scale.
52type OutputPlacement struct {
53 Info OutputInfo
54 X, Y, Width, Height int
55 Scale float64
56 // Primary is output.<name>.primary: the pointer starts on it.
57 Primary bool
58}
59
60// Contains reports whether the logical point is on the output.
61func (o OutputPlacement) Contains(x, y float64) bool {
62 return x >= float64(o.X) && x < float64(o.X+o.Width) && y >= float64(o.Y) && y < float64(o.Y+o.Height)
63}
64
65// Layout is the global arrangement of outputs, left to right.
66type Layout []OutputPlacement
67
68// At returns the output under the logical point.
69func (l Layout) At(x, y float64) (OutputPlacement, bool) {
70 for _, o := range l {
71 if o.Contains(x, y) {
72 return o, true
73 }
74 }
75 return OutputPlacement{}, false
76}
77
78// Clamp keeps the pointer on an output: a point outside every output stays
79// on the output under (fromX, fromY), or the first one, clamped to its edges.
80func (l Layout) Clamp(fromX, fromY, x, y float64) (float64, float64) {
81 if len(l) == 0 {
82 return x, y
83 }
84 if _, ok := l.At(x, y); ok {
85 return x, y
86 }
87 o, ok := l.At(fromX, fromY)
88 if !ok {
89 o = l[0]
90 }
91 x = min(max(x, float64(o.X)), float64(o.X+o.Width)-1)
92 y = min(max(y, float64(o.Y)), float64(o.Y+o.Height)-1)
93 return x, y
94}
95
96// SetOutputs carries core → wayland every output and the focused one (where
97// new surfaces start). It is sent when the list, a placement or the focus changes.
98type SetOutputs struct {
99 Outputs Layout
100 Focused string
101 // Off lists the outputs a client turned off (output power management),
102 // in Outputs order.
103 Off []string
104}
105
106func (SetOutputs) clientCommand() {}
107
108// SlotsPending tells wayland whether a slot waits for its window. Only then
109// does it read the SlotEnv of mapping clients.
110type SlotsPending struct{ Pending bool }
111
112func (SlotsPending) clientCommand() {}
113
114// CloseWindow carries core → wayland close requests.
115type CloseWindow struct{ ID WindowID }
116
117func (CloseWindow) clientCommand() {}
118
119// FocusWindow carries core → wayland keyboard focus (0 means none).
120type FocusWindow struct{ ID WindowID }
121
122func (FocusWindow) clientCommand() {}
123
124// ConfigurePopup carries core → wayland a popup's place, relative to its
125// parent's window geometry. Reposition answers a reposition request.
126type ConfigurePopup struct {
127 ID WindowID
128 Rect Rect
129 Reposition bool
130 Token uint32
131}
132
133func (ConfigurePopup) clientCommand() {}
134
135// ClosePopup carries core → wayland a popup to dismiss (popup_done).
136type ClosePopup struct{ ID WindowID }
137
138func (ClosePopup) clientCommand() {}
139
140// PointerFocus changes the pointer surface; ID 0 clears focus. Coordinates are surface-local.
141type PointerFocus struct {
142 ID WindowID
143 X, Y float64
144}
145
146func (PointerFocus) clientCommand() {}
147
148// PointerMotionTo carries core → wayland motion for the pointer focus, in
149// window coordinates. The deltas and TimeUsec feed zwp_relative_pointer_v1;
150// While the window locks the pointer, wayland sends only relative motion.
151type PointerMotionTo struct {
152 ID WindowID
153 X, Y float64
154 DX, DY float64
155 UnaccelDX, UnaccelDY float64
156 TimeMsec uint32
157 TimeUsec uint64
158}
159
160func (PointerMotionTo) clientCommand() {}
161
162type PointerButtonTo struct {
163 ID WindowID
164 Button uint32
165 Pressed bool
166 TimeMsec uint32
167}
168
169func (PointerButtonTo) clientCommand() {}
170
171// PointerAxisTo sends a scroll frame to a window.
172type PointerAxisTo struct {
173 ID WindowID
174 Axis PointerAxis
175}
176
177func (PointerAxisTo) clientCommand() {}
178
179// ForwardKey carries core → wayland unbound keys.
180type ForwardKey struct {
181 ID WindowID
182 Key KeyEvent
183}
184
185func (ForwardKey) clientCommand() {}
186
187// SetKeymap carries app → wayland repeat info and, unless Keymap is empty, a new
188// xkb keymap in text format.
189type SetKeymap struct {
190 Keymap string
191 RepeatRate, RepeatDelay int
192}
193
194func (SetKeymap) clientCommand() {}
195
196// CursorImage is a cursor frame in premultiplied B8G8R8A8, W*4 bytes per
197// row; (HotX, HotY) is the click point. Sizes are physical pixels.
198type CursorImage struct {
199 W, H, HotX, HotY int
200 Pixels []byte
201}
202
203// CursorChange carries wayland → outputs the cursor the focused client asks
204// for: a CSS cursor name (wp_cursor_shape_v1), its own image, or none.
205// The zero value is the default arrow.
206type CursorChange struct {
207 // Shape is a CSS cursor name such as "pointer" or "text".
208 Shape string
209 // Image is a client cursor at Scale buffer pixels per logical pixel.
210 Image *CursorImage
211 Scale int
212 Hidden bool
213}
214
215// SpawnRequest carries core → launcher process arguments.
216type SpawnRequest struct {
217 // Security retains the admitting owner epoch through launcher backpressure.
218 // A wired launcher rejects stale or protected requests before execution.
219 Security SecurityState
220 Argv []string
221 // Env adds KEY=value entries to the child environment.
222 Env []string
223}