output_events.go RawHistoryFolder
1package ports
2
3import (
4 "image"
5 "time"
6)
7
8// OutputEvent carries output → core notifications.
9type OutputEvent interface{ outputEvent() }
10
11// OutputInfo describes a connected display. Sizes are physical pixels.
12type OutputInfo struct {
13 // Name is the connector (e.g. DP-2), matched against output.<name>.* config.
14 Name string
15 // Make, Model and Serial come from EDID; empty when unknown.
16 Make, Model, Serial string
17 Width, Height int
18 RefreshMilli int
19 PhysicalW, PhysicalH int // millimetres
20}
21
22// Key identifies the monitor across connectors: make, model and serial, or
23// the connector name when EDID has no serial.
24func (i OutputInfo) Key() string {
25 if i.Serial == "" {
26 return i.Name
27 }
28 return i.Make + " " + i.Model + " " + i.Serial
29}
30
31// OutputMode describes a connected connector's physical mode.
32type OutputMode struct {
33 Width, Height, RefreshMilli int
34 Preferred bool
35}
36
37// OutputHead describes a connected connector even when it is disabled.
38// Current is the active mode; it is nil for disabled or not-yet-running heads.
39type OutputHead struct {
40 Info OutputInfo
41 Modes []OutputMode
42 Current *OutputMode
43 Enabled bool
44}
45
46// OutputHeads is a complete backend inventory, delivered to Wayland after a scan.
47type OutputHeads struct{ Heads []OutputHead }
48
49// HeadChange is the complete desired state of one head in a configuration.
50type HeadChange struct {
51 Name string
52 Enabled bool
53 Mode *OutputMode
54 Pos *image.Point
55 Scale float64
56}
57
58// OutputApply asks the app owner to validate or apply a runtime configuration.
59type OutputApply struct {
60 ID uint64
61 Test bool
62 Heads []HeadChange
63}
64
65// OutputApplied reports completion (or failure) of a runtime configuration.
66type OutputApplied struct {
67 ID uint64
68 Err error
69}
70
71// OutputAdded carries output → core a new display, or a new mode for a known
72// connector.
73type OutputAdded struct{ Info OutputInfo }
74
75func (OutputAdded) outputEvent() {}
76
77// OutputPresented carries output → wayland what an output shows and reads.
78// Flip is set when a page flip completed: frame callbacks of the surfaces
79// on it are due. Shown and Queued are the DMABuf IDs scanned out directly
80// (0: a composed image); Seen is the latest content Seq per window the
81// output finished reading (the GPU is done with it). A replaced client
82// buffer is released once every output that reports has seen a later
83// content of its window and neither shows nor queues it.
84type OutputPresented struct {
85 Output string
86 Flip *FlipInfo
87 Shown, Queued uint64
88 Seen map[WindowID]uint64
89 // ChildReads is the oldest content Seq per window still read by a child
90 // renderer on a separate device. Unlike Seen, these holds never time out:
91 // they end only with a completed render or device shutdown.
92 ChildReads map[WindowID]uint64
93}
94
95// OutputFormats carries output → wayland the dmabuf formats an output can
96// scan out directly (its primary plane's, that the renderer also samples,
97// so a refused buffer can still be composed). Device is the KMS device
98// (dev_t) clients allocate scanout buffers for. Sent after every successful
99// modeset, including startup and VT resume; empty Formats means no direct
100// scanout. HDR is non-nil only when the output's HDR10 modeset succeeded;
101// nil means SDR, regardless of the monitor's HDR capability.
102type OutputFormats struct {
103 Output string
104 Device uint64
105 Formats []DMABufFormat
106 HDR *OutputHDR
107}
108
109// OutputHDR carries the active HDR10 output's EDID luminances in nits.
110// These describe the display, not any client's content metadata.
111type OutputHDR struct {
112 MaxLuminance, MaxFrameAverage, MinLuminance float64
113}
114
115// FlipInfo is one completed page flip. When is its CLOCK_MONOTONIC time
116// (hardware clock on DRM), Seq the output's vblank counter, Refresh the
117// refresh period (0 while variable refresh is on). ZeroCopy is the window
118// whose buffer was shown without composition (direct scanout or overlay
119// plane; 0: none), Async set for a tearing flip.
120// Shows is the content Seq per window the flipped frame shows. Merged
121// counts earlier flips folded into this one when the reader fell behind:
122// their presentation feedback is discarded.
123type FlipInfo struct {
124 When time.Duration
125 Seq uint64
126 Refresh time.Duration
127 ZeroCopy WindowID
128 Async bool
129 HardwareClock bool
130 Merged int
131 Shows map[WindowID]uint64
132}
133
134// OutputFrame carries output → core a completed page flip: the next frame
135// of a running animation is due.
136type OutputFrame struct{ Output string }
137
138// OutputRemoved carries output → core an unplugged display.
139type OutputRemoved struct{ Name string }
140
141func (OutputRemoved) outputEvent() {}
142
143// ConfigChanged carries config → core reloads.
144type ConfigChanged struct{ Config Config }
145
146// ScaleChanged carries core → persistence a scale set by a scale bind.
147type ScaleChanged struct {
148 Output string
149 Scale float64
150}