1package ports
2
3import (
4 "image"
5 "time"
6)
7
8// DefaultSDRBrightness is the BT.2408 SDR reference white in HDR, in nits.
9const DefaultSDRBrightness = 203
10
11// OutputConfig configures one connector. Name is the connector (e.g. "DP-2").
12// Mode is "WxH" (highest refresh) or "WxH@Hz" (closest refresh); empty picks the
13// monitor's preferred mode. Off disables the connector.
14// Every connected output that is not off is used.
15// Placement, by precedence: Pos (set at runtime by wlr-output-management),
16// then Anchor against another connected output, then automatic: right of
17// everything placed so far (never left of 0), at y=0, in config order, then in
18// connection order.
19// Scale is the output scale (0 means 1); layout works in logical pixels,
20// physical = logical × Scale. Placement and offsets use the transformed
21// logical size.
22// Primary gets the focus and the pointer at startup, wherever it is placed.
23// ScaleOnly marks an entry set only by output.<name> subkeys: it
24// does not select the connector.
25type OutputConfig struct {
26 Name string
27 Mode string
28 Off bool
29 Scale float64
30 // Transform is output.<name>.transform; logical size swaps for 90/270.
31 Transform BufferTransform
32 // Pos is an explicit logical placement set at runtime; nil uses Anchor, else automatic layout.
33 Pos *image.Point
34 // Anchor places the output against another connected one.
35 Anchor OutputAnchor // RelationNone: automatic
36 Primary bool
37 HDR bool // opt-in to HDR10 on capable outputs
38 SDRBrightness int // nits; default DefaultSDRBrightness
39 ScaleOnly bool
40}
41
42// OutputRelation is the side of another output where an output is placed.
43type OutputRelation uint8
44
45const (
46 RelationNone OutputRelation = iota
47 RelationRightOf
48 RelationLeftOf
49 RelationAbove
50 RelationBelow
51)
52
53// OutputAnchor places an output against another connected one, named by To.
54// Offset is in logical pixels, along the shared edge: y for right-of and
55// left-of (positive is down), x for above and below (positive is right).
56type OutputAnchor struct {
57 Relation OutputRelation
58 To string
59 Offset int
60}
61
62// LayoutRules are the layout settings shared by the defaults, screens and
63// named workspaces. Zero MaxColumns and an empty Overflow inherit.
64type LayoutRules struct {
65 // MaxColumns is how many columns share the screen at once.
66 MaxColumns int
67 // Overflow is "scroll" (further columns scroll) or "fixed" (they split
68 // the last one).
69 Overflow string
70}
71
72// Over fills the unset rules of r from base.
73func (r LayoutRules) Over(base LayoutRules) LayoutRules {
74 if r.MaxColumns == 0 {
75 r.MaxColumns = base.MaxColumns
76 }
77 if r.Overflow == "" {
78 r.Overflow = base.Overflow
79 }
80 return r
81}
82
83// OutputLayout is the layout of one screen, matched by connector (DP-2) or
84// monitor key.
85type OutputLayout struct {
86 Output string
87 LayoutRules
88}
89
90// Focus indicator: the animation (Config.Focus.Animation) shapes in time
91// the visual effect (Config.Focus.Effect) drawn on a newly focused window.
92const (
93 FocusAnimationOff = "off"
94 FocusAnimationPulse = "pulse"
95 FocusEffectScreen = "screen"
96)
97
98// Config is the parsed compositor configuration (see the config adapter for keys).
99type Config struct {
100 Keyboard struct {
101 Layout, Variant, Options string
102 RepeatRate int
103 RepeatDelay int
104 CmdKey string
105 }
106 Terminal struct {
107 Command []string
108 AutoOpen string
109 }
110 // Xwayland is the xwayland-satellite binary serving X11 clients; empty
111 // disables X11.
112 Xwayland string
113 // Startup are commands run once when the session starts, in order.
114 Startup [][]string
115 Background struct{ Color string }
116 Floating struct{ Dim float64 }
117 // Stash is the strip of windows set aside by toggle-window-stash:
118 // Width is the width of its selected window (10 to 90) and Gap the
119 // space between it and its neighbors (0 to 10), in percent of the
120 // usable width; Dim darkens the neighbors, 0 to 1. Capture puts new
121 // windows in the stash while it is shown.
122 Stash struct {
123 Width, Gap int
124 Dim float64
125 Capture bool
126 }
127 // Border is drawn inside the window edge; Width 0 disables it.
128 Border struct {
129 Width int
130 Active string
131 Inactive string
132 }
133 Layout struct {
134 Gaps int
135 Presets []string
136 // LayoutRules are the defaults; Outputs override them per screen and
137 // named workspaces override them again.
138 LayoutRules
139 Outputs []OutputLayout
140 }
141 // InputDevicesConfig holds Touchpad and Mouse, promoted.
142 InputDevicesConfig
143 // Cursor.HideAfter hides the pointer cursor after this long without
144 // motion; the next motion shows it. 0 never hides it.
145 Cursor struct{ HideAfter time.Duration }
146 // Animations: On enables motion (off lands everything instantly);
147 // Slowdown scales every spring's duration (not the focus pulse), 0.1 to
148 // 10 (the config's animations.speed maps to it).
149 Animations struct {
150 On bool
151 Slowdown float64
152 }
153 Focus struct {
154 // FollowMove shows the target workspace after a column or window
155 // moves to it.
156 FollowMove bool
157 // Animation and Effect mark a window that just got the focus:
158 // FocusAnimation* (off disables it) and FocusEffect*. Strength is
159 // the effect's peak, 0.01 to 0.2.
160 Animation, Effect string
161 Strength float64
162 }
163 // Workspaces are declared with workspace.<name>.* keys, in first-seen order.
164 Workspaces []WorkspaceConfig
165 // Outputs selects and configures physical displays (drm backend).
166 Outputs []OutputConfig
167 Binds map[string]string
168 Render struct {
169 DirectScanout bool
170 // Tearing honours wp_tearing_control_v1 in direct scanout; VRR
171 // turns variable refresh on while a buffer is scanned out.
172 Tearing, VRR bool
173 // VRRFlipGap is the minimum time between a game frame's flip and
174 // the next frame commit under VRR (0: off). It works around
175 // flips that land at the panel's slowest refresh.
176 VRRFlipGap time.Duration
177 }
178 Performance struct{ Realtime bool }
179 Log struct {
180 Level string
181 Debug []string
182 }
183}
184
185// PointerConfig holds the settings mice and touchpads share. NaturalScroll
186// moves the content with the fingers or the wheel instead of against them.
187// AccelSpeed (-1 to 1) and AccelProfile (AccelAdaptive or AccelFlat) set the
188// pointer speed. LeftHanded swaps the left and right buttons.
189type PointerConfig struct {
190 NaturalScroll bool
191 AccelSpeed float64
192 AccelProfile string
193 LeftHanded bool
194}
195
196// TouchpadConfig configures touchpads: the shared pointer settings
197// (NaturalScroll also applies to two-finger scroll and swipes), plus Tap,
198// which clicks on a tap (one finger left, two right, three middle), and
199// ScrollFactor, which multiplies two-finger scroll.
200type TouchpadConfig struct {
201 PointerConfig
202 Tap bool
203 ScrollFactor float64
204}
205
206// InputDevicesConfig is the live configuration of the input devices, sent to
207// the input adapter as one value. It is comparable.
208type InputDevicesConfig struct {
209 Touchpad TouchpadConfig
210 Mouse PointerConfig
211}
212
213// Pointer acceleration profiles, for mice and touchpads.
214const (
215 AccelAdaptive = "adaptive"
216 AccelFlat = "flat"
217)
218
219// WorkspaceConfig declares a bind-only named workspace, outside the numbered list.
220// Zero MaxColumns and an empty Overflow use the layout.* defaults.
221type WorkspaceConfig struct {
222 Name string
223 // Monitor is the home monitor: a connector name (DP-2) or a monitor key
224 // ("make model serial"); empty follows the focused output when shown.
225 Monitor string
226 // Size overrides the workspace's logical width and height. Zero inherits
227 // the monitor; its scale is always inherited.
228 Size [2]int
229 // Slots are the declared columns (workspace.<name>.column.N), by N.
230 Slots []SlotConfig
231 LayoutRules
232}
233
234// SlotConfig reserves column N of a workspace for the window of one command.
235// neferwl spawns the command at startup; the window it opens goes to the
236// slot. Width is a layout width (fraction, percentage or pixels).
237type SlotConfig struct {
238 Index int
239 Width string
240 Argv []string
241}