1package ports
2
3import (
4 "os"
5 "time"
6)
7
8// ClientEvent carries wayland → core notifications.
9type ClientEvent interface{ clientEvent() }
10
11// WindowMapped carries wayland → core mapping.
12type WindowMapped struct {
13 ID WindowID
14 AppID string
15 // Slot is the SlotEnv value of the client process, empty if none.
16 Slot string
17 // PID is the client process, 0 when unknown.
18 PID int
19 // Floating windows are dialogs (a parent) or fixed-size windows such
20 // as splash screens: core shows them over the columns at their own
21 // size, Width×Height logical (0 when unknown).
22 Floating bool
23 Width, Height int
24}
25
26// SlotEnv is the environment variable neferwl sets on processes it spawns
27// for a slot. The client's value maps its windows to the slot.
28const SlotEnv = "NEFERWL_SLOT"
29
30func (WindowMapped) clientEvent() {}
31
32// WindowUnmapped carries wayland → core removal.
33type WindowUnmapped struct{ ID WindowID }
34
35func (WindowUnmapped) clientEvent() {}
36
37// ShortcutsInhibit carries wayland → core that a window asks for (Active)
38// or stops asking for all keys, compositor binds included, while it has
39// keyboard focus (zwp_keyboard_shortcuts_inhibit_v1).
40type ShortcutsInhibit struct {
41 Window WindowID
42 Active bool
43}
44
45func (ShortcutsInhibit) clientEvent() {}
46
47// IdleInhibit carries wayland → core that a window keeps (Active) or
48// stops keeping the session from going idle (zwp_idle_inhibit_v1).
49type IdleInhibit struct {
50 Window WindowID
51 Active bool
52}
53
54func (IdleInhibit) clientEvent() {}
55
56// WindowFullscreenRequest carries wayland → core fullscreen requests.
57type WindowFullscreenRequest struct {
58 ID WindowID
59 Fullscreen bool
60}
61
62func (WindowFullscreenRequest) clientEvent() {}
63
64// WindowActivate carries wayland → core a valid xdg-activation request:
65// show the window's workspace and focus it.
66type WindowActivate struct{ ID WindowID }
67
68func (WindowActivate) clientEvent() {}
69
70// WindowAppID carries wayland → core an app ID set after the window mapped.
71type WindowAppID struct {
72 ID WindowID
73 AppID string
74}
75
76func (WindowAppID) clientEvent() {}
77
78// WindowResized carries wayland → core the new size of a floating window.
79type WindowResized struct {
80 ID WindowID
81 Width, Height int
82}
83
84func (WindowResized) clientEvent() {}
85
86// Popup anchors and gravities, as xdg_positioner values.
87const (
88 EdgeNone uint32 = iota
89 EdgeTop
90 EdgeBottom
91 EdgeLeft
92 EdgeRight
93 EdgeTopLeft
94 EdgeBottomLeft
95 EdgeTopRight
96 EdgeBottomRight
97)
98
99// Popup constraint adjustments, as xdg_positioner values.
100const (
101 AdjustSlideX uint32 = 1 << iota
102 AdjustSlideY
103 AdjustFlipX
104 AdjustFlipY
105 AdjustResizeX
106 AdjustResizeY
107)
108
109// Positioner places a popup relative to its parent's window geometry:
110// the Anchor point of AnchorRect, moved by Offset, with the popup extending
111// towards Gravity. Adjust says how core may move it to stay on screen.
112type Positioner struct {
113 Width, Height int
114 AnchorRect Rect
115 Anchor, Gravity uint32
116 OffsetX, OffsetY int
117 Adjust uint32
118}
119
120// PopupRequest carries wayland → core a popup to place (xdg_popup), on
121// its first commit and on reposition (Reposition, with the client's
122// Token). Parent is a window or popup. Grab popups take the keyboard and
123// close on a click elsewhere.
124type PopupRequest struct {
125 ID, Parent WindowID
126 Positioner Positioner
127 Grab bool
128 Reposition bool
129 Token uint32
130}
131
132func (PopupRequest) clientEvent() {}
133
134// PopupMapped carries wayland → core a placed popup that now has content.
135// It ends with WindowUnmapped.
136type PopupMapped struct{ ID WindowID }
137
138func (PopupMapped) clientEvent() {}
139
140// Layer is a wlr-layer-shell stacking layer.
141type Layer uint32
142
143const (
144 LayerBackground Layer = iota
145 LayerBottom
146 LayerTop
147 LayerOverlay
148)
149
150// Anchor edges, as in zwlr_layer_surface_v1.anchor.
151const (
152 AnchorTop uint32 = 1
153 AnchorBottom uint32 = 2
154 AnchorLeft uint32 = 4
155 AnchorRight uint32 = 8
156)
157
158// LayerSurface is the committed state of one mapped layer surface. Width and
159// Height are the committed surface size in logical pixels. Margin is top, right, bottom, left.
160// IDs share the WindowID space with windows and never collide.
161type LayerSurface struct {
162 ID WindowID
163 Layer Layer
164 Anchor uint32
165 ExclusiveZone int32
166 Margin [4]int32
167 Width, Height int
168 Namespace string
169 // Keyboard is the requested interactivity: 0 none, 1 exclusive, 2 on-demand.
170 Keyboard uint32
171 // Output is the connector the surface is on.
172 Output string
173}
174
175// LayerChanged carries wayland → core the full list of mapped layer surfaces,
176// sent whenever a layer surface maps, unmaps or commits new layer state.
177type LayerChanged struct{ Layers []LayerSurface }
178
179func (LayerChanged) clientEvent() {}
180
181// ConstraintMode is how a pointer constraint holds the pointer.
182type ConstraintMode uint8
183
184const (
185 ConstraintNone ConstraintMode = iota
186 // ConstraintLock keeps the pointer still: only relative motion flows.
187 ConstraintLock
188 // ConstraintConfine keeps the pointer inside Rect.
189 ConstraintConfine
190)
191
192// PointerConstraint is an active pointer constraint. Rect is logical: in
193// PointerConstrained it is window-local and empty means the whole window;
194// core sends input the resolved global rectangle, and in X, Y its cursor
195// position, where input holds a locked pointer.
196type PointerConstraint struct {
197 Mode ConstraintMode
198 Rect Rect
199 X, Y float64
200}
201
202// Clamp keeps a global point inside the rectangle of a lock or confine;
203// no constraint and an empty rectangle leave it unchanged.
204func (c PointerConstraint) Clamp(x, y float64) (float64, float64) {
205 if c.Mode == ConstraintNone || c.Rect.W <= 0 || c.Rect.H <= 0 {
206 return x, y
207 }
208 x = min(max(x, float64(c.Rect.X)), float64(c.Rect.X+c.Rect.W-1))
209 y = min(max(y, float64(c.Rect.Y)), float64(c.Rect.Y+c.Rect.H-1))
210 return x, y
211}
212
213// PointerConstrained carries wayland → core the constraint active on a
214// window (zwp_pointer_constraints_v1); ID 0 means none is active. A
215// constraint is active only on the window with both pointer and keyboard
216// focus.
217type PointerConstrained struct {
218 ID WindowID
219 PointerConstraint
220}
221
222func (PointerConstrained) clientEvent() {}
223
224// Mods carries input → core modifier flags.
225type Mods uint8
226
227const (
228 ModShift Mods = 1 << iota
229 ModCtrl
230 ModAlt
231 ModSuper
232)
233
234// InputEvent carries input → core notifications.
235type InputEvent interface{ inputEvent() }
236
237// KeyEvent carries input → core key transitions; Keysym is an xkb keysym name.
238// Keycode is the evdev code (xkb keycode - 8) and State the xkb modifier state
239// after this transition; wayland forwards both to clients unchanged.
240type KeyEvent struct {
241 Keysym string
242 // Base is the key's unshifted keysym in the active layout, so Cmd+Shift+1
243 // still matches a cmd+shift+1 bind although it prints exclam.
244 Base string
245 Mods Mods
246 Pressed bool
247 TimeMsec uint32
248 Keycode uint32
249 State ModState
250}
251
252// ModState is the serialized xkb modifier state sent in wl_keyboard.modifiers.
253type ModState struct{ Depressed, Latched, Locked, Group uint32 }
254
255func (KeyEvent) inputEvent() {}
256
257// PointerMotion uses global layout coordinates in logical pixels (see OutputPlacement).
258// DX and DY are the accelerated logical deltas and UnaccelDX, UnaccelDY the
259// raw device deltas; all four are 0 for absolute devices. TimeUsec is the
260// device timestamp in microseconds.
261type PointerMotion struct {
262 X, Y float64
263 DX, DY float64
264 UnaccelDX, UnaccelDY float64
265 TimeMsec uint32
266 TimeUsec uint64
267}
268
269func (PointerMotion) inputEvent() {}
270
271// PointerButton uses evdev button codes (BTN_LEFT is 0x110).
272type PointerButton struct {
273 Button uint32
274 Pressed bool
275 TimeMsec uint32
276}
277
278func (PointerButton) inputEvent() {}
279
280// AxisSource tells how a scroll was made; values match wl_pointer.axis_source.
281type AxisSource uint8
282
283const (
284 AxisWheel AxisSource = iota
285 AxisFinger
286 AxisContinuous
287)
288
289// ScrollAxis is one scroll direction in a pointer frame. Value is in
290// surface pixels; V120 counts wheel detents in 1/120 steps (wheel only).
291// Stop ends a finger or continuous scroll on this axis.
292type ScrollAxis struct {
293 Set bool
294 Value float64
295 V120 int32
296 Stop bool
297}
298
299// PointerAxis is one scroll frame: Vertical, then Horizontal.
300type PointerAxis struct {
301 Source AxisSource
302 Vertical, Horizontal ScrollAxis
303 TimeMsec uint32
304}
305
306func (PointerAxis) inputEvent() {}
307
308// OutputEvent carries output → core notifications.
309type OutputEvent interface{ outputEvent() }
310
311// OutputInfo describes a connected display. Sizes are physical pixels.
312type OutputInfo struct {
313 // Name is the connector (e.g. DP-2), matched against output.<name>.* config.
314 Name string
315 // Make, Model and Serial come from EDID; empty when unknown.
316 Make, Model, Serial string
317 Width, Height int
318 RefreshMilli int
319 PhysicalW, PhysicalH int // millimetres
320}
321
322// Key identifies the monitor across connectors: make, model and serial, or
323// the connector name when EDID has no serial.
324func (i OutputInfo) Key() string {
325 if i.Serial == "" {
326 return i.Name
327 }
328 return i.Make + " " + i.Model + " " + i.Serial
329}
330
331// OutputAdded carries output → core a new display, or a new mode for a known
332// connector.
333type OutputAdded struct{ Info OutputInfo }
334
335func (OutputAdded) outputEvent() {}
336
337// OutputPresented carries output → wayland what an output shows and reads.
338// Flip is set when a page flip completed: frame callbacks of the surfaces
339// on it are due. Shown and Queued are the DMABuf IDs scanned out directly
340// (0: a composed image); Seen is the latest content Seq per window the
341// output finished reading (the GPU is done with it). A replaced client
342// buffer is released once every output that reports has seen a later
343// content of its window and neither shows nor queues it.
344type OutputPresented struct {
345 Output string
346 Flip *FlipInfo
347 Shown, Queued uint64
348 Seen map[WindowID]uint64
349}
350
351// OutputFormats carries output → wayland the dmabuf formats an output can
352// scan out directly (its primary plane's, that the renderer also samples,
353// so a refused buffer can still be composed). Device is the KMS device
354// (dev_t) clients allocate scanout buffers for. Sent at start and after
355// every modeset; empty Formats means no direct scanout.
356type OutputFormats struct {
357 Output string
358 Device uint64
359 Formats []DMABufFormat
360}
361
362// FlipInfo is one completed page flip. When is its CLOCK_MONOTONIC time
363// (hardware clock on DRM), Seq the output's vblank counter, Refresh the
364// refresh period (0 while variable refresh is on). ZeroCopy is the window
365// whose buffer was shown without composition (direct scanout or overlay
366// plane; 0: none), Async set for a tearing flip.
367// Shows is the content Seq per window the flipped frame shows. Merged
368// counts earlier flips folded into this one when the reader fell behind:
369// their presentation feedback is discarded.
370type FlipInfo struct {
371 When time.Duration
372 Seq uint64
373 Refresh time.Duration
374 ZeroCopy WindowID
375 Async bool
376 HardwareClock bool
377 Merged int
378 Shows map[WindowID]uint64
379}
380
381// OutputRemoved carries output → core an unplugged display.
382type OutputRemoved struct{ Name string }
383
384func (OutputRemoved) outputEvent() {}
385
386// ConfigChanged carries config → core reloads.
387type ConfigChanged struct{ Config Config }
388
389// ClientCommand carries core → wayland commands.
390type ClientCommand interface{ clientCommand() }
391
392// ShortcutsInhibitState carries core → wayland whether a window's
393// shortcuts inhibitor is in effect (it has keyboard focus).
394type ShortcutsInhibitState struct {
395 Window WindowID
396 Active bool
397}
398
399func (ShortcutsInhibitState) clientCommand() {}
400
401// ConfigureWindow carries core → wayland geometry and state. Output is the
402// connector showing the window, empty while it is hidden.
403type ConfigureWindow struct {
404 ID WindowID
405 Width, Height int
406 Fullscreen, Activated bool
407 // Floating windows are not tiled: no tiled states.
408 Floating bool
409 Output string
410}
411
412func (ConfigureWindow) clientCommand() {}
413
414// OutputPlacement is one output in the global layout. X, Y, Width and
415// Height are logical; physical = logical × Scale.
416type OutputPlacement struct {
417 Info OutputInfo
418 X, Y, Width, Height int
419 Scale float64
420 // Primary is output.<name>.primary: the pointer starts on it.
421 Primary bool
422}
423
424// Contains reports whether the logical point is on the output.
425func (o OutputPlacement) Contains(x, y float64) bool {
426 return x >= float64(o.X) && x < float64(o.X+o.Width) && y >= float64(o.Y) && y < float64(o.Y+o.Height)
427}
428
429// Layout is the global arrangement of outputs, left to right.
430type Layout []OutputPlacement
431
432// At returns the output under the logical point.
433func (l Layout) At(x, y float64) (OutputPlacement, bool) {
434 for _, o := range l {
435 if o.Contains(x, y) {
436 return o, true
437 }
438 }
439 return OutputPlacement{}, false
440}
441
442// Clamp keeps the pointer on an output: a point outside every output stays
443// on the output under (fromX, fromY), or the first one, clamped to its edges.
444func (l Layout) Clamp(fromX, fromY, x, y float64) (float64, float64) {
445 if len(l) == 0 {
446 return x, y
447 }
448 if _, ok := l.At(x, y); ok {
449 return x, y
450 }
451 o, ok := l.At(fromX, fromY)
452 if !ok {
453 o = l[0]
454 }
455 x = min(max(x, float64(o.X)), float64(o.X+o.Width)-1)
456 y = min(max(y, float64(o.Y)), float64(o.Y+o.Height)-1)
457 return x, y
458}
459
460// SetOutputs carries core → wayland every output and the focused one (where
461// new surfaces start). It is sent when the list, a placement or the focus changes.
462type SetOutputs struct {
463 Outputs Layout
464 Focused string
465}
466
467func (SetOutputs) clientCommand() {}
468
469// SlotsPending tells wayland whether a slot waits for its window. Only then
470// does it read the SlotEnv of mapping clients.
471type SlotsPending struct{ Pending bool }
472
473func (SlotsPending) clientCommand() {}
474
475// CloseWindow carries core → wayland close requests.
476type CloseWindow struct{ ID WindowID }
477
478func (CloseWindow) clientCommand() {}
479
480// FocusWindow carries core → wayland keyboard focus (0 means none).
481type FocusWindow struct{ ID WindowID }
482
483func (FocusWindow) clientCommand() {}
484
485// ConfigurePopup carries core → wayland a popup's place, relative to its
486// parent's window geometry. Reposition answers a reposition request.
487type ConfigurePopup struct {
488 ID WindowID
489 Rect Rect
490 Reposition bool
491 Token uint32
492}
493
494func (ConfigurePopup) clientCommand() {}
495
496// ClosePopup carries core → wayland a popup to dismiss (popup_done).
497type ClosePopup struct{ ID WindowID }
498
499func (ClosePopup) clientCommand() {}
500
501// PointerFocus changes the pointer surface; ID 0 clears focus. Coordinates are surface-local.
502type PointerFocus struct {
503 ID WindowID
504 X, Y float64
505}
506
507func (PointerFocus) clientCommand() {}
508
509// PointerMotionTo carries core → wayland motion for the pointer focus, in
510// window coordinates. The deltas and TimeUsec feed zwp_relative_pointer_v1;
511// While the window locks the pointer, wayland sends only relative motion.
512type PointerMotionTo struct {
513 ID WindowID
514 X, Y float64
515 DX, DY float64
516 UnaccelDX, UnaccelDY float64
517 TimeMsec uint32
518 TimeUsec uint64
519}
520
521func (PointerMotionTo) clientCommand() {}
522
523type PointerButtonTo struct {
524 ID WindowID
525 Button uint32
526 Pressed bool
527 TimeMsec uint32
528}
529
530func (PointerButtonTo) clientCommand() {}
531
532// PointerAxisTo sends a scroll frame to a window.
533type PointerAxisTo struct {
534 ID WindowID
535 Axis PointerAxis
536}
537
538func (PointerAxisTo) clientCommand() {}
539
540// ForwardKey carries core → wayland unbound keys.
541type ForwardKey struct {
542 ID WindowID
543 Key KeyEvent
544}
545
546func (ForwardKey) clientCommand() {}
547
548// SetKeymap carries app → wayland repeat info and, unless Keymap is empty, a new
549// xkb keymap in text format.
550type SetKeymap struct {
551 Keymap string
552 RepeatRate, RepeatDelay int
553}
554
555func (SetKeymap) clientCommand() {}
556
557// CursorImage is a cursor frame in premultiplied B8G8R8A8, W*4 bytes per
558// row; (HotX, HotY) is the click point. Sizes are physical pixels.
559type CursorImage struct {
560 W, H, HotX, HotY int
561 Pixels []byte
562}
563
564// CursorChange carries wayland → outputs the cursor the focused client asks
565// for: a CSS cursor name (wp_cursor_shape_v1), its own image, or none.
566// The zero value is the default arrow.
567type CursorChange struct {
568 // Shape is a CSS cursor name such as "pointer" or "text".
569 Shape string
570 // Image is a client cursor at Scale buffer pixels per logical pixel.
571 Image *CursorImage
572 Scale int
573 Hidden bool
574}
575
576// SpawnRequest carries core → launcher process arguments.
577type SpawnRequest struct {
578 Argv []string
579 // Env adds KEY=value entries to the child environment.
580 Env []string
581}
582
583// Scene carries core → renderer immutable snapshots with fresh Windows slices,
584// one per output. Rects and the output size are logical and local to the
585// output; the renderer multiplies by Scale.
586type Scene struct {
587 Output string
588 Seq uint64
589 OutputWidth, OutputHeight int
590 Scale float64
591 Background string
592 Border Border
593 Windows []SceneWindow
594 // Separators are the lines between windows, drawn in slice order with
595 // the Border colors: tile lines over the tiles, under the floats; a
596 // float's border right after the float.
597 Separators []Separator
598 // Layers are drawn in slice order: background and bottom before windows,
599 // top and overlay after. A fullscreen window covers bottom and top.
600 // Window popups are drawn after the windows, layer popups
601 // (SceneWindow.OverLayers) last, over every layer.
602 Layers []SceneLayer
603}
604
605// Shows reports whether the scene draws the surface of id: only its
606// content changes need a new frame.
607func (s Scene) Shows(id WindowID) bool {
608 for _, w := range s.Windows {
609 if w.ID == id && !w.Hidden {
610 return true
611 }
612 }
613 for _, l := range s.Layers {
614 if l.ID == id {
615 return true
616 }
617 }
618 return false
619}
620
621// Border carries the window border style; colors are #rrggbb, "" skips
622// drawing. Width is in logical pixels.
623type Border struct {
624 Width int
625 Active, Inactive string
626}
627
628// Separator is a line between windows, in logical pixels. Active lines
629// mark the focused window and use Border.Active, others Border.Inactive.
630// Window is the float whose border it is; 0 for lines between tiles.
631type Separator struct {
632 Rect Rect
633 Active bool
634 Window WindowID
635}
636
637// SceneLayer carries core → renderer layer surface placement.
638type SceneLayer struct {
639 ID WindowID
640 Layer Layer
641 Rect Rect
642}
643
644// SurfaceContent carries wayland → output the latest committed content of a
645// window: SHM, a client shared-memory buffer, or DMABuf, a GPU buffer.
646// Renderers read both in place and never modify them. Empty means the window
647// has no content. LogicalW and LogicalH are the surface size in logical
648// pixels (buffer scale and viewport applied). Subsurfaces come in Children;
649// Geometry is the part of the surface that is the window (xdg window
650// geometry), the rest being client shadows.
651type SurfaceContent struct {
652 ID WindowID
653 // Seq counts the window's contents (wayland sets it), for release.
654 Seq uint64
655 Width, Height int
656 LogicalW, LogicalH int
657 Opaque bool // x formats: ignore the alpha byte
658 SHM *SHMBuffer
659 DMABuf *DMABuf
660 // Children are the subsurfaces, bottom to top, flattened.
661 Children []Subsurface
662 // Geometry is in logical pixels from the surface origin; empty means
663 // the whole surface.
664 Geometry Rect
665 // Async asks for tearing presentation (wp_tearing_control_v1); outputs
666 // honour it only in direct scanout.
667 Async bool
668 // Acquire is the explicit-sync fence of this content's root buffer
669 // (wp_linux_drm_syncobj_v1): readers wait on it before reading the
670 // buffer, instead of the buffer's implicit fences. Wayland owns it and
671 // closes it when the buffer is released; a reader that keeps it past
672 // the call duplicates it under Acquire.SyscallConn. nil: implicit sync.
673 // Wayland closes it only after every output reported a later content of
674 // the window as seen, so a reader never gets it already closed.
675 Acquire *os.File
676 // DamageHistory is what changed in the root surface's buffer over the
677 // window's last contents, oldest first, ending with this one (Seq).
678 // A renderer holding an older content redraws the union of the
679 // entries after it, or everything when the history does not reach it.
680 DamageHistory []SeqDamage
681}
682
683// SeqDamage is what content Seq changed from the one before: Rects in
684// root buffer pixels, or everything when Full.
685type SeqDamage struct {
686 Seq uint64
687 Full bool
688 Rects []Rect
689}
690
691// DamageSince is the union of changes after content seq up to this one,
692// and false when the history does not reach back to seq (redraw all).
693func (c SurfaceContent) DamageSince(seq uint64) ([]Rect, bool) {
694 if seq >= c.Seq {
695 return nil, true
696 }
697 h := c.DamageHistory
698 if len(h) == 0 || h[0].Seq > seq+1 || h[len(h)-1].Seq != c.Seq {
699 return nil, false
700 }
701 var out []Rect
702 for _, d := range h {
703 if d.Seq <= seq {
704 continue
705 }
706 if d.Full {
707 return nil, false
708 }
709 out = append(out, d.Rects...)
710 }
711 return out, true
712}
713
714// Subsurface is a child surface at X, Y logical pixels from the root
715// surface origin. Below children are drawn under the root surface.
716type Subsurface struct {
717 X, Y int
718 Below bool
719 SurfaceContent
720}
721
722// Empty reports whether the content has nothing to draw.
723func (c SurfaceContent) Empty() bool {
724 return c.SHM == nil && c.DMABuf == nil && len(c.Children) == 0
725}
726
727// SHMBuffer is a client wl_shm buffer: B8G8R8A8 pixels (argb8888/xrgb8888
728// little-endian) at Offset in the pool File, Stride bytes per row. The
729// client keeps writing the file, so renderers copy from it when they draw.
730// Pool is unique per wl_shm pool for the session: renderers map a pool
731// once. File stays open while the client's buffer exists and follows the
732// DMABuf rules: duplicate it under File.SyscallConn before keeping it. A
733// client may shrink the file at any time, so readers must survive faults.
734type SHMBuffer struct {
735 Pool uint64
736 File *os.File
737 Offset, Stride int
738}
739
740// DMABuf is a client GPU buffer (linux-dmabuf). Its files stay open while
741// the client's buffer exists; a renderer that keeps it must duplicate the
742// descriptors under File.SyscallConn so a concurrent close cannot hand it a
743// reused one. ID is unique per buffer for the whole session: renderers key
744// their imports on it.
745type DMABuf struct {
746 ID uint64
747 Width, Height int
748 Format uint32 // DRM fourcc
749 Modifier uint64
750 Planes []DMABufPlane
751}
752
753// DMABufPlane is one plane of a DMABuf.
754type DMABufPlane struct {
755 File *os.File
756 Offset, Stride uint32
757}
758
759// DMABufFormat is a DRM fourcc with a modifier the renderer can import.
760type DMABufFormat struct {
761 Format uint32
762 Modifier uint64
763}
764
765// DMABufSupport is what the renderer imports: the render device (a dev_t,
766// 0 when unknown) and the formats. No formats means no dmabuf.
767type DMABufSupport struct {
768 Device uint64
769 Formats []DMABufFormat
770}
771
772// SceneWindow carries core → renderer window placement.
773type SceneWindow struct {
774 ID WindowID
775 Rect Rect
776 Focused, Fullscreen, Hidden bool
777 // Inset sides carry a separator line inside Rect: the client is drawn
778 // inside it.
779 Inset Sides
780 // Floating windows are drawn over the tiles and their lines.
781 Floating bool
782 // Popups are drawn from their content only: no border, no background.
783 Popup bool
784 // OverLayers popups hang from a layer surface: drawn over the top and
785 // overlay layers. Window popups stay with the windows, under them.
786 OverLayers bool
787}
788
789// State carries core → state publisher a snapshot of what is on screen, for
790// scripts (bars, status lines). Workspace numbers count from 1.
791type State struct {
792 // Output is the focused output; "" before the first one.
793 Output string
794 Outputs []OutputState
795 // Window is the focused window, nil when none.
796 Window *WindowState
797 Windows []WindowState
798}
799
800// OutputState is one output: its workspace on screen and how many numbered
801// workspaces it has. Active is 0 while a hidden (named) workspace is shown.
802type OutputState struct {
803 Name string
804 Active int
805 Count int
806 Workspace string // name of the workspace on screen, "" if unnamed
807}
808
809// WindowState is one mapped window and where it is.
810type WindowState struct {
811 ID WindowID
812 AppID string
813 PID int
814 Output string
815 // Workspace is the window's numbered workspace, 0 for a hidden one.
816 Workspace int
817 // Visible means on the workspace on screen (it may be behind a
818 // fullscreen window).
819 Visible bool
820 // IdleInhibit is set while the window keeps the session from idling.
821 IdleInhibit bool `json:",omitempty"`
822}