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 // Transform is nil to leave the transform unchanged.
57 Transform *BufferTransform
58}
59
60// OutputApply asks the app owner to validate or apply a runtime configuration.
61type OutputApply struct {
62 ID uint64
63 Test bool
64 Heads []HeadChange
65}
66
67// OutputApplied reports completion (or failure) of a runtime configuration.
68type OutputApplied struct {
69 ID uint64
70 Err error
71}
72
73// OutputAdded carries output → core a new display, or a new mode for a known
74// connector.
75type OutputAdded struct{ Info OutputInfo }
76
77func (OutputAdded) outputEvent() {}
78
79// OutputPresented carries output → wayland what an output shows and reads.
80// Flip is set when a page flip completed: frame callbacks of the surfaces
81// on it are due. Shown and Queued are the DMABuf IDs scanned out directly
82// (0: a composed image); Seen is the latest content Seq per window the
83// output finished reading (the GPU is done with it). A replaced client
84// buffer is released once every output that reports has seen a later
85// content of its window and neither shows nor queues it.
86type OutputPresented struct {
87 Output string
88 Flip *FlipInfo
89 Shown, Queued uint64
90 Seen map[WindowID]uint64
91 // ChildReads is the oldest content Seq per window still read by a child
92 // renderer on a separate device. Unlike Seen, these holds never time out:
93 // they end only with a completed render or device shutdown.
94 ChildReads map[WindowID]uint64
95}
96
97// OutputFormats carries output → wayland the dmabuf formats an output can
98// scan out directly (its primary plane's, that the renderer also samples,
99// so a refused buffer can still be composed). Device is the KMS device
100// (dev_t) clients allocate scanout buffers for. Sent after every successful
101// modeset, including startup and VT resume; empty Formats means no direct
102// scanout. HDR is non-nil only when the output's HDR10 modeset succeeded;
103// nil means SDR, regardless of the monitor's HDR capability.
104type OutputFormats struct {
105 Output string
106 Device uint64
107 Formats []DMABufFormat
108 HDR *OutputHDR
109}
110
111// OutputHDR carries the active HDR10 output's EDID luminances in nits.
112// These describe the display, not any client's content metadata.
113type OutputHDR struct {
114 MaxLuminance, MaxFrameAverage, MinLuminance float64
115}
116
117// FlipInfo is one completed page flip. When is its CLOCK_MONOTONIC time
118// (hardware clock on DRM), Seq the output's vblank counter, Refresh the
119// refresh period (0 while variable refresh is on). ZeroCopy is the window
120// whose buffer was shown without composition (direct scanout or overlay
121// plane; 0: none), Async set for a tearing flip.
122// Shows is the content Seq per window the flipped frame shows. Merged
123// counts earlier flips folded into this one when the reader fell behind:
124// their presentation feedback is discarded.
125type FlipInfo struct {
126 When time.Duration
127 Seq uint64
128 Refresh time.Duration
129 ZeroCopy WindowID
130 Async bool
131 HardwareClock bool
132 Merged int
133 Shows map[WindowID]uint64
134}
135
136// OutputFrame carries output → core a completed page flip: the next frame
137// of a running animation is due.
138type OutputFrame struct{ Output string }
139
140// OutputRemoved carries output → core an unplugged display.
141type OutputRemoved struct{ Name string }
142
143func (OutputRemoved) outputEvent() {}
144
145// ConfigChanged carries config → core reloads.
146type ConfigChanged struct{ Config Config }
147
148// ScaleChanged carries core → persistence a scale set by a scale bind.
149type ScaleChanged struct {
150 Output string
151 Scale float64
152}