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 Focus struct {
147 // FollowMove shows the target workspace after a column or window
148 // moves to it.
149 FollowMove bool
150 // Animation and Effect mark a window that just got the focus:
151 // FocusAnimation* (off disables it) and FocusEffect*. Strength is
152 // the effect's peak, 0.01 to 0.2.
153 Animation, Effect string
154 Strength float64
155 }
156 // Workspaces are declared with workspace.<name>.* keys, in first-seen order.
157 Workspaces []WorkspaceConfig
158 // Outputs selects and configures physical displays (drm backend).
159 Outputs []OutputConfig
160 Binds map[string]string
161 Render struct {
162 DirectScanout bool
163 // Tearing honours wp_tearing_control_v1 in direct scanout; VRR
164 // turns variable refresh on while a buffer is scanned out.
165 Tearing, VRR bool
166 // VRRFlipGap is the minimum time between a game frame's flip and
167 // the next frame commit under VRR (0: off). It works around
168 // flips that land at the panel's slowest refresh.
169 VRRFlipGap time.Duration
170 }
171 Performance struct{ Realtime bool }
172 Log struct {
173 Level string
174 Debug []string
175 }
176}
177
178// PointerConfig holds the settings mice and touchpads share. NaturalScroll
179// moves the content with the fingers or the wheel instead of against them.
180// AccelSpeed (-1 to 1) and AccelProfile (AccelAdaptive or AccelFlat) set the
181// pointer speed. LeftHanded swaps the left and right buttons.
182type PointerConfig struct {
183 NaturalScroll bool
184 AccelSpeed float64
185 AccelProfile string
186 LeftHanded bool
187}
188
189// TouchpadConfig configures touchpads: the shared pointer settings
190// (NaturalScroll also applies to two-finger scroll and swipes), plus Tap,
191// which clicks on a tap (one finger left, two right, three middle), and
192// ScrollFactor, which multiplies two-finger scroll.
193type TouchpadConfig struct {
194 PointerConfig
195 Tap bool
196 ScrollFactor float64
197}
198
199// InputDevicesConfig is the live configuration of the input devices, sent to
200// the input adapter as one value. It is comparable.
201type InputDevicesConfig struct {
202 Touchpad TouchpadConfig
203 Mouse PointerConfig
204}
205
206// Pointer acceleration profiles, for mice and touchpads.
207const (
208 AccelAdaptive = "adaptive"
209 AccelFlat = "flat"
210)
211
212// WorkspaceConfig declares a bind-only named workspace, outside the numbered list.
213// Zero MaxColumns and an empty Overflow use the layout.* defaults.
214type WorkspaceConfig struct {
215 Name string
216 // Monitor is the home monitor: a connector name (DP-2) or a monitor key
217 // ("make model serial"); empty follows the focused output when shown.
218 Monitor string
219 // Size overrides the workspace's logical width and height. Zero inherits
220 // the monitor; its scale is always inherited.
221 Size [2]int
222 // Slots are the declared columns (workspace.<name>.column.N), by N.
223 Slots []SlotConfig
224 LayoutRules
225}
226
227// SlotConfig reserves column N of a workspace for the window of one command.
228// neferwl spawns the command at startup; the window it opens goes to the
229// slot. Width is a layout width (fraction, percentage or pixels).
230type SlotConfig struct {
231 Index int
232 Width string
233 Argv []string
234}