1package ports
2
3// ClientEvent carries wayland → core notifications.
4type ClientEvent interface{ clientEvent() }
5
6// WindowMapped carries wayland → core mapping.
7type WindowMapped struct {
8 ID WindowID
9 AppID string
10 // Slot is the SlotEnv value of the client process, empty if none.
11 Slot string
12 // PID is the client process, 0 when unknown.
13 PID int
14 // Floating windows are dialogs (a parent) or fixed-size windows such
15 // as splash screens: core shows them over the columns at their own
16 // size, Width×Height logical (0 when unknown).
17 Floating bool
18 Width, Height int
19}
20
21// SlotEnv is the environment variable neferwl sets on processes it spawns
22// for a slot. The client's value maps its windows to the slot.
23const SlotEnv = "NEFERWL_SLOT"
24
25func (WindowMapped) clientEvent() {}
26
27// InputRegionChanged replaces the surface-local hit area for a mapped surface.
28// All means the full hit rectangle; otherwise Rects is the exact union.
29type InputRegionChanged struct {
30 ID WindowID
31 All bool
32 Rects []Rect
33}
34
35func (InputRegionChanged) clientEvent() {}
36
37// WindowUnmapped carries wayland → core removal.
38type WindowUnmapped struct{ ID WindowID }
39
40func (WindowUnmapped) clientEvent() {}
41
42// ShortcutsInhibit carries wayland → core that a window asks for (Active)
43// or stops asking for all keys, compositor binds included, while it has
44// keyboard focus (zwp_keyboard_shortcuts_inhibit_v1).
45type ShortcutsInhibit struct {
46 Window WindowID
47 Active bool
48}
49
50func (ShortcutsInhibit) clientEvent() {}
51
52// IdleInhibit carries wayland → core that a window keeps (Active) or
53// stops keeping the session from going idle (zwp_idle_inhibit_v1).
54type IdleInhibit struct {
55 Window WindowID
56 Active bool
57}
58
59func (IdleInhibit) clientEvent() {}
60
61// OutputPower carries wayland → core a client turning a display off or
62// back on (zwlr_output_power_v1).
63type OutputPower struct {
64 Output string
65 On bool
66}
67
68func (OutputPower) clientEvent() {}
69
70// ResizeEdges are the window edges a pointer resize moves, as bit flags
71// (the xdg_toplevel resize_edge values).
72type ResizeEdges uint32
73
74const (
75 ResizeTop ResizeEdges = 1
76 ResizeBottom ResizeEdges = 2
77 ResizeLeft ResizeEdges = 4
78 ResizeRight ResizeEdges = 8
79)
80
81// WindowMoveRequest carries wayland → core xdg_toplevel move and resize
82// requests answering the client's current press: core starts a pointer
83// drag of the window with the held button.
84type WindowMoveRequest struct {
85 ID WindowID
86 Resize bool
87 Edges ResizeEdges
88}
89
90func (WindowMoveRequest) clientEvent() {}
91
92// WindowFullscreenRequest carries wayland → core fullscreen requests.
93// External is set when another client (a taskbar, through foreign
94// toplevel) asks for it, not the window itself.
95type WindowFullscreenRequest struct {
96 ID WindowID
97 Fullscreen bool
98 External bool
99}
100
101func (WindowFullscreenRequest) clientEvent() {}
102
103// WindowActivate carries wayland → core a valid xdg-activation request:
104// show the window's workspace and focus it.
105type WindowActivate struct{ ID WindowID }
106
107func (WindowActivate) clientEvent() {}
108
109// WorkspaceActivate requests showing workspaces by stable ID, in commit order.
110// Core applies the entire batch before publishing a new state.
111type WorkspaceActivate struct{ IDs []uint64 }
112
113func (WorkspaceActivate) clientEvent() {}
114
115// Workspaces is an immutable, latest-only inventory of output workspaces.
116type Workspaces struct{ Outputs []WorkspaceOutput }
117type WorkspaceOutput struct {
118 Name string
119 Workspaces []WorkspaceInfo
120}
121type WorkspaceInfo struct {
122 ID uint64
123 Configured string // configured name; empty for dynamic workspaces. ID, not this, identifies the workspace
124 Name string
125 Index int // zero-based vertical coordinate
126 Active, Hidden bool
127 // Frame is the workspace viewport in output-local logical pixels
128 // (Monitor.Frame geometry: the whole output unless the workspace has a
129 // size override). It is where a capture session of it lies.
130 Frame Rect
131}
132
133// WindowAppID carries wayland → core an app ID set after the window mapped.
134type WindowAppID struct {
135 ID WindowID
136 AppID string
137}
138
139func (WindowAppID) clientEvent() {}
140
141// WindowResized carries wayland → core the new size of a floating window.
142type WindowResized struct {
143 ID WindowID
144 Width, Height int
145}
146
147func (WindowResized) clientEvent() {}
148
149// Popup anchors and gravities, as xdg_positioner values.
150const (
151 EdgeNone uint32 = iota
152 EdgeTop
153 EdgeBottom
154 EdgeLeft
155 EdgeRight
156 EdgeTopLeft
157 EdgeBottomLeft
158 EdgeTopRight
159 EdgeBottomRight
160)
161
162// Popup constraint adjustments, as xdg_positioner values.
163const (
164 AdjustSlideX uint32 = 1 << iota
165 AdjustSlideY
166 AdjustFlipX
167 AdjustFlipY
168 AdjustResizeX
169 AdjustResizeY
170)
171
172// Positioner places a popup relative to its parent's window geometry:
173// the Anchor point of AnchorRect, moved by Offset, with the popup extending
174// towards Gravity. Adjust says how core may move it to stay on screen.
175type Positioner struct {
176 Width, Height int
177 AnchorRect Rect
178 Anchor, Gravity uint32
179 OffsetX, OffsetY int
180 Adjust uint32
181}
182
183// PopupRequest carries wayland → core a popup to place (xdg_popup), on
184// its first commit and on reposition (Reposition, with the client's
185// Token). Parent is a window or popup. Grab popups take the keyboard and
186// close on a click elsewhere.
187type PopupRequest struct {
188 ID, Parent WindowID
189 Positioner Positioner
190 Grab bool
191 Reposition bool
192 Token uint32
193}
194
195func (PopupRequest) clientEvent() {}
196
197// PopupMapped carries wayland → core a placed popup that now has content.
198// It ends with WindowUnmapped.
199type PopupMapped struct{ ID WindowID }
200
201func (PopupMapped) clientEvent() {}
202
203// Layer is a wlr-layer-shell stacking layer.
204type Layer uint32
205
206const (
207 LayerBackground Layer = iota
208 LayerBottom
209 LayerTop
210 LayerOverlay
211)
212
213// Anchor edges, as in zwlr_layer_surface_v1.anchor.
214const (
215 AnchorTop uint32 = 1
216 AnchorBottom uint32 = 2
217 AnchorLeft uint32 = 4
218 AnchorRight uint32 = 8
219)
220
221// LayerSurface is the committed state of one mapped layer surface. Width and
222// Height are the committed surface size in logical pixels. Margin is top, right, bottom, left.
223// IDs share the WindowID space with windows and never collide.
224type LayerSurface struct {
225 ID WindowID
226 Layer Layer
227 Anchor uint32
228 ExclusiveZone int32
229 Margin [4]int32
230 Width, Height int
231 Namespace string
232 // Keyboard is the requested interactivity: 0 none, 1 exclusive, 2 on-demand.
233 Keyboard uint32
234 // Output is the connector the surface is on.
235 Output string
236}
237
238// LayerChanged carries wayland → core the full list of mapped layer surfaces,
239// sent whenever a layer surface maps, unmaps or commits new layer state.
240type LayerChanged struct{ Layers []LayerSurface }
241
242func (LayerChanged) clientEvent() {}
243
244// ConstraintMode is how a pointer constraint holds the pointer.
245type ConstraintMode uint8
246
247const (
248 ConstraintNone ConstraintMode = iota
249 // ConstraintLock keeps the pointer still: only relative motion flows.
250 ConstraintLock
251 // ConstraintConfine keeps the pointer inside Rect.
252 ConstraintConfine
253)
254
255// PointerConstraint is an active pointer constraint. Rect is logical: in
256// PointerConstrained it is window-local and empty means the whole window;
257// core sends input the resolved global rectangle, and in X, Y its cursor
258// position, where input holds a locked pointer. Warp moves input's
259// pointer to X, Y whatever the mode (wp_pointer_warp_v1).
260type PointerConstraint struct {
261 Mode ConstraintMode
262 Rect Rect
263 X, Y float64
264 Warp bool
265}
266
267// Clamp keeps a global point inside the rectangle of a lock or confine;
268// no constraint and an empty rectangle leave it unchanged.
269func (c PointerConstraint) Clamp(x, y float64) (float64, float64) {
270 if c.Mode == ConstraintNone || c.Rect.W <= 0 || c.Rect.H <= 0 {
271 return x, y
272 }
273 x = min(max(x, float64(c.Rect.X)), float64(c.Rect.X+c.Rect.W-1))
274 y = min(max(y, float64(c.Rect.Y)), float64(c.Rect.Y+c.Rect.H-1))
275 return x, y
276}
277
278// PointerConstrained carries wayland → core the constraint active on a
279// window (zwp_pointer_constraints_v1); ID 0 means none is active. A
280// constraint is active only on the window with both pointer and keyboard
281// focus.
282type PointerConstrained struct {
283 ID WindowID
284 PointerConstraint
285}
286
287func (PointerConstrained) clientEvent() {}
288
289// PointerWarp carries wayland → core a client's request to move the
290// pointer to X, Y, window-local logical (wp_pointer_warp_v1). Wayland has
291// checked that the window has the pointer and the point is on it.
292type PointerWarp struct {
293 ID WindowID
294 X, Y float64
295}
296
297func (PointerWarp) clientEvent() {}