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