feat/virtual-hdr a44825f

#118 feat: HDR streaming of virtual outputs

state
merged · 2d292c0 · merge commit
branch
feat/virtual-hdr → main
opened
bnema ·
updated

HDR streaming of virtual outputs.

  • Shared domain.OutputHDRSettings for DRM and headless outputs.
  • Virtual outputs accept .hdr, .sdr-brightness and .sdr-expand*; changes apply without removing the screen.
  • wlr-screencopy offers XRGB/ARGB8888 dmabuf buffers, filled on the GPU (opaque alpha), ready after the copy fence.
  • PQ capture (BeginCapturePQ); screencasts of HDR outputs offer xBGR_210LE + BT.2020/PQ first, 8-bit fallback, renegotiated live with SetFormats.
  • Docs: config.md (virtual HDR), capture.md (dmabuf, HDR cast, Sunshine capture = portal).

Checks: make check, make race, make mocks-check, staticcheck; screencast e2e against real PipeWire (pw-dump: xBGR_210LE / smpte2084 / bt2020).

Before merge: purego-pipewire is pinned to a pseudo-version of purego-pipewire!4; merge it, tag v0.4.1, bump go.mod. Not verified yet: real Sunshine + Moonlight HDR on the Shield.

CommitSubjectAuthorDateSignatureStatus
a44825fMerge branch 'feat/cast-dmabuf' into feat/keep-focusbrice GPG Verified
2931d5cbuild(deps): bump purego-pipewire to v0.6.0brice GPG Verified
1bb30c0test(core): strict keep-focus stash and output removal expectationsbrice GPG Verified
fe3c5cftest(app): X11 round-trip barrier before asserting the probe got no keybrice GPG Verified
5012debtest(wayland): X11 focus survives keymap replacement and keyboard resetbrice GPG Verified
a0446e1test(core): keep-focus under lock cycles, stash, overview, fullscreen and output removalbrice GPG Verified
ee73e9bfix(core): resend X11Active after any security epoch changebrice GPG Verified
26be80fdocs(config): document output.<name>.keep-focusbrice GPG Verified
597a2dctest(app): end-to-end keep-focus with Xwaylandbrice GPG Verified
229b4fbfeat(wayland): apply core's X11Active to the XWM focusbrice GPG Verified
e7bca67feat(core): keep an X11 window X11-active on keep-focus outputsbrice GPG Verified
b4444c6feat(config): add output.<name>.keep-focusbrice GPG Verified
9021a52fix(screencast): identify the PipeWire node as a screen castbrice GPG Verified
5009628fix(vulkan): fail closed when cast buffer sync cannot be establishedbrice GPG Verified
3ca339bdocs(capture): screencasts are DMA-BUF onlybrice GPG Verified
6a57469test(screencast): expect DMA-BUF PQ buffers in the HDR cast e2ebrice GPG Verified
45a3947feat(screencast): send GPU DMA-BUF frames only, drop memfd and CPU readbackbrice GPG Verified
10f6f9cfeat(ports): add CastBufferAllocator for screencast DMA-BUF buffersbrice GPG Verified
c894364feat(vulkan): copy PQ captures into XB30 dmabufs with implicit syncbrice GPG Verified
1377cadfeat(vulkan): export cast DMA-BUF buffers with per-format modifiersbrice GPG Verified
fec1d19build(deps): use purego-pipewire b87b6e8 for DMA-BUF video sourcesbrice GPG Verified
2786184fix(capture): composite requested cursors into private GPU capturesbrice GPG Verified
b90d11dbuild(deps): use purego-pipewire v0.5.0brice GPG Verified
afb17c0fix(core): focus a new window a rule opens on another outputbrice GPG Verified
edac31bMerge branch 'fix/rule-move-keeps-focus' into feat/virtual-hdrbrice GPG Verified
a006c36fix(capture): start no dmabuf copy for a cancelled pipelinebrice GPG Verified
3863c70fix(screencast): retry renegotiation while a buffer is borrowedbrice GPG Verified
c487ea4fix(vulkan): keep composed alpha opaque for dmabuf capturesbrice GPG Verified
4ad4d67fix(virtuals): apply HDR changes without removing the screenbrice GPG Verified
8a8428cfix(vulkan): free the PQ capture pass before the HDR composition imagebrice GPG Verified
0000f91test(screencast): HDR virtual output negotiates 10-bit PQ end to endbrice GPG Verified
85085e0feat(screencast): offer 10-bit PQ for HDR outputsbrice GPG Verified
e703a15feat(capture): read PQ cast requests from the HDR framebrice GPG Verified
b14022dMerge branch 'feat/virtual-hdr-dmabuf' into feat/virtual-hdrbrice GPG Verified
bb45177build(deps): use purego-pipewire with live format renegotiationbrice GPG Verified
b980a3cfeat(wayland): offer dmabuf buffers in screencopybrice GPG Verified
573e28efeat(capture): route dmabuf capture requests to the GPU copybrice GPG Verified
9318610feat(vulkan): copy captures into client dmabufsbrice GPG Verified
5270e85feat(screencast): report the target's HDR state with its sizebrice GPG Verified
71c2724feat(ports): expose PQ capture on the renderer portbrice GPG Verified
37b7de4feat(vulkan): read HDR frames back as XBGR2101010 PQbrice GPG Verified
52aa01efeat(domain): add a dmabuf destination to capture requestsbrice GPG Verified
6ed9356test(wayland): virtual HDR output advertises PQ/BT.2020brice GPG Verified
d77e981feat(virtuals): start virtual outputs with configured HDR settingsbrice GPG Verified
846640ffeat(config): allow HDR on virtual outputsbrice GPG Verified
ae135a2refactor(headless): drive virtual HDR from shared output HDR settingsbrice GPG Verified
5dd8dedrefactor(domain): share output HDR settings across backendsbrice GPG Verified

Checks 1

116 files · +6063 -701
1/1
M .mockery.yml +6 -0
@@ -14,6 +14,7 @@ packages:
1414 filename: '{{.InterfaceFile | base | trimSuffix ".go"}}_mock.go'
1515 interfaces:
1616 CaptureFrame:
17+ CastBufferAllocator:
1718 CastSink:
1819 Clock:
1920 ContentReturn:
@@ -80,6 +81,11 @@ packages:
8081 dir: internal/adapters/vulkan
8182 pkgname: vulkan
8283 filename: capture_sync_mock_test.go
84+ dmabufFences:
85+ config:
86+ dir: internal/adapters/vulkan
87+ pkgname: vulkan
88+ filename: dmabuf_fences_mock_test.go
8389 github.com/bnema/neferwl/internal/adapters/wayland:
8490 interfaces:
8591 procEnv:
@@ -14,6 +14,7 @@ packages:
14 filename: '{{.InterfaceFile | base | trimSuffix ".go"}}_mock.go'14 filename: '{{.InterfaceFile | base | trimSuffix ".go"}}_mock.go'
15 interfaces:15 interfaces:
16 CaptureFrame:16 CaptureFrame:
17+ CastBufferAllocator:
17 CastSink:18 CastSink:
18 Clock:19 Clock:
19 ContentReturn:20 ContentReturn:
@@ -80,6 +81,11 @@ packages:
80 dir: internal/adapters/vulkan81 dir: internal/adapters/vulkan
81 pkgname: vulkan82 pkgname: vulkan
82 filename: capture_sync_mock_test.go83 filename: capture_sync_mock_test.go
84+ dmabufFences:
85+ config:
86+ dir: internal/adapters/vulkan
87+ pkgname: vulkan
88+ filename: dmabuf_fences_mock_test.go
83 github.com/bnema/neferwl/internal/adapters/wayland:89 github.com/bnema/neferwl/internal/adapters/wayland:
84 interfaces:90 interfaces:
85 procEnv:91 procEnv:
M docs/capture.md +17 -3
@@ -10,7 +10,8 @@ NeferWL supports `zwlr_screencopy_manager_v1` (used by `grim`) and `ext_image_co
1010
1111 With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.
1212
13-- Captures are 8-bit sRGB. HDR content is tone-mapped.
13+- Screenshots and recordings over these protocols are 8-bit sRGB. HDR content is tone-mapped. Screen sharing through the [portal](#portals) keeps HDR.
14+- `zwlr_screencopy_manager_v1` offers shared-memory buffers and, when the GPU can write them, linux-dmabuf buffers (XRGB8888 or ARGB8888), so a recorder can keep frames on the GPU.
1415 - The cursor is never included.
1516 - GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.
1617 - `neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.
@@ -25,7 +26,8 @@ grim -o tv tv.png
2526 ```
2627
2728 Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same
28-allowlist, portal and lock-security restrictions apply; virtual outputs are SDR.
29+allowlist, portal and lock-security restrictions apply. A virtual output with
30+`output.tv.hdr = on` is shared over the portal in HDR, like a physical one.
2931
3032 ## The indicator
3133
@@ -78,12 +80,24 @@ The allowlist stops unknown programs, not a program running as you that drives a
7880 NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.
7981
8082 - **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.
83+- **GPU buffers only**: the stream's buffers are DMA-BUFs the GPU allocates (DRM format modifiers), and every frame is copied into them on the GPU, synchronised through the buffers' implicit fences. No frame goes through CPU memory and no shared-memory (memfd) buffer is offered: a program that cannot take DMA-BUF frames (or a GPU that cannot export them) gets no stream, and the cast ends with a `dmabuf` reason in the log. OBS, browsers, Sunshine and GStreamer's `pipewiresrc` take DMA-BUF. `wlr-screencopy` clients such as grim still get shared-memory frames.
8184 - **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.
8285 - A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.
83-- Unsupported: area and virtual casts, and the "Select area" and "Window" choices of the screenshot dialog.
86+- **HDR**: sharing an output that shows HDR offers 10-bit PQ first (`xBGR_210LE`, BT.2020 primaries, SMPTE 2084, full-range RGB), with no tone mapping, and 8-bit sRGB (`BGRx`, `BGRA`) as the fallback for programs that do not take it. When the output turns HDR on or off, the stream renegotiates on the same PipeWire node: the receiving program keeps its stream. Window casts are 8-bit sRGB.
87+- Unsupported: area casts and casts of a monitor the cast itself creates (`RecordVirtual`; config-declared virtual outputs are shared like any output), and the "Select area" and "Window" choices of the screenshot dialog.
8488
8589 The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.
8690
8791 The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.
8892
8993 Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.
94+
95+### Sunshine
96+
97+[Sunshine](https://github.com/LizardByte/Sunshine) streams an HDR output through the portal. Set its capture method in `sunshine.conf`:
98+
99+```ini
100+capture = portal
101+```
102+
103+Pick the output in the portal dialog, for example a virtual `tv` with `output.tv.hdr = on`.
@@ -10,7 +10,8 @@ NeferWL supports `zwlr_screencopy_manager_v1` (used by `grim`) and `ext_image_co
10 10
11 With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.11 With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.
12 12
13-- Captures are 8-bit sRGB. HDR content is tone-mapped.13+- Screenshots and recordings over these protocols are 8-bit sRGB. HDR content is tone-mapped. Screen sharing through the [portal](#portals) keeps HDR.
14+- `zwlr_screencopy_manager_v1` offers shared-memory buffers and, when the GPU can write them, linux-dmabuf buffers (XRGB8888 or ARGB8888), so a recorder can keep frames on the GPU.
14 - The cursor is never included.15 - The cursor is never included.
15 - GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.16 - GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.
16 - `neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.17 - `neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.
@@ -25,7 +26,8 @@ grim -o tv tv.png
25 ```26 ```
26 27
27 Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same28 Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same
28-allowlist, portal and lock-security restrictions apply; virtual outputs are SDR.29+allowlist, portal and lock-security restrictions apply. A virtual output with
30+`output.tv.hdr = on` is shared over the portal in HDR, like a physical one.
29 31
30 ## The indicator32 ## The indicator
31 33
@@ -78,12 +80,24 @@ The allowlist stops unknown programs, not a program running as you that drives a
78 NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.80 NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.
79 81
80 - **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.82 - **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.
83+- **GPU buffers only**: the stream's buffers are DMA-BUFs the GPU allocates (DRM format modifiers), and every frame is copied into them on the GPU, synchronised through the buffers' implicit fences. No frame goes through CPU memory and no shared-memory (memfd) buffer is offered: a program that cannot take DMA-BUF frames (or a GPU that cannot export them) gets no stream, and the cast ends with a `dmabuf` reason in the log. OBS, browsers, Sunshine and GStreamer's `pipewiresrc` take DMA-BUF. `wlr-screencopy` clients such as grim still get shared-memory frames.
81 - **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.84 - **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.
82 - A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.85 - A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.
83-- Unsupported: area and virtual casts, and the "Select area" and "Window" choices of the screenshot dialog.86+- **HDR**: sharing an output that shows HDR offers 10-bit PQ first (`xBGR_210LE`, BT.2020 primaries, SMPTE 2084, full-range RGB), with no tone mapping, and 8-bit sRGB (`BGRx`, `BGRA`) as the fallback for programs that do not take it. When the output turns HDR on or off, the stream renegotiates on the same PipeWire node: the receiving program keeps its stream. Window casts are 8-bit sRGB.
87+- Unsupported: area casts and casts of a monitor the cast itself creates (`RecordVirtual`; config-declared virtual outputs are shared like any output), and the "Select area" and "Window" choices of the screenshot dialog.
84 88
85 The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.89 The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.
86 90
87 The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.91 The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.
88 92
89 Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.93 Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.
94+
95+### Sunshine
96+
97+[Sunshine](https://github.com/LizardByte/Sunshine) streams an HDR output through the portal. Set its capture method in `sunshine.conf`:
98+
99+```ini
100+capture = portal
101+```
102+
103+Pick the output in the portal dialog, for example a virtual `tv` with `output.tv.hdr = on`.
M docs/config.md +25 -6
@@ -85,8 +85,9 @@ See [examples/config](../examples/config) for every key with its default.
8585 | `output.<name>.transform` | `normal` | `90`, `180`, `270`, `flipped`, `flipped-90`, … |
8686 | `output.<name>.primary` | `off` | Focused at startup |
8787 | `output.<name>.right-of`, `.left-of`, `.above`, `.below`, `.offset` | automatic | [Output placement](#output-placement) |
88-| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays; ignored with a warning on virtual outputs, as are `.sdr-expand`, `.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` (always SDR) |
88+| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays and on virtual outputs |
8989 | `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |
90+| `output.<name>.keep-focus` | `off` | Keeps an X11 window on this output X11-active while a native window has the keyboard; see [Virtual outputs](#virtual-outputs) |
9091 | `drm.devices` | empty (all GPUs) | Comma-separated [GPUs](#gpus) NeferWL uses (restart required) |
9192 | `drm.ignore` | empty | Comma-separated [GPUs](#gpus) NeferWL leaves alone (restart required) |
9293 | `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |
@@ -166,6 +167,7 @@ output.<name>.primary = off
166167 output.<name>.offset = 0
167168 output.<name>.hdr = off
168169 output.<name>.sdr-brightness = 203
170+output.<name>.keep-focus = off
169171 output.<name>.sdr-expand = auto
170172 output.<name>.sdr-expand-intensity = 0.5
171173 output.<name>.sdr-expand-peak = 0
@@ -176,7 +178,7 @@ Outputs are arranged automatically unless `.right-of`, `.left-of`, `.above` or `
176178
177179 ## Window rules
178180
179-Rules place an app's windows when they first open. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
181+Rules place an app's windows when they first open. A window a rule opens on another output, even an isolated one, takes the focus there and that output becomes focused, as it would have taken the focus on the focused output; a window that would open in the background (behind another app's fullscreen window, during overview or lock) stays unfocused. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
180182
181183 | Key | Meaning |
182184 |---|---|
@@ -205,7 +207,7 @@ rule.calc.floating = on
205207 ```
206208
207209 - Every matching rule applies, in file order; later rules win.
208-- A rule never moves your focus or view.
210+- A rule never moves your focus or view, except a new window or a focused window it sends to another output (above).
209211 - Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.
210212 - An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.
211213 - A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.
@@ -213,7 +215,7 @@ rule.calc.floating = on
213215
214216 ## Virtual outputs
215217
216-Declare an SDR output in the config; it exists while its entry remains:
218+Declare a virtual output in the config; it exists while its entry remains:
217219
218220 ```ini
219221 output.tv = virtual 1920x1080@60
@@ -221,8 +223,15 @@ output.tv = virtual 1920x1080@60
221223
222224 Refresh defaults to 60 Hz. Dimensions must be 1–16384; names use ASCII
223225 letters, digits, `.`, `_` and `-`, and must not collide with a physical head.
224-Invalid declarations warn and are ignored. HDR and SDR-expansion overrides
225-warn and are ignored on virtual outputs.
226+Invalid declarations warn and are ignored.
227+
228+Virtual outputs are SDR by default. `output.tv.hdr = on` makes one HDR
229+(PQ/BT.2020, reported as a 1000-nit display) when the renderer supports it,
230+else it falls back to SDR and logs why. `.sdr-brightness`, `.sdr-expand`,
231+`.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` apply as on
232+physical outputs. Reloading after a change to `.hdr` or `.sdr-brightness`
233+restarts the output's rendering; its windows, workspaces and screen casts
234+stay. `.sdr-expand-peak` applies at once.
226235
227236 Without placement, `tv` is isolated: automatic layout, unbound pointers,
228237 directional focus and startup focus skip it. Isolated outputs share a column
@@ -267,6 +276,16 @@ rule.big.title = (?i)big picture
267276 rule.big.output = tv
268277 ```
269278
279+Steam Big Picture picks its controller layout from the X11 focus. With
280+`output.tv.keep-focus = on`, an X11 (Xwayland) window on `tv` keeps the X11
281+input focus and `_NET_ACTIVE_WINDOW` while a native window on another output
282+has the keyboard: the window focused on `tv`, else the most recently mapped
283+visible one. Wayland keyboard focus is unchanged, so typed keys go to the
284+focused window only. It applies to X11 windows only; an X11 window with the
285+keyboard elsewhere takes precedence, and a locked session clears it. With
286+several such outputs, the first in config order wins. Sunshine's virtual
287+keyboard and mouse still follow normal focus.
288+
270289 For Sunshine, a `global_prep_cmd` command can select the client's mode:
271290 `wlr-randr --output tv --custom-mode ${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}@${SUNSHINE_CLIENT_FPS}`.
272291 Use `wayvnc -o tv` for remote access, or select `tv` in OBS's screen-capture
@@ -85,8 +85,9 @@ See [examples/config](../examples/config) for every key with its default.
85 | `output.<name>.transform` | `normal` | `90`, `180`, `270`, `flipped`, `flipped-90`, … |85 | `output.<name>.transform` | `normal` | `90`, `180`, `270`, `flipped`, `flipped-90`, … |
86 | `output.<name>.primary` | `off` | Focused at startup |86 | `output.<name>.primary` | `off` | Focused at startup |
87 | `output.<name>.right-of`, `.left-of`, `.above`, `.below`, `.offset` | automatic | [Output placement](#output-placement) |87 | `output.<name>.right-of`, `.left-of`, `.above`, `.below`, `.offset` | automatic | [Output placement](#output-placement) |
88-| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays; ignored with a warning on virtual outputs, as are `.sdr-expand`, `.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` (always SDR) |88+| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays and on virtual outputs |
89 | `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |89 | `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |
90+| `output.<name>.keep-focus` | `off` | Keeps an X11 window on this output X11-active while a native window has the keyboard; see [Virtual outputs](#virtual-outputs) |
90 | `drm.devices` | empty (all GPUs) | Comma-separated [GPUs](#gpus) NeferWL uses (restart required) |91 | `drm.devices` | empty (all GPUs) | Comma-separated [GPUs](#gpus) NeferWL uses (restart required) |
91 | `drm.ignore` | empty | Comma-separated [GPUs](#gpus) NeferWL leaves alone (restart required) |92 | `drm.ignore` | empty | Comma-separated [GPUs](#gpus) NeferWL leaves alone (restart required) |
92 | `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |93 | `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |
@@ -166,6 +167,7 @@ output.<name>.primary = off
166 output.<name>.offset = 0167 output.<name>.offset = 0
167 output.<name>.hdr = off168 output.<name>.hdr = off
168 output.<name>.sdr-brightness = 203169 output.<name>.sdr-brightness = 203
170+output.<name>.keep-focus = off
169 output.<name>.sdr-expand = auto171 output.<name>.sdr-expand = auto
170 output.<name>.sdr-expand-intensity = 0.5172 output.<name>.sdr-expand-intensity = 0.5
171 output.<name>.sdr-expand-peak = 0173 output.<name>.sdr-expand-peak = 0
@@ -176,7 +178,7 @@ Outputs are arranged automatically unless `.right-of`, `.left-of`, `.above` or `
176 178
177 ## Window rules179 ## Window rules
178 180
179-Rules place an app's windows when they first open. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.181+Rules place an app's windows when they first open. A window a rule opens on another output, even an isolated one, takes the focus there and that output becomes focused, as it would have taken the focus on the focused output; a window that would open in the background (behind another app's fullscreen window, during overview or lock) stays unfocused. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
180 182
181 | Key | Meaning |183 | Key | Meaning |
182 |---|---|184 |---|---|
@@ -205,7 +207,7 @@ rule.calc.floating = on
205 ```207 ```
206 208
207 - Every matching rule applies, in file order; later rules win.209 - Every matching rule applies, in file order; later rules win.
208-- A rule never moves your focus or view.210+- A rule never moves your focus or view, except a new window or a focused window it sends to another output (above).
209 - Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.211 - Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.
210 - An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.212 - An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.
211 - A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.213 - A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.
@@ -213,7 +215,7 @@ rule.calc.floating = on
213 215
214 ## Virtual outputs216 ## Virtual outputs
215 217
216-Declare an SDR output in the config; it exists while its entry remains:218+Declare a virtual output in the config; it exists while its entry remains:
217 219
218 ```ini220 ```ini
219 output.tv = virtual 1920x1080@60221 output.tv = virtual 1920x1080@60
@@ -221,8 +223,15 @@ output.tv = virtual 1920x1080@60
221 223
222 Refresh defaults to 60 Hz. Dimensions must be 1–16384; names use ASCII224 Refresh defaults to 60 Hz. Dimensions must be 1–16384; names use ASCII
223 letters, digits, `.`, `_` and `-`, and must not collide with a physical head.225 letters, digits, `.`, `_` and `-`, and must not collide with a physical head.
224-Invalid declarations warn and are ignored. HDR and SDR-expansion overrides226+Invalid declarations warn and are ignored.
225-warn and are ignored on virtual outputs.227+
228+Virtual outputs are SDR by default. `output.tv.hdr = on` makes one HDR
229+(PQ/BT.2020, reported as a 1000-nit display) when the renderer supports it,
230+else it falls back to SDR and logs why. `.sdr-brightness`, `.sdr-expand`,
231+`.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` apply as on
232+physical outputs. Reloading after a change to `.hdr` or `.sdr-brightness`
233+restarts the output's rendering; its windows, workspaces and screen casts
234+stay. `.sdr-expand-peak` applies at once.
226 235
227 Without placement, `tv` is isolated: automatic layout, unbound pointers,236 Without placement, `tv` is isolated: automatic layout, unbound pointers,
228 directional focus and startup focus skip it. Isolated outputs share a column237 directional focus and startup focus skip it. Isolated outputs share a column
@@ -267,6 +276,16 @@ rule.big.title = (?i)big picture
267 rule.big.output = tv276 rule.big.output = tv
268 ```277 ```
269 278
279+Steam Big Picture picks its controller layout from the X11 focus. With
280+`output.tv.keep-focus = on`, an X11 (Xwayland) window on `tv` keeps the X11
281+input focus and `_NET_ACTIVE_WINDOW` while a native window on another output
282+has the keyboard: the window focused on `tv`, else the most recently mapped
283+visible one. Wayland keyboard focus is unchanged, so typed keys go to the
284+focused window only. It applies to X11 windows only; an X11 window with the
285+keyboard elsewhere takes precedence, and a locked session clears it. With
286+several such outputs, the first in config order wins. Sunshine's virtual
287+keyboard and mouse still follow normal focus.
288+
270 For Sunshine, a `global_prep_cmd` command can select the client's mode:289 For Sunshine, a `global_prep_cmd` command can select the client's mode:
271 `wlr-randr --output tv --custom-mode ${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}@${SUNSHINE_CLIENT_FPS}`.290 `wlr-randr --output tv --custom-mode ${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}@${SUNSHINE_CLIENT_FPS}`.
272 Use `wayvnc -o tv` for remote access, or select `tv` in OBS's screen-capture291 Use `wayvnc -o tv` for remote access, or select `tv` in OBS's screen-capture
M go.mod +1 -1
@@ -6,7 +6,7 @@ require (
66 bnema.dev/kvconf v0.2.0
77 bnema.dev/purego v0.13.0-bnema.3
88 bnema.dev/purego-libwayland v0.13.0
9- bnema.dev/purego-pipewire v0.4.0
9+ bnema.dev/purego-pipewire v0.6.0
1010 bnema.dev/purego-vulkan v0.7.0
1111 bnema.dev/wlturbo v0.7.0
1212 bnema.dev/xturbo v0.1.0
@@ -6,7 +6,7 @@ require (
6 bnema.dev/kvconf v0.2.06 bnema.dev/kvconf v0.2.0
7 bnema.dev/purego v0.13.0-bnema.37 bnema.dev/purego v0.13.0-bnema.3
8 bnema.dev/purego-libwayland v0.13.08 bnema.dev/purego-libwayland v0.13.0
9- bnema.dev/purego-pipewire v0.4.09+ bnema.dev/purego-pipewire v0.6.0
10 bnema.dev/purego-vulkan v0.7.010 bnema.dev/purego-vulkan v0.7.0
11 bnema.dev/wlturbo v0.7.011 bnema.dev/wlturbo v0.7.0
12 bnema.dev/xturbo v0.1.012 bnema.dev/xturbo v0.1.0
M go.sum +4 -4 generated file: collapsed
M internal/adapters/config/config.go +11 -19
@@ -456,6 +456,17 @@ func parseBytes(data []byte) (domain.Config, map[string]string, []Warning, error
456456 entry().Primary = b
457457 continue
458458 }
459+ if base, ok := strings.CutSuffix(name, ".keep-focus"); ok {
460+ name = base
461+ b, err := onOff(value)
462+ if err != nil {
463+ warn("%s: %v", key, err)
464+ continue
465+ }
466+ override()
467+ entry().KeepFocus = b
468+ continue
469+ }
459470 if base, ok := strings.CutSuffix(name, ".hdr"); ok {
460471 name = base
461472 b, err := onOff(value)
@@ -662,25 +673,6 @@ func parseBytes(data []byte) (domain.Config, map[string]string, []Warning, error
662673 }
663674 override()
664675 }
665- // Subkeys may precede the declaration: enforce SDR only after all lines.
666- for i := range c.Outputs {
667- o := &c.Outputs[i]
668- if !o.Virtual {
669- continue
670- }
671- for _, field := range []string{"hdr", "sdr-expand", "sdr-expand-intensity", "sdr-expand-peak", "sdr-decode"} {
672- key := "output." + o.Name + "." + field
673- if line, ok := seen[key]; ok {
674- warnings = append(warnings, Warning{Line: line, Msg: key + ": ignored on virtual output (always SDR)"})
675- delete(raw, key)
676- }
677- }
678- o.HDR = false
679- o.SDRExpand = domain.SDRExpandAuto
680- o.SDRExpandIntensity = domain.DefaultSDRExpandIntensity
681- o.SDRExpandPeak = 0
682- o.SDRDecode = 0
683- }
684676 warnings = append(warnings, checkOutputAnchors(c.Outputs, relKeys, offsetLines, seen)...)
685677 warnings = append(warnings, checkWorkspaceBinds(c, seen)...)
686678 var ruleWarnings []Warning
@@ -456,6 +456,17 @@ func parseBytes(data []byte) (domain.Config, map[string]string, []Warning, error
456 entry().Primary = b456 entry().Primary = b
457 continue457 continue
458 }458 }
459+ if base, ok := strings.CutSuffix(name, ".keep-focus"); ok {
460+ name = base
461+ b, err := onOff(value)
462+ if err != nil {
463+ warn("%s: %v", key, err)
464+ continue
465+ }
466+ override()
467+ entry().KeepFocus = b
468+ continue
469+ }
459 if base, ok := strings.CutSuffix(name, ".hdr"); ok {470 if base, ok := strings.CutSuffix(name, ".hdr"); ok {
460 name = base471 name = base
461 b, err := onOff(value)472 b, err := onOff(value)
@@ -662,25 +673,6 @@ func parseBytes(data []byte) (domain.Config, map[string]string, []Warning, error
662 }673 }
663 override()674 override()
664 }675 }
665- // Subkeys may precede the declaration: enforce SDR only after all lines.
666- for i := range c.Outputs {
667- o := &c.Outputs[i]
668- if !o.Virtual {
669- continue
670- }
671- for _, field := range []string{"hdr", "sdr-expand", "sdr-expand-intensity", "sdr-expand-peak", "sdr-decode"} {
672- key := "output." + o.Name + "." + field
673- if line, ok := seen[key]; ok {
674- warnings = append(warnings, Warning{Line: line, Msg: key + ": ignored on virtual output (always SDR)"})
675- delete(raw, key)
676- }
677- }
678- o.HDR = false
679- o.SDRExpand = domain.SDRExpandAuto
680- o.SDRExpandIntensity = domain.DefaultSDRExpandIntensity
681- o.SDRExpandPeak = 0
682- o.SDRDecode = 0
683- }
684 warnings = append(warnings, checkOutputAnchors(c.Outputs, relKeys, offsetLines, seen)...)676 warnings = append(warnings, checkOutputAnchors(c.Outputs, relKeys, offsetLines, seen)...)
685 warnings = append(warnings, checkWorkspaceBinds(c, seen)...)677 warnings = append(warnings, checkWorkspaceBinds(c, seen)...)
686 var ruleWarnings []Warning678 var ruleWarnings []Warning
M internal/adapters/config/config_test.go +3 -1
@@ -295,6 +295,7 @@ output.HDMI-A-1 = off
295295 output.DP-1 = preferred
296296 output.DP-1.scale = 1.5
297297 output.DP-1.primary = on
298+output.DP-2.keep-focus = on
298299 bind.cmd+code:30 = quit
299300 render.direct-scanout = off
300301 render.tearing = off
@@ -315,7 +316,7 @@ startup = wl-paste --primary --watch cliphist store; waybar ;mako;
315316 t.Fatalf("%+v", c)
316317 }
317318 // Scale and mode lines combine in either order.
318- if len(c.Outputs) != 3 || c.Outputs[0].Mode != "5120x2160@165.058" || c.Outputs[0].Scale != 4.0/3 || !c.Outputs[1].Off || c.Outputs[2].Mode != "" || c.Outputs[2].Off || c.Outputs[2].Scale != 1.5 || !c.Outputs[2].Primary || c.Outputs[0].Primary {
319+ if len(c.Outputs) != 3 || c.Outputs[0].Mode != "5120x2160@165.058" || c.Outputs[0].Scale != 4.0/3 || !c.Outputs[1].Off || c.Outputs[2].Mode != "" || c.Outputs[2].Off || c.Outputs[2].Scale != 1.5 || !c.Outputs[2].Primary || c.Outputs[0].Primary || !c.Outputs[0].KeepFocus || c.Outputs[2].KeepFocus {
319320 t.Fatalf("%+v", c.Outputs)
320321 }
321322 if c.Binds["Cmd+code:30"] != "quit" {
@@ -340,6 +341,7 @@ func TestWarningsKeepDefaults(t *testing.T) {
340341 {"output.DP-2 = 1920x1080@0", "output.DP-2"},
341342 {"output.DP-2.scale = 0.5", "between 1 and 4"},
342343 {"output.DP-2.primary = yes", "output.DP-2.primary"},
344+ {"output.tv.keep-focus = yes", "output.tv.keep-focus"},
343345 {"output.DP-2.scale = 3/0", "between 1 and 4"},
344346 {"bind.cmd+code:x = quit", "evdev key code"},
345347 {"nope = 1", "nope"},
@@ -295,6 +295,7 @@ output.HDMI-A-1 = off
295 output.DP-1 = preferred295 output.DP-1 = preferred
296 output.DP-1.scale = 1.5296 output.DP-1.scale = 1.5
297 output.DP-1.primary = on297 output.DP-1.primary = on
298+output.DP-2.keep-focus = on
298 bind.cmd+code:30 = quit299 bind.cmd+code:30 = quit
299 render.direct-scanout = off300 render.direct-scanout = off
300 render.tearing = off301 render.tearing = off
@@ -315,7 +316,7 @@ startup = wl-paste --primary --watch cliphist store; waybar ;mako;
315 t.Fatalf("%+v", c)316 t.Fatalf("%+v", c)
316 }317 }
317 // Scale and mode lines combine in either order.318 // Scale and mode lines combine in either order.
318- if len(c.Outputs) != 3 || c.Outputs[0].Mode != "5120x2160@165.058" || c.Outputs[0].Scale != 4.0/3 || !c.Outputs[1].Off || c.Outputs[2].Mode != "" || c.Outputs[2].Off || c.Outputs[2].Scale != 1.5 || !c.Outputs[2].Primary || c.Outputs[0].Primary {319+ if len(c.Outputs) != 3 || c.Outputs[0].Mode != "5120x2160@165.058" || c.Outputs[0].Scale != 4.0/3 || !c.Outputs[1].Off || c.Outputs[2].Mode != "" || c.Outputs[2].Off || c.Outputs[2].Scale != 1.5 || !c.Outputs[2].Primary || c.Outputs[0].Primary || !c.Outputs[0].KeepFocus || c.Outputs[2].KeepFocus {
319 t.Fatalf("%+v", c.Outputs)320 t.Fatalf("%+v", c.Outputs)
320 }321 }
321 if c.Binds["Cmd+code:30"] != "quit" {322 if c.Binds["Cmd+code:30"] != "quit" {
@@ -340,6 +341,7 @@ func TestWarningsKeepDefaults(t *testing.T) {
340 {"output.DP-2 = 1920x1080@0", "output.DP-2"},341 {"output.DP-2 = 1920x1080@0", "output.DP-2"},
341 {"output.DP-2.scale = 0.5", "between 1 and 4"},342 {"output.DP-2.scale = 0.5", "between 1 and 4"},
342 {"output.DP-2.primary = yes", "output.DP-2.primary"},343 {"output.DP-2.primary = yes", "output.DP-2.primary"},
344+ {"output.tv.keep-focus = yes", "output.tv.keep-focus"},
343 {"output.DP-2.scale = 3/0", "between 1 and 4"},345 {"output.DP-2.scale = 3/0", "between 1 and 4"},
344 {"bind.cmd+code:x = quit", "evdev key code"},346 {"bind.cmd+code:x = quit", "evdev key code"},
345 {"nope = 1", "nope"},347 {"nope = 1", "nope"},
M internal/adapters/config/virtual_test.go +23 -27
@@ -60,36 +60,32 @@ func TestVirtualOutputModes(t *testing.T) {
6060 }
6161 }
6262
63-func TestVirtualOutputSDRWarnings(t *testing.T) {
64- for _, field := range []struct{ key, value string }{
65- {"hdr", "on"}, {"sdr-expand", "always"}, {"sdr-expand-intensity", "0.9"},
66- {"sdr-expand-peak", "800"}, {"sdr-decode", "srgb"},
67- } {
68- for _, before := range []bool{true, false} {
69- order := "after"
63+func TestVirtualOutputHDRKeys(t *testing.T) {
64+ for _, before := range []bool{true, false} {
65+ t.Run(map[bool]string{true: "before", false: "after"}[before], func(t *testing.T) {
66+ declaration := "output.tv = virtual 1920x1080\n"
67+ subkeys := "output.tv.hdr = on\noutput.tv.sdr-brightness = 300\noutput.tv.sdr-expand = always\noutput.tv.sdr-expand-intensity = 0.9\noutput.tv.sdr-expand-peak = 800\noutput.tv.sdr-decode = srgb\n"
68+ input := declaration + subkeys
7069 if before {
71- order = "before"
70+ input = subkeys + declaration
7271 }
73- t.Run(field.key+"/"+order, func(t *testing.T) {
74- declaration := "output.tv = virtual 1920x1080\n"
75- subkey := "output.tv." + field.key + " = " + field.value + "\n"
76- input, line := declaration+subkey, 2
77- if before {
78- input, line = subkey+declaration, 1
79- }
80- c, raw, warnings, err := parseBytes([]byte(input))
81- if err != nil || len(warnings) != 1 || warnings[0].Line != line || !strings.Contains(warnings[0].Msg, "ignored on virtual output") {
82- t.Fatalf("err=%v warnings=%v", err, warnings)
83- }
84- o := c.Outputs[0]
85- if !o.Virtual || o.HDR || o.SDRExpand != domain.SDRExpandAuto || o.SDRExpandIntensity != domain.DefaultSDRExpandIntensity || o.SDRExpandPeak != 0 || o.SDRDecode != domain.SDRDecodeGamma22 {
86- t.Fatalf("output=%+v", o)
87- }
88- if _, ok := raw["output.tv."+field.key]; ok {
89- t.Fatal("ignored key retained in effective config")
72+ c, raw, warnings, err := parseBytes([]byte(input))
73+ if err != nil || len(warnings) != 0 {
74+ t.Fatalf("err=%v warnings=%v", err, warnings)
75+ }
76+ o := c.Outputs[0]
77+ if !o.Virtual || !o.HDR || o.SDRBrightness != 300 || o.SDRExpand != domain.SDRExpandAlways || o.SDRExpandIntensity != 0.9 || o.SDRExpandPeak != 800 || o.SDRDecode != domain.SDRDecodeSRGB {
78+ t.Fatalf("output=%+v", o)
79+ }
80+ if got := o.HDRSettings(); got != (domain.OutputHDRSettings{Enabled: true, SDRBrightness: 300, ExpansionPeakNits: 800}) {
81+ t.Fatalf("settings=%+v", got)
82+ }
83+ for _, key := range []string{"hdr", "sdr-brightness", "sdr-expand", "sdr-expand-intensity", "sdr-expand-peak", "sdr-decode"} {
84+ if _, ok := raw["output.tv."+key]; !ok {
85+ t.Fatalf("%s dropped from effective config", key)
9086 }
91- })
92- }
87+ }
88+ })
9389 }
9490 }
9591
@@ -60,36 +60,32 @@ func TestVirtualOutputModes(t *testing.T) {
60 }60 }
61 }61 }
62 62
63-func TestVirtualOutputSDRWarnings(t *testing.T) {63+func TestVirtualOutputHDRKeys(t *testing.T) {
64- for _, field := range []struct{ key, value string }{64+ for _, before := range []bool{true, false} {
65- {"hdr", "on"}, {"sdr-expand", "always"}, {"sdr-expand-intensity", "0.9"},65+ t.Run(map[bool]string{true: "before", false: "after"}[before], func(t *testing.T) {
66- {"sdr-expand-peak", "800"}, {"sdr-decode", "srgb"},66+ declaration := "output.tv = virtual 1920x1080\n"
67- } {67+ subkeys := "output.tv.hdr = on\noutput.tv.sdr-brightness = 300\noutput.tv.sdr-expand = always\noutput.tv.sdr-expand-intensity = 0.9\noutput.tv.sdr-expand-peak = 800\noutput.tv.sdr-decode = srgb\n"
68- for _, before := range []bool{true, false} {68+ input := declaration + subkeys
69- order := "after"
70 if before {69 if before {
71- order = "before"70+ input = subkeys + declaration
72 }71 }
73- t.Run(field.key+"/"+order, func(t *testing.T) {72+ c, raw, warnings, err := parseBytes([]byte(input))
74- declaration := "output.tv = virtual 1920x1080\n"73+ if err != nil || len(warnings) != 0 {
75- subkey := "output.tv." + field.key + " = " + field.value + "\n"74+ t.Fatalf("err=%v warnings=%v", err, warnings)
76- input, line := declaration+subkey, 275+ }
77- if before {76+ o := c.Outputs[0]
78- input, line = subkey+declaration, 177+ if !o.Virtual || !o.HDR || o.SDRBrightness != 300 || o.SDRExpand != domain.SDRExpandAlways || o.SDRExpandIntensity != 0.9 || o.SDRExpandPeak != 800 || o.SDRDecode != domain.SDRDecodeSRGB {
79- }78+ t.Fatalf("output=%+v", o)
80- c, raw, warnings, err := parseBytes([]byte(input))79+ }
81- if err != nil || len(warnings) != 1 || warnings[0].Line != line || !strings.Contains(warnings[0].Msg, "ignored on virtual output") {80+ if got := o.HDRSettings(); got != (domain.OutputHDRSettings{Enabled: true, SDRBrightness: 300, ExpansionPeakNits: 800}) {
82- t.Fatalf("err=%v warnings=%v", err, warnings)81+ t.Fatalf("settings=%+v", got)
83- }82+ }
84- o := c.Outputs[0]83+ for _, key := range []string{"hdr", "sdr-brightness", "sdr-expand", "sdr-expand-intensity", "sdr-expand-peak", "sdr-decode"} {
85- if !o.Virtual || o.HDR || o.SDRExpand != domain.SDRExpandAuto || o.SDRExpandIntensity != domain.DefaultSDRExpandIntensity || o.SDRExpandPeak != 0 || o.SDRDecode != domain.SDRDecodeGamma22 {84+ if _, ok := raw["output.tv."+key]; !ok {
86- t.Fatalf("output=%+v", o)85+ t.Fatalf("%s dropped from effective config", key)
87- }
88- if _, ok := raw["output.tv."+field.key]; ok {
89- t.Fatal("ignored key retained in effective config")
90 }86 }
91- })87+ }
92- }88+ })
93 }89 }
94 }90 }
95 91
A internal/adapters/drm/capture_cursor_test.go +26 -0
@@ -0,0 +1,26 @@
1+package drm
2+
3+import (
4+ "github.com/bnema/neferwl/internal/domain"
5+ "testing"
6+)
7+
8+func TestCaptureCursorSnapshot(t *testing.T) {
9+ c := newCursor(nil, 64)
10+ c.image = true
11+ c.captureImage = domain.CursorImage{W: 1, H: 1, HotX: 2, Pixels: []byte{1, 2, 3, 255}}
12+ c.Move(10, 20)
13+ s := c.snapshot()
14+ if s == nil || s.X != 10 || s.Y != 20 || s.Image.HotX != 2 || s.Image.Pixels[2] != 3 {
15+ t.Fatalf("snapshot: %+v", s)
16+ }
17+ c.Hide()
18+ if c.snapshot() != nil {
19+ t.Fatal("away cursor captured")
20+ }
21+ c.Move(30, 40)
22+ c.image = false
23+ if c.snapshot() != nil {
24+ t.Fatal("security-invalidated cursor captured")
25+ }
26+}
@@ -0,0 +1,26 @@
1+package drm
2+
3+import (
4+ "github.com/bnema/neferwl/internal/domain"
5+ "testing"
6+)
7+
8+func TestCaptureCursorSnapshot(t *testing.T) {
9+ c := newCursor(nil, 64)
10+ c.image = true
11+ c.captureImage = domain.CursorImage{W: 1, H: 1, HotX: 2, Pixels: []byte{1, 2, 3, 255}}
12+ c.Move(10, 20)
13+ s := c.snapshot()
14+ if s == nil || s.X != 10 || s.Y != 20 || s.Image.HotX != 2 || s.Image.Pixels[2] != 3 {
15+ t.Fatalf("snapshot: %+v", s)
16+ }
17+ c.Hide()
18+ if c.snapshot() != nil {
19+ t.Fatal("away cursor captured")
20+ }
21+ c.Move(30, 40)
22+ c.image = false
23+ if c.snapshot() != nil {
24+ t.Fatal("security-invalidated cursor captured")
25+ }
26+}
M internal/adapters/drm/card.go +2 -9
@@ -350,17 +350,10 @@ func (c *Card) ReadEvents(ctx context.Context) error {
350350 return nil
351351 }
352352
353-func normalizedHDRSettings(settings HDRSettings) HDRSettings {
354- if settings.SDRBrightness == 0 {
355- settings.SDRBrightness = domain.DefaultSDRBrightness
356- }
357- return settings
358-}
359-
360353 // outputNeedsRestart applies the same replacement path to mode and HDR
361354 // configuration changes; Release drops the old output before reopening it.
362-func outputNeedsRestart(o *Output, mode modeInfo, settings HDRSettings) bool {
363- settings = normalizedHDRSettings(settings)
355+func outputNeedsRestart(o *Output, mode modeInfo, settings domain.OutputHDRSettings) bool {
356+ settings = settings.Normalized()
364357 // ExpansionPeakNits affects composition and reported caps, not KMS state.
365358 // Its live update is delivered to the owner instead of replacing the output.
366359 return o.mode != mode || o.hdr.settings.Enabled != settings.Enabled || o.hdr.settings.SDRBrightness != settings.SDRBrightness
@@ -350,17 +350,10 @@ func (c *Card) ReadEvents(ctx context.Context) error {
350 return nil350 return nil
351 }351 }
352 352
353-func normalizedHDRSettings(settings HDRSettings) HDRSettings {
354- if settings.SDRBrightness == 0 {
355- settings.SDRBrightness = domain.DefaultSDRBrightness
356- }
357- return settings
358-}
359-
360 // outputNeedsRestart applies the same replacement path to mode and HDR353 // outputNeedsRestart applies the same replacement path to mode and HDR
361 // configuration changes; Release drops the old output before reopening it.354 // configuration changes; Release drops the old output before reopening it.
362-func outputNeedsRestart(o *Output, mode modeInfo, settings HDRSettings) bool {355+func outputNeedsRestart(o *Output, mode modeInfo, settings domain.OutputHDRSettings) bool {
363- settings = normalizedHDRSettings(settings)356+ settings = settings.Normalized()
364 // ExpansionPeakNits affects composition and reported caps, not KMS state.357 // ExpansionPeakNits affects composition and reported caps, not KMS state.
365 // Its live update is delivered to the owner instead of replacing the output.358 // Its live update is delivered to the owner instead of replacing the output.
366 return o.mode != mode || o.hdr.settings.Enabled != settings.Enabled || o.hdr.settings.SDRBrightness != settings.SDRBrightness359 return o.mode != mode || o.hdr.settings.Enabled != settings.Enabled || o.hdr.settings.SDRBrightness != settings.SDRBrightness
M internal/adapters/drm/colorop_test.go +5 -5
@@ -892,7 +892,7 @@ func TestSetupColor(t *testing.T) {
892892 t.Run("HDR makes the matrix blob, the multiplier and the identity 3D LUT", func(t *testing.T) {
893893 o, k, _ := colorOutput(t, false, nil)
894894 o.ctmBlob, o.lut3dBlob, o.colorMult = 0, 0, 0
895- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 160}
895+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 160}
896896 o.hdr.cap.Capable = true
897897 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()
898898 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(17)) })).Return(uint32(62), nil).Once()
@@ -906,7 +906,7 @@ func TestSetupColor(t *testing.T) {
906906 colorPlane(k, o.primary, pColorPipe, opBase, []opSpec{opSRGB, opMult, opCTM, opPQ})
907907 o.hdr.on = true
908908 o.readColor()
909- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 160}
909+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 160}
910910 o.hdr.cap.Capable = true
911911 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()
912912 o.setupColor()
@@ -943,7 +943,7 @@ func TestSetupColor(t *testing.T) {
943943 if o.overlay == nil || o.overlay.pipeline == nil || o.primary.pipeline == nil {
944944 t.Fatal("pipelines not matched")
945945 }
946- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
946+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
947947 o.hdr.cap.Capable = true
948948 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()
949949 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(uint32(tc.lut))) })).Return(uint32(62), nil).Once()
@@ -957,7 +957,7 @@ func TestSetupColor(t *testing.T) {
957957 t.Run("3D LUT blob failure turns the pipelines off", func(t *testing.T) {
958958 o, k, _ := colorOutput(t, true, nil)
959959 o.ctmBlob, o.lut3dBlob = 0, 0
960- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
960+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
961961 o.hdr.cap.Capable = true
962962 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()
963963 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()
@@ -969,7 +969,7 @@ func TestSetupColor(t *testing.T) {
969969 t.Run("blob failure turns the pipelines off", func(t *testing.T) {
970970 o, k, _ := colorOutput(t, true, nil)
971971 o.ctmBlob = 0
972- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
972+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
973973 o.hdr.cap.Capable = true
974974 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()
975975 o.setupColor()
@@ -892,7 +892,7 @@ func TestSetupColor(t *testing.T) {
892 t.Run("HDR makes the matrix blob, the multiplier and the identity 3D LUT", func(t *testing.T) {892 t.Run("HDR makes the matrix blob, the multiplier and the identity 3D LUT", func(t *testing.T) {
893 o, k, _ := colorOutput(t, false, nil)893 o, k, _ := colorOutput(t, false, nil)
894 o.ctmBlob, o.lut3dBlob, o.colorMult = 0, 0, 0894 o.ctmBlob, o.lut3dBlob, o.colorMult = 0, 0, 0
895- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 160}895+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 160}
896 o.hdr.cap.Capable = true896 o.hdr.cap.Capable = true
897 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()897 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()
898 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(17)) })).Return(uint32(62), nil).Once()898 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(17)) })).Return(uint32(62), nil).Once()
@@ -906,7 +906,7 @@ func TestSetupColor(t *testing.T) {
906 colorPlane(k, o.primary, pColorPipe, opBase, []opSpec{opSRGB, opMult, opCTM, opPQ})906 colorPlane(k, o.primary, pColorPipe, opBase, []opSpec{opSRGB, opMult, opCTM, opPQ})
907 o.hdr.on = true907 o.hdr.on = true
908 o.readColor()908 o.readColor()
909- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 160}909+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 160}
910 o.hdr.cap.Capable = true910 o.hdr.cap.Capable = true
911 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()911 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()
912 o.setupColor()912 o.setupColor()
@@ -943,7 +943,7 @@ func TestSetupColor(t *testing.T) {
943 if o.overlay == nil || o.overlay.pipeline == nil || o.primary.pipeline == nil {943 if o.overlay == nil || o.overlay.pipeline == nil || o.primary.pipeline == nil {
944 t.Fatal("pipelines not matched")944 t.Fatal("pipelines not matched")
945 }945 }
946- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}946+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
947 o.hdr.cap.Capable = true947 o.hdr.cap.Capable = true
948 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()948 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, ctmBytes(bt709ToBT2020)) })).Return(uint32(61), nil).Once()
949 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(uint32(tc.lut))) })).Return(uint32(62), nil).Once()949 k.EXPECT().createBlob(mock.MatchedBy(func(b []byte) bool { return slices.Equal(b, lut3dIdentityBytes(uint32(tc.lut))) })).Return(uint32(62), nil).Once()
@@ -957,7 +957,7 @@ func TestSetupColor(t *testing.T) {
957 t.Run("3D LUT blob failure turns the pipelines off", func(t *testing.T) {957 t.Run("3D LUT blob failure turns the pipelines off", func(t *testing.T) {
958 o, k, _ := colorOutput(t, true, nil)958 o, k, _ := colorOutput(t, true, nil)
959 o.ctmBlob, o.lut3dBlob = 0, 0959 o.ctmBlob, o.lut3dBlob = 0, 0
960- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}960+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
961 o.hdr.cap.Capable = true961 o.hdr.cap.Capable = true
962 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()962 k.EXPECT().createBlob(mock.Anything).Return(uint32(61), nil).Once()
963 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()963 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()
@@ -969,7 +969,7 @@ func TestSetupColor(t *testing.T) {
969 t.Run("blob failure turns the pipelines off", func(t *testing.T) {969 t.Run("blob failure turns the pipelines off", func(t *testing.T) {
970 o, k, _ := colorOutput(t, true, nil)970 o, k, _ := colorOutput(t, true, nil)
971 o.ctmBlob = 0971 o.ctmBlob = 0
972- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}972+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
973 o.hdr.cap.Capable = true973 o.hdr.cap.Capable = true
974 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()974 k.EXPECT().createBlob(mock.Anything).Return(uint32(0), unix.ENOMEM).Once()
975 o.setupColor()975 o.setupColor()
M internal/adapters/drm/cursor.go +22 -3
@@ -5,6 +5,7 @@ import (
55 "slices"
66 "sync"
77
8+ "github.com/bnema/neferwl/internal/domain"
89 "github.com/bnema/neferwl/internal/ports"
910 )
1011
@@ -46,9 +47,10 @@ type Cursor struct {
4647 hotX, hotY int
4748 // last is a copy of the loaded image, written again into new images
4849 // when the allocator changes.
49- last laterImage
50- applied cursorState // what the last commit put on the plane
51- commits int
50+ captureImage domain.CursorImage // owner-only SDR image, independent of KMS allocation
51+ last laterImage
52+ applied cursorState // what the last commit put on the plane
53+ commits int
5254 // screen is the image the plane scans out (0: none); flight is what
5355 // the pending commit puts on it when flying. An image is written only
5456 // when it is neither, so the plane never shows a half-written image.
@@ -92,6 +94,18 @@ func (c *Cursor) TakeStats() CursorStats {
9294 return s
9395 }
9496
97+// snapshot samples physical hotspot motion under its lock; the SDR image is
98+// owned by this output goroutine, not by the input goroutine or KMS plane.
99+func (c *Cursor) snapshot() *domain.CaptureCursor {
100+ c.mu.Lock()
101+ x, y, away := c.x, c.y, c.away
102+ c.mu.Unlock()
103+ if away || !c.image || c.captureImage.W == 0 || c.captureImage.H == 0 {
104+ return nil
105+ }
106+ return &domain.CaptureCursor{Image: c.captureImage, X: x, Y: y}
107+}
108+
95109 // Limit is the largest image side the cursor plane accepts.
96110 func (c *Cursor) Limit() int { return c.size }
97111
@@ -181,6 +195,10 @@ func (c *Cursor) useFallback(hdrNits float64) (bool, error) {
181195 // none).
182196 // hdrNits is the SDR white of an HDR output (0: SDR).
183197 func (c *Cursor) setImage(pixels []byte, w, h, hotX, hotY int, hdrNits float64) error {
198+ c.captureImage = domain.CursorImage{}
199+ if w > 0 && h > 0 && len(pixels) >= w*h*4 {
200+ c.captureImage = domain.CursorImage{W: w, H: h, HotX: hotX, HotY: hotY, Pixels: slices.Clone(pixels[:w*h*4])}
201+ }
184202 c.later = nil
185203 if w <= 0 || h <= 0 || len(pixels) < w*h*4 {
186204 c.image = false
@@ -286,6 +304,7 @@ func (c *Cursor) free() {
286304 }
287305 c.fbs = [2]uint32{}
288306 c.image, c.later = false, nil
307+ c.captureImage = domain.CursorImage{}
289308 c.last = laterImage{}
290309 c.screen, c.flying = 0, false
291310 }
@@ -5,6 +5,7 @@ import (
5 "slices"5 "slices"
6 "sync"6 "sync"
7 7
8+ "github.com/bnema/neferwl/internal/domain"
8 "github.com/bnema/neferwl/internal/ports"9 "github.com/bnema/neferwl/internal/ports"
9 )10 )
10 11
@@ -46,9 +47,10 @@ type Cursor struct {
46 hotX, hotY int47 hotX, hotY int
47 // last is a copy of the loaded image, written again into new images48 // last is a copy of the loaded image, written again into new images
48 // when the allocator changes.49 // when the allocator changes.
49- last laterImage50+ captureImage domain.CursorImage // owner-only SDR image, independent of KMS allocation
50- applied cursorState // what the last commit put on the plane51+ last laterImage
51- commits int52+ applied cursorState // what the last commit put on the plane
53+ commits int
52 // screen is the image the plane scans out (0: none); flight is what54 // screen is the image the plane scans out (0: none); flight is what
53 // the pending commit puts on it when flying. An image is written only55 // the pending commit puts on it when flying. An image is written only
54 // when it is neither, so the plane never shows a half-written image.56 // when it is neither, so the plane never shows a half-written image.
@@ -92,6 +94,18 @@ func (c *Cursor) TakeStats() CursorStats {
92 return s94 return s
93 }95 }
94 96
97+// snapshot samples physical hotspot motion under its lock; the SDR image is
98+// owned by this output goroutine, not by the input goroutine or KMS plane.
99+func (c *Cursor) snapshot() *domain.CaptureCursor {
100+ c.mu.Lock()
101+ x, y, away := c.x, c.y, c.away
102+ c.mu.Unlock()
103+ if away || !c.image || c.captureImage.W == 0 || c.captureImage.H == 0 {
104+ return nil
105+ }
106+ return &domain.CaptureCursor{Image: c.captureImage, X: x, Y: y}
107+}
108+
95 // Limit is the largest image side the cursor plane accepts.109 // Limit is the largest image side the cursor plane accepts.
96 func (c *Cursor) Limit() int { return c.size }110 func (c *Cursor) Limit() int { return c.size }
97 111
@@ -181,6 +195,10 @@ func (c *Cursor) useFallback(hdrNits float64) (bool, error) {
181 // none).195 // none).
182 // hdrNits is the SDR white of an HDR output (0: SDR).196 // hdrNits is the SDR white of an HDR output (0: SDR).
183 func (c *Cursor) setImage(pixels []byte, w, h, hotX, hotY int, hdrNits float64) error {197 func (c *Cursor) setImage(pixels []byte, w, h, hotX, hotY int, hdrNits float64) error {
198+ c.captureImage = domain.CursorImage{}
199+ if w > 0 && h > 0 && len(pixels) >= w*h*4 {
200+ c.captureImage = domain.CursorImage{W: w, H: h, HotX: hotX, HotY: hotY, Pixels: slices.Clone(pixels[:w*h*4])}
201+ }
184 c.later = nil202 c.later = nil
185 if w <= 0 || h <= 0 || len(pixels) < w*h*4 {203 if w <= 0 || h <= 0 || len(pixels) < w*h*4 {
186 c.image = false204 c.image = false
@@ -286,6 +304,7 @@ func (c *Cursor) free() {
286 }304 }
287 c.fbs = [2]uint32{}305 c.fbs = [2]uint32{}
288 c.image, c.later = false, nil306 c.image, c.later = false, nil
307+ c.captureImage = domain.CursorImage{}
289 c.last = laterImage{}308 c.last = laterImage{}
290 c.screen, c.flying = 0, false309 c.screen, c.flying = 0, false
291 }310 }
M internal/adapters/drm/edid_corpus_test.go +1 -1
@@ -41,7 +41,7 @@ func TestEDIDCorpus(t *testing.T) {
4141 if tt.file != "" && math.Abs(m.HDR.MaxFrameAverage-tt.average) > 1 {
4242 t.Fatalf("frame-average = %g, want %g", m.HDR.MaxFrameAverage, tt.average)
4343 }
44- caps := detectHDR(m, props).caps(0, 203)
44+ caps := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 0, SDRBrightness: 203}, detectHDR(m, props).facts(), false).Caps
4545 if caps.Tier != tt.tier || caps.PeakSource != tt.source || math.Abs(caps.PeakNits-tt.peak) > 1 || math.Abs(caps.Headroom-tt.peak/203) > 0.005 || caps.Expandable() != tt.expandable {
4646 t.Fatalf("caps = %+v (expandable %t), want tier=%s source=%s peak=%g headroom=%g expandable=%t", caps, caps.Expandable(), tt.tier, tt.source, tt.peak, tt.peak/203, tt.expandable)
4747 }
@@ -41,7 +41,7 @@ func TestEDIDCorpus(t *testing.T) {
41 if tt.file != "" && math.Abs(m.HDR.MaxFrameAverage-tt.average) > 1 {41 if tt.file != "" && math.Abs(m.HDR.MaxFrameAverage-tt.average) > 1 {
42 t.Fatalf("frame-average = %g, want %g", m.HDR.MaxFrameAverage, tt.average)42 t.Fatalf("frame-average = %g, want %g", m.HDR.MaxFrameAverage, tt.average)
43 }43 }
44- caps := detectHDR(m, props).caps(0, 203)44+ caps := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 0, SDRBrightness: 203}, detectHDR(m, props).facts(), false).Caps
45 if caps.Tier != tt.tier || caps.PeakSource != tt.source || math.Abs(caps.PeakNits-tt.peak) > 1 || math.Abs(caps.Headroom-tt.peak/203) > 0.005 || caps.Expandable() != tt.expandable {45 if caps.Tier != tt.tier || caps.PeakSource != tt.source || math.Abs(caps.PeakNits-tt.peak) > 1 || math.Abs(caps.Headroom-tt.peak/203) > 0.005 || caps.Expandable() != tt.expandable {
46 t.Fatalf("caps = %+v (expandable %t), want tier=%s source=%s peak=%g headroom=%g expandable=%t", caps, caps.Expandable(), tt.tier, tt.source, tt.peak, tt.peak/203, tt.expandable)46 t.Fatalf("caps = %+v (expandable %t), want tier=%s source=%s peak=%g headroom=%g expandable=%t", caps, caps.Expandable(), tt.tier, tt.source, tt.peak, tt.peak/203, tt.expandable)
47 }47 }
M internal/adapters/drm/frame_submit.go +6 -0
@@ -42,6 +42,12 @@ func (o *Output) submitFrame(ctx context.Context, r ports.Renderer, scene domain
4242 // displayed frame.
4343 // A request whose capture indicator the scene does not show yet is held
4444 // (the caller keeps it, see capture.Waiting).
45+ if pipeline != nil {
46+ pipeline.Cursor = nil
47+ if o.cursor != nil {
48+ pipeline.Cursor = o.cursor.snapshot()
49+ }
50+ }
4551 ready, _ := pipeline.Hold(scene, requests, time.Now())
4652 if len(scene.CaptureIndicators) > 0 {
4753 // The captures of this frame are delivered only once the frame that
@@ -42,6 +42,12 @@ func (o *Output) submitFrame(ctx context.Context, r ports.Renderer, scene domain
42 // displayed frame.42 // displayed frame.
43 // A request whose capture indicator the scene does not show yet is held43 // A request whose capture indicator the scene does not show yet is held
44 // (the caller keeps it, see capture.Waiting).44 // (the caller keeps it, see capture.Waiting).
45+ if pipeline != nil {
46+ pipeline.Cursor = nil
47+ if o.cursor != nil {
48+ pipeline.Cursor = o.cursor.snapshot()
49+ }
50+ }
45 ready, _ := pipeline.Hold(scene, requests, time.Now())51 ready, _ := pipeline.Hold(scene, requests, time.Now())
46 if len(scene.CaptureIndicators) > 0 {52 if len(scene.CaptureIndicators) > 0 {
47 // The captures of this frame are delivered only once the frame that53 // The captures of this frame are delivered only once the frame that
M internal/adapters/drm/hdr.go +9 -8
@@ -52,7 +52,7 @@ func maxFrameAverage(h HDRMetadata) float64 {
5252 type hdrState struct {
5353 cap hdrCapability
5454 props connectorHDRProps
55- settings HDRSettings
55+ settings domain.OutputHDRSettings
5656 // failed disables retries until this Output is replaced; on is the
5757 // currently selected signal encoding, including on VT resume.
5858 on, failed bool
@@ -147,14 +147,13 @@ func (m *hdrOutputMetadata) bytes() []byte {
147147 return unsafe.Slice((*byte)(unsafe.Pointer(m)), unsafe.Sizeof(*m))
148148 }
149149
150-// caps converts connector/EDID detection into pure capability facts without
150+// facts converts connector/EDID detection into pure capability facts without
151151 // changing the HDR signaling decision.
152-func (c hdrCapability) caps(peakNits, sdrWhiteNits float64) domain.HDRCaps {
153- return domain.ResolveHDRCaps(domain.HDRCapsInput{
152+func (c hdrCapability) facts() domain.HDRCapsInput {
153+ return domain.HDRCapsInput{
154154 Capable: c.Capable, Reason: c.Reason,
155- MaxLuminance: c.MaxLuminance, MaxFrameAverage: c.MaxFrameAverage,
156- MinLuminance: c.MinLuminance, ConfigPeakNits: peakNits, SDRWhiteNits: sdrWhiteNits,
157- })
155+ MaxLuminance: c.MaxLuminance, MaxFrameAverage: c.MaxFrameAverage, MinLuminance: c.MinLuminance,
156+ }
158157 }
159158
160159 // sendHDRCaps shares the lossless lifecycle stream. Cancellation releases a
@@ -163,7 +162,7 @@ func (o *Output) sendHDRCaps() {
163162 if o.Events == nil {
164163 return
165164 }
166- event := domain.OutputHDRCaps{Output: o.conn.name, Caps: o.hdr.cap.caps(o.hdr.settings.ExpansionPeakNits, float64(o.hdr.settings.SDRBrightness)), Active: o.hdr.on && !o.off}
165+ event := domain.NewOutputHDRCaps(o.conn.name, o.hdr.settings, o.hdr.cap.facts(), o.hdr.on && !o.off)
167166 ctx := o.eventContext
168167 if ctx == nil {
169168 ctx = context.Background()
@@ -197,6 +196,8 @@ func (o *Output) updateExpansionPeak(peak float64) {
197196 }
198197
199198 // applyExpansionPeak runs on the output owner, alongside lifecycle reporting.
199+//
200+//hexcheck:ignore suspicious-business-logic-in-adapter stores the owner-delivered peak and republishes caps; resolution policy is domain.NewOutputHDRCaps
200201 func (o *Output) applyExpansionPeak(peak float64) {
201202 if peak == o.hdr.settings.ExpansionPeakNits {
202203 return
@@ -52,7 +52,7 @@ func maxFrameAverage(h HDRMetadata) float64 {
52 type hdrState struct {52 type hdrState struct {
53 cap hdrCapability53 cap hdrCapability
54 props connectorHDRProps54 props connectorHDRProps
55- settings HDRSettings55+ settings domain.OutputHDRSettings
56 // failed disables retries until this Output is replaced; on is the56 // failed disables retries until this Output is replaced; on is the
57 // currently selected signal encoding, including on VT resume.57 // currently selected signal encoding, including on VT resume.
58 on, failed bool58 on, failed bool
@@ -147,14 +147,13 @@ func (m *hdrOutputMetadata) bytes() []byte {
147 return unsafe.Slice((*byte)(unsafe.Pointer(m)), unsafe.Sizeof(*m))147 return unsafe.Slice((*byte)(unsafe.Pointer(m)), unsafe.Sizeof(*m))
148 }148 }
149 149
150-// caps converts connector/EDID detection into pure capability facts without150+// facts converts connector/EDID detection into pure capability facts without
151 // changing the HDR signaling decision.151 // changing the HDR signaling decision.
152-func (c hdrCapability) caps(peakNits, sdrWhiteNits float64) domain.HDRCaps {152+func (c hdrCapability) facts() domain.HDRCapsInput {
153- return domain.ResolveHDRCaps(domain.HDRCapsInput{153+ return domain.HDRCapsInput{
154 Capable: c.Capable, Reason: c.Reason,154 Capable: c.Capable, Reason: c.Reason,
155- MaxLuminance: c.MaxLuminance, MaxFrameAverage: c.MaxFrameAverage,155+ MaxLuminance: c.MaxLuminance, MaxFrameAverage: c.MaxFrameAverage, MinLuminance: c.MinLuminance,
156- MinLuminance: c.MinLuminance, ConfigPeakNits: peakNits, SDRWhiteNits: sdrWhiteNits,156+ }
157- })
158 }157 }
159 158
160 // sendHDRCaps shares the lossless lifecycle stream. Cancellation releases a159 // sendHDRCaps shares the lossless lifecycle stream. Cancellation releases a
@@ -163,7 +162,7 @@ func (o *Output) sendHDRCaps() {
163 if o.Events == nil {162 if o.Events == nil {
164 return163 return
165 }164 }
166- event := domain.OutputHDRCaps{Output: o.conn.name, Caps: o.hdr.cap.caps(o.hdr.settings.ExpansionPeakNits, float64(o.hdr.settings.SDRBrightness)), Active: o.hdr.on && !o.off}165+ event := domain.NewOutputHDRCaps(o.conn.name, o.hdr.settings, o.hdr.cap.facts(), o.hdr.on && !o.off)
167 ctx := o.eventContext166 ctx := o.eventContext
168 if ctx == nil {167 if ctx == nil {
169 ctx = context.Background()168 ctx = context.Background()
@@ -197,6 +196,8 @@ func (o *Output) updateExpansionPeak(peak float64) {
197 }196 }
198 197
199 // applyExpansionPeak runs on the output owner, alongside lifecycle reporting.198 // applyExpansionPeak runs on the output owner, alongside lifecycle reporting.
199+//
200+//hexcheck:ignore suspicious-business-logic-in-adapter stores the owner-delivered peak and republishes caps; resolution policy is domain.NewOutputHDRCaps
200 func (o *Output) applyExpansionPeak(peak float64) {201 func (o *Output) applyExpansionPeak(peak float64) {
201 if peak == o.hdr.settings.ExpansionPeakNits {202 if peak == o.hdr.settings.ExpansionPeakNits {
202 return203 return
M internal/adapters/drm/hdr_caps_test.go +5 -5
@@ -10,14 +10,14 @@ import (
1010
1111 func TestHDRCapabilityCaps(t *testing.T) {
1212 c := hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604, MaxFrameAverage: 277}}
13- if got := c.caps(0, 203); got.Tier != domain.HDRFull || got.PeakNits != 604 {
13+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 0, SDRBrightness: 203}, c.facts(), false).Caps; got.Tier != domain.HDRFull || got.PeakNits != 604 {
1414 t.Fatalf("caps: %+v", got)
1515 }
16- if got := c.caps(800, 200); got.PeakSource != domain.HDRPeakConfig || got.Headroom != 4 {
16+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 800, SDRBrightness: 200}, c.facts(), false).Caps; got.PeakSource != domain.HDRPeakConfig || got.Headroom != 4 {
1717 t.Fatalf("override: %+v", got)
1818 }
1919 c.Capable, c.Reason = false, "edid: no PQ"
20- if got := c.caps(800, 200); got.Tier != domain.HDRUnavailable || got.Reason != c.Reason {
20+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 800, SDRBrightness: 200}, c.facts(), false).Caps; got.Tier != domain.HDRUnavailable || got.Reason != c.Reason {
2121 t.Fatalf("unavailable: %+v", got)
2222 }
2323 }
@@ -93,13 +93,13 @@ func TestExpansionPeakLiveUpdate(t *testing.T) {
9393 o.mode = modeInfo{VRefresh: 60}
9494 o.hdr.cap = hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604}}
9595 o.hdr.on = true
96- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
96+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
9797 c := &Card{k: k, outputs: map[string]*Output{"DP-1": o}}
9898 k.EXPECT().resources().Return([]uint32{30}, []uint32{40}, nil)
9999 k.EXPECT().connector(uint32(40)).Return(connector{id: 40, name: "DP-1", connected: true, modes: []modeInfo{o.mode}}, nil)
100100 scan := func(peak float64) {
101101 t.Helper()
102- c.SetWant(Want{HDR: map[string]HDRSettings{"DP-1": {Enabled: true, SDRBrightness: 203, ExpansionPeakNits: peak}}})
102+ c.SetWant(Want{HDR: map[string]domain.OutputHDRSettings{"DP-1": {Enabled: true, SDRBrightness: 203, ExpansionPeakNits: peak}}})
103103 added, removed, replaced, err := c.Scan()
104104 if err != nil || len(added)+len(removed)+len(replaced) != 0 {
105105 t.Fatalf("peak-only scan: added=%v removed=%v replaced=%v err=%v", added, removed, replaced, err)
@@ -10,14 +10,14 @@ import (
10 10
11 func TestHDRCapabilityCaps(t *testing.T) {11 func TestHDRCapabilityCaps(t *testing.T) {
12 c := hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604, MaxFrameAverage: 277}}12 c := hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604, MaxFrameAverage: 277}}
13- if got := c.caps(0, 203); got.Tier != domain.HDRFull || got.PeakNits != 604 {13+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 0, SDRBrightness: 203}, c.facts(), false).Caps; got.Tier != domain.HDRFull || got.PeakNits != 604 {
14 t.Fatalf("caps: %+v", got)14 t.Fatalf("caps: %+v", got)
15 }15 }
16- if got := c.caps(800, 200); got.PeakSource != domain.HDRPeakConfig || got.Headroom != 4 {16+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 800, SDRBrightness: 200}, c.facts(), false).Caps; got.PeakSource != domain.HDRPeakConfig || got.Headroom != 4 {
17 t.Fatalf("override: %+v", got)17 t.Fatalf("override: %+v", got)
18 }18 }
19 c.Capable, c.Reason = false, "edid: no PQ"19 c.Capable, c.Reason = false, "edid: no PQ"
20- if got := c.caps(800, 200); got.Tier != domain.HDRUnavailable || got.Reason != c.Reason {20+ if got := domain.NewOutputHDRCaps("", domain.OutputHDRSettings{ExpansionPeakNits: 800, SDRBrightness: 200}, c.facts(), false).Caps; got.Tier != domain.HDRUnavailable || got.Reason != c.Reason {
21 t.Fatalf("unavailable: %+v", got)21 t.Fatalf("unavailable: %+v", got)
22 }22 }
23 }23 }
@@ -93,13 +93,13 @@ func TestExpansionPeakLiveUpdate(t *testing.T) {
93 o.mode = modeInfo{VRefresh: 60}93 o.mode = modeInfo{VRefresh: 60}
94 o.hdr.cap = hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604}}94 o.hdr.cap = hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604}}
95 o.hdr.on = true95 o.hdr.on = true
96- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}96+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
97 c := &Card{k: k, outputs: map[string]*Output{"DP-1": o}}97 c := &Card{k: k, outputs: map[string]*Output{"DP-1": o}}
98 k.EXPECT().resources().Return([]uint32{30}, []uint32{40}, nil)98 k.EXPECT().resources().Return([]uint32{30}, []uint32{40}, nil)
99 k.EXPECT().connector(uint32(40)).Return(connector{id: 40, name: "DP-1", connected: true, modes: []modeInfo{o.mode}}, nil)99 k.EXPECT().connector(uint32(40)).Return(connector{id: 40, name: "DP-1", connected: true, modes: []modeInfo{o.mode}}, nil)
100 scan := func(peak float64) {100 scan := func(peak float64) {
101 t.Helper()101 t.Helper()
102- c.SetWant(Want{HDR: map[string]HDRSettings{"DP-1": {Enabled: true, SDRBrightness: 203, ExpansionPeakNits: peak}}})102+ c.SetWant(Want{HDR: map[string]domain.OutputHDRSettings{"DP-1": {Enabled: true, SDRBrightness: 203, ExpansionPeakNits: peak}}})
103 added, removed, replaced, err := c.Scan()103 added, removed, replaced, err := c.Scan()
104 if err != nil || len(added)+len(removed)+len(replaced) != 0 {104 if err != nil || len(added)+len(removed)+len(replaced) != 0 {
105 t.Fatalf("peak-only scan: added=%v removed=%v replaced=%v err=%v", added, removed, replaced, err)105 t.Fatalf("peak-only scan: added=%v removed=%v replaced=%v err=%v", added, removed, replaced, err)
M internal/adapters/drm/hdr_test.go +10 -10
@@ -77,7 +77,7 @@ func TestHDRTestCommitFallbackReexportsSDR(t *testing.T) {
7777 o, k, commits := testOutput(t, unix.EINVAL)
7878 o.cursor = nil
7979 o.hdr.cap = hdrCapability{Capable: true}
80- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
80+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
8181 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
8282 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}
8383 r := portsmocks.NewMockRenderer(t)
@@ -129,15 +129,15 @@ func TestHDRTestCommitFallbackReexportsSDR(t *testing.T) {
129129 }
130130
131131 func TestHDRSettingsRestartComparison(t *testing.T) {
132- current := HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
132+ current := domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
133133 for _, tc := range []struct {
134- settings HDRSettings
134+ settings domain.OutputHDRSettings
135135 restart bool
136136 }{
137- {HDRSettings{Enabled: true}, false},
138- {HDRSettings{Enabled: true, ExpansionPeakNits: 800}, false},
139- {HDRSettings{Enabled: true, SDRBrightness: 350}, true},
140- {HDRSettings{SDRBrightness: domain.DefaultSDRBrightness}, true},
137+ {domain.OutputHDRSettings{Enabled: true}, false},
138+ {domain.OutputHDRSettings{Enabled: true, ExpansionPeakNits: 800}, false},
139+ {domain.OutputHDRSettings{Enabled: true, SDRBrightness: 350}, true},
140+ {domain.OutputHDRSettings{SDRBrightness: domain.DefaultSDRBrightness}, true},
141141 } {
142142 if restart := outputNeedsRestart(&Output{hdr: hdrState{settings: current}}, modeInfo{}, tc.settings); restart != tc.restart {
143143 t.Fatalf("settings %+v: restart %t, want %t", tc.settings, restart, tc.restart)
@@ -153,7 +153,7 @@ func TestHDRSuccessfulModeset(t *testing.T) {
153153 o.fbs = [2]uint32{} // the first setup of a run: no image yet
154154 o.cursor = nil
155155 o.hdr.cap = hdrCapability{Capable: true}
156- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
156+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
157157 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
158158 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
159159 r := portsmocks.NewMockRenderer(t)
@@ -194,7 +194,7 @@ func TestHDRBlobReusedAcrossImageSetup(t *testing.T) {
194194 o, k, commits := testOutput(t)
195195 o.cursor = nil
196196 o.hdr.cap = hdrCapability{Capable: true}
197- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
197+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
198198 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
199199 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
200200 r := portsmocks.NewMockRenderer(t)
@@ -244,7 +244,7 @@ func TestHDRBlobReplacementWaitsForCommit(t *testing.T) {
244244 o, k, _ := testOutput(t)
245245 o.cursor = nil
246246 o.hdr.cap = hdrCapability{Capable: true}
247- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
247+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
248248 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
249249 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
250250 r := portsmocks.NewMockRenderer(t)
@@ -77,7 +77,7 @@ func TestHDRTestCommitFallbackReexportsSDR(t *testing.T) {
77 o, k, commits := testOutput(t, unix.EINVAL)77 o, k, commits := testOutput(t, unix.EINVAL)
78 o.cursor = nil78 o.cursor = nil
79 o.hdr.cap = hdrCapability{Capable: true}79 o.hdr.cap = hdrCapability{Capable: true}
80- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}80+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
81 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}81 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
82 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}82 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}
83 r := portsmocks.NewMockRenderer(t)83 r := portsmocks.NewMockRenderer(t)
@@ -129,15 +129,15 @@ func TestHDRTestCommitFallbackReexportsSDR(t *testing.T) {
129 }129 }
130 130
131 func TestHDRSettingsRestartComparison(t *testing.T) {131 func TestHDRSettingsRestartComparison(t *testing.T) {
132- current := HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}132+ current := domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
133 for _, tc := range []struct {133 for _, tc := range []struct {
134- settings HDRSettings134+ settings domain.OutputHDRSettings
135 restart bool135 restart bool
136 }{136 }{
137- {HDRSettings{Enabled: true}, false},137+ {domain.OutputHDRSettings{Enabled: true}, false},
138- {HDRSettings{Enabled: true, ExpansionPeakNits: 800}, false},138+ {domain.OutputHDRSettings{Enabled: true, ExpansionPeakNits: 800}, false},
139- {HDRSettings{Enabled: true, SDRBrightness: 350}, true},139+ {domain.OutputHDRSettings{Enabled: true, SDRBrightness: 350}, true},
140- {HDRSettings{SDRBrightness: domain.DefaultSDRBrightness}, true},140+ {domain.OutputHDRSettings{SDRBrightness: domain.DefaultSDRBrightness}, true},
141 } {141 } {
142 if restart := outputNeedsRestart(&Output{hdr: hdrState{settings: current}}, modeInfo{}, tc.settings); restart != tc.restart {142 if restart := outputNeedsRestart(&Output{hdr: hdrState{settings: current}}, modeInfo{}, tc.settings); restart != tc.restart {
143 t.Fatalf("settings %+v: restart %t, want %t", tc.settings, restart, tc.restart)143 t.Fatalf("settings %+v: restart %t, want %t", tc.settings, restart, tc.restart)
@@ -153,7 +153,7 @@ func TestHDRSuccessfulModeset(t *testing.T) {
153 o.fbs = [2]uint32{} // the first setup of a run: no image yet153 o.fbs = [2]uint32{} // the first setup of a run: no image yet
154 o.cursor = nil154 o.cursor = nil
155 o.hdr.cap = hdrCapability{Capable: true}155 o.hdr.cap = hdrCapability{Capable: true}
156- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}156+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
157 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}157 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
158 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}158 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
159 r := portsmocks.NewMockRenderer(t)159 r := portsmocks.NewMockRenderer(t)
@@ -194,7 +194,7 @@ func TestHDRBlobReusedAcrossImageSetup(t *testing.T) {
194 o, k, commits := testOutput(t)194 o, k, commits := testOutput(t)
195 o.cursor = nil195 o.cursor = nil
196 o.hdr.cap = hdrCapability{Capable: true}196 o.hdr.cap = hdrCapability{Capable: true}
197- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}197+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
198 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}198 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
199 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}199 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
200 r := portsmocks.NewMockRenderer(t)200 r := portsmocks.NewMockRenderer(t)
@@ -244,7 +244,7 @@ func TestHDRBlobReplacementWaitsForCommit(t *testing.T) {
244 o, k, _ := testOutput(t)244 o, k, _ := testOutput(t)
245 o.cursor = nil245 o.cursor = nil
246 o.hdr.cap = hdrCapability{Capable: true}246 o.hdr.cap = hdrCapability{Capable: true}
247- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}247+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: domain.DefaultSDRBrightness}
248 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}248 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
249 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}249 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 19}}
250 r := portsmocks.NewMockRenderer(t)250 r := portsmocks.NewMockRenderer(t)
M internal/adapters/drm/kms.go +1 -8
@@ -97,7 +97,7 @@ type Want struct {
9797 // Modes maps a connector to W, H and Hz (0: highest refresh at W x H).
9898 Modes map[string][3]float64
9999 // HDR settings are retained per connector; phase 1 never applies them to KMS.
100- HDR map[string]HDRSettings
100+ HDR map[string]domain.OutputHDRSettings
101101 // NoScanout disables direct scanout (render.direct-scanout = off).
102102 NoScanout bool
103103 // NoTearing ignores tearing requests (render.tearing = off).
@@ -117,13 +117,6 @@ type Want struct {
117117 VRRFlipGap time.Duration
118118 }
119119
120-// HDRSettings is the requested HDR state and SDR reference white (nits).
121-type HDRSettings struct {
122- ExpansionPeakNits float64
123- Enabled bool
124- SDRBrightness int
125-}
126-
127120 // usable reports whether a connector should be driven.
128121 func (w Want) usable(c connector) bool {
129122 return c.connected && !c.nonDesktop && len(c.modes) > 0 && !w.Disabled[c.name]
@@ -97,7 +97,7 @@ type Want struct {
97 // Modes maps a connector to W, H and Hz (0: highest refresh at W x H).97 // Modes maps a connector to W, H and Hz (0: highest refresh at W x H).
98 Modes map[string][3]float6498 Modes map[string][3]float64
99 // HDR settings are retained per connector; phase 1 never applies them to KMS.99 // HDR settings are retained per connector; phase 1 never applies them to KMS.
100- HDR map[string]HDRSettings100+ HDR map[string]domain.OutputHDRSettings
101 // NoScanout disables direct scanout (render.direct-scanout = off).101 // NoScanout disables direct scanout (render.direct-scanout = off).
102 NoScanout bool102 NoScanout bool
103 // NoTearing ignores tearing requests (render.tearing = off).103 // NoTearing ignores tearing requests (render.tearing = off).
@@ -117,13 +117,6 @@ type Want struct {
117 VRRFlipGap time.Duration117 VRRFlipGap time.Duration
118 }118 }
119 119
120-// HDRSettings is the requested HDR state and SDR reference white (nits).
121-type HDRSettings struct {
122- ExpansionPeakNits float64
123- Enabled bool
124- SDRBrightness int
125-}
126-
127 // usable reports whether a connector should be driven.120 // usable reports whether a connector should be driven.
128 func (w Want) usable(c connector) bool {121 func (w Want) usable(c connector) bool {
129 return c.connected && !c.nonDesktop && len(c.modes) > 0 && !w.Disabled[c.name]122 return c.connected && !c.nonDesktop && len(c.modes) > 0 && !w.Disabled[c.name]
M internal/adapters/drm/output.go +1 -1
@@ -254,7 +254,7 @@ func newOutput(card *Card, c connector, mode modeInfo, crtc uint32) (*Output, er
254254 if err := o.readProps(card.fd, pipe, card.taken, cursorSize(card.fd)); err != nil {
255255 return nil, err
256256 }
257- o.hdr.settings = normalizedHDRSettings(card.want.HDR[c.name])
257+ o.hdr.settings = card.want.HDR[c.name].Normalized()
258258 o.expansionPeak = make(chan float64, 1)
259259 o.requestedExpansionPeak = o.hdr.settings.ExpansionPeakNits
260260 o.hdr.cap = detectHDR(o.monitor, o.hdr.props)
@@ -254,7 +254,7 @@ func newOutput(card *Card, c connector, mode modeInfo, crtc uint32) (*Output, er
254 if err := o.readProps(card.fd, pipe, card.taken, cursorSize(card.fd)); err != nil {254 if err := o.readProps(card.fd, pipe, card.taken, cursorSize(card.fd)); err != nil {
255 return nil, err255 return nil, err
256 }256 }
257- o.hdr.settings = normalizedHDRSettings(card.want.HDR[c.name])257+ o.hdr.settings = card.want.HDR[c.name].Normalized()
258 o.expansionPeak = make(chan float64, 1)258 o.expansionPeak = make(chan float64, 1)
259 o.requestedExpansionPeak = o.hdr.settings.ExpansionPeakNits259 o.requestedExpansionPeak = o.hdr.settings.ExpansionPeakNits
260 o.hdr.cap = detectHDR(o.monitor, o.hdr.props)260 o.hdr.cap = detectHDR(o.monitor, o.hdr.props)
M internal/adapters/drm/protection_retry_test.go +1 -1
@@ -266,7 +266,7 @@ func TestProtectedShowImagesHDRKeepsHDRForKMSErrors(t *testing.T) {
266266 o.cursor = nil
267267 o.protected = true
268268 o.hdr.cap = hdrCapability{Capable: true}
269- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}
269+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
270270 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
271271 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}
272272 if errno == nil {
@@ -266,7 +266,7 @@ func TestProtectedShowImagesHDRKeepsHDRForKMSErrors(t *testing.T) {
266 o.cursor = nil266 o.cursor = nil
267 o.protected = true267 o.protected = true
268 o.hdr.cap = hdrCapability{Capable: true}268 o.hdr.cap = hdrCapability{Capable: true}
269- o.hdr.settings = HDRSettings{Enabled: true, SDRBrightness: 203}269+ o.hdr.settings = domain.OutputHDRSettings{Enabled: true, SDRBrightness: 203}
270 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}270 o.hdr.props = connectorHDRProps{Metadata: 100, Colorspace: 101, MaxBPC: 102, BT2020Value: 7, HasDefault: true, MaxBPCValue: 8}
271 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}271 o.primary.formats = []domain.DMABufFormat{{Format: fourccXR30, Modifier: 0}}
272 if errno == nil {272 if errno == nil {
M internal/adapters/drm/supervisor/drm_test.go +1 -2
@@ -4,7 +4,6 @@ import (
44 "testing"
55 "time"
66
7- "github.com/bnema/neferwl/internal/adapters/drm"
87 "github.com/bnema/neferwl/internal/domain"
98 )
109
@@ -12,7 +11,7 @@ func TestWantFromConfig(t *testing.T) {
1211 cfg := domain.Config{Outputs: []domain.OutputConfig{{Name: "eDP-1", Scale: 2, ScaleOnly: true, HDR: true, SDRBrightness: 350, SDRExpandPeak: 800}, {Name: "HDMI-A-1", Mode: "1920x1080@60"}, {Name: "DP-3", Off: true}}}
1312 cfg.Render.DirectScanout, cfg.Render.VRR, cfg.Render.VRRFlipGap = true, true, 2*time.Millisecond
1413 want := wantFromConfig(cfg)
15- if m := want.Modes["HDMI-A-1"]; m != [3]float64{1920, 1080, 60} || want.VRRFlipGap != 2*time.Millisecond || !want.Disabled["DP-3"] || len(want.Modes) != 1 || want.NoScanout || !want.NoTearing || want.NoVRR || want.HDR["eDP-1"] != (drm.HDRSettings{Enabled: true, SDRBrightness: 350, ExpansionPeakNits: 800}) || want.HDR["HDMI-A-1"].SDRBrightness != 203 {
14+ if m := want.Modes["HDMI-A-1"]; m != [3]float64{1920, 1080, 60} || want.VRRFlipGap != 2*time.Millisecond || !want.Disabled["DP-3"] || len(want.Modes) != 1 || want.NoScanout || !want.NoTearing || want.NoVRR || want.HDR["eDP-1"] != (domain.OutputHDRSettings{Enabled: true, SDRBrightness: 350, ExpansionPeakNits: 800}) || want.HDR["HDMI-A-1"].SDRBrightness != 203 {
1615 t.Fatalf("%+v", want)
1716 }
1817 }
@@ -4,7 +4,6 @@ import (
4 "testing"4 "testing"
5 "time"5 "time"
6 6
7- "github.com/bnema/neferwl/internal/adapters/drm"
8 "github.com/bnema/neferwl/internal/domain"7 "github.com/bnema/neferwl/internal/domain"
9 )8 )
10 9
@@ -12,7 +11,7 @@ func TestWantFromConfig(t *testing.T) {
12 cfg := domain.Config{Outputs: []domain.OutputConfig{{Name: "eDP-1", Scale: 2, ScaleOnly: true, HDR: true, SDRBrightness: 350, SDRExpandPeak: 800}, {Name: "HDMI-A-1", Mode: "1920x1080@60"}, {Name: "DP-3", Off: true}}}11 cfg := domain.Config{Outputs: []domain.OutputConfig{{Name: "eDP-1", Scale: 2, ScaleOnly: true, HDR: true, SDRBrightness: 350, SDRExpandPeak: 800}, {Name: "HDMI-A-1", Mode: "1920x1080@60"}, {Name: "DP-3", Off: true}}}
13 cfg.Render.DirectScanout, cfg.Render.VRR, cfg.Render.VRRFlipGap = true, true, 2*time.Millisecond12 cfg.Render.DirectScanout, cfg.Render.VRR, cfg.Render.VRRFlipGap = true, true, 2*time.Millisecond
14 want := wantFromConfig(cfg)13 want := wantFromConfig(cfg)
15- if m := want.Modes["HDMI-A-1"]; m != [3]float64{1920, 1080, 60} || want.VRRFlipGap != 2*time.Millisecond || !want.Disabled["DP-3"] || len(want.Modes) != 1 || want.NoScanout || !want.NoTearing || want.NoVRR || want.HDR["eDP-1"] != (drm.HDRSettings{Enabled: true, SDRBrightness: 350, ExpansionPeakNits: 800}) || want.HDR["HDMI-A-1"].SDRBrightness != 203 {14+ if m := want.Modes["HDMI-A-1"]; m != [3]float64{1920, 1080, 60} || want.VRRFlipGap != 2*time.Millisecond || !want.Disabled["DP-3"] || len(want.Modes) != 1 || want.NoScanout || !want.NoTearing || want.NoVRR || want.HDR["eDP-1"] != (domain.OutputHDRSettings{Enabled: true, SDRBrightness: 350, ExpansionPeakNits: 800}) || want.HDR["HDMI-A-1"].SDRBrightness != 203 {
16 t.Fatalf("%+v", want)15 t.Fatalf("%+v", want)
17 }16 }
18 }17 }
M internal/adapters/drm/supervisor/supervisor.go +2 -6
@@ -346,16 +346,12 @@ func (b *Backend) openCard(ctx context.Context, info domain.GPUInfo, mode domain
346346 // wantFromConfig turns output.<name> and render.* entries into connector choices.
347347 func wantFromConfig(cfg domain.Config) drm.Want {
348348 r := cfg.Render
349- want := drm.Want{Disabled: map[string]bool{}, Modes: map[string][3]float64{}, HDR: map[string]drm.HDRSettings{}, NoScanout: !r.DirectScanout, NoTearing: !r.Tearing, NoVRR: !r.VRR, VRRFlipGap: r.VRRFlipGap}
349+ want := drm.Want{Disabled: map[string]bool{}, Modes: map[string][3]float64{}, HDR: map[string]domain.OutputHDRSettings{}, NoScanout: !r.DirectScanout, NoTearing: !r.Tearing, NoVRR: !r.VRR, VRRFlipGap: r.VRRFlipGap}
350350 for _, o := range cfg.Outputs {
351351 if o.Virtual {
352352 continue
353353 }
354- nits := o.SDRBrightness
355- if nits == 0 {
356- nits = domain.DefaultSDRBrightness
357- }
358- want.HDR[o.Name] = drm.HDRSettings{Enabled: o.HDR, SDRBrightness: nits, ExpansionPeakNits: o.SDRExpandPeak}
354+ want.HDR[o.Name] = o.HDRSettings()
359355 if o.Off {
360356 want.Disabled[o.Name] = true
361357 continue
@@ -346,16 +346,12 @@ func (b *Backend) openCard(ctx context.Context, info domain.GPUInfo, mode domain
346 // wantFromConfig turns output.<name> and render.* entries into connector choices.346 // wantFromConfig turns output.<name> and render.* entries into connector choices.
347 func wantFromConfig(cfg domain.Config) drm.Want {347 func wantFromConfig(cfg domain.Config) drm.Want {
348 r := cfg.Render348 r := cfg.Render
349- want := drm.Want{Disabled: map[string]bool{}, Modes: map[string][3]float64{}, HDR: map[string]drm.HDRSettings{}, NoScanout: !r.DirectScanout, NoTearing: !r.Tearing, NoVRR: !r.VRR, VRRFlipGap: r.VRRFlipGap}349+ want := drm.Want{Disabled: map[string]bool{}, Modes: map[string][3]float64{}, HDR: map[string]domain.OutputHDRSettings{}, NoScanout: !r.DirectScanout, NoTearing: !r.Tearing, NoVRR: !r.VRR, VRRFlipGap: r.VRRFlipGap}
350 for _, o := range cfg.Outputs {350 for _, o := range cfg.Outputs {
351 if o.Virtual {351 if o.Virtual {
352 continue352 continue
353 }353 }
354- nits := o.SDRBrightness354+ want.HDR[o.Name] = o.HDRSettings()
355- if nits == 0 {
356- nits = domain.DefaultSDRBrightness
357- }
358- want.HDR[o.Name] = drm.HDRSettings{Enabled: o.HDR, SDRBrightness: nits, ExpansionPeakNits: o.SDRExpandPeak}
359 if o.Off {355 if o.Off {
360 want.Disabled[o.Name] = true356 want.Disabled[o.Name] = true
361 continue357 continue
M internal/adapters/headless/cursor.go +11 -0
@@ -36,6 +36,17 @@ func (c *Cursor) set(img domain.CursorImage) {
3636 c.mu.Unlock()
3737 }
3838
39+// snapshot is called by the output owner; set replaces rather than mutates
40+// image pixels, so the returned image stays immutable through the GPU upload.
41+func (c *Cursor) snapshot() *domain.CaptureCursor {
42+ c.mu.Lock()
43+ defer c.mu.Unlock()
44+ if c.hidden || c.img.W == 0 || c.img.H == 0 {
45+ return nil
46+ }
47+ return &domain.CaptureCursor{Image: c.img, X: int(c.x), Y: int(c.y)}
48+}
49+
3950 // draw blends the premultiplied cursor over dst with its hotspot at (x, y).
4051 func (c *Cursor) draw(dst *image.RGBA) {
4152 c.drawSecure(dst, nil)
@@ -36,6 +36,17 @@ func (c *Cursor) set(img domain.CursorImage) {
36 c.mu.Unlock()36 c.mu.Unlock()
37 }37 }
38 38
39+// snapshot is called by the output owner; set replaces rather than mutates
40+// image pixels, so the returned image stays immutable through the GPU upload.
41+func (c *Cursor) snapshot() *domain.CaptureCursor {
42+ c.mu.Lock()
43+ defer c.mu.Unlock()
44+ if c.hidden || c.img.W == 0 || c.img.H == 0 {
45+ return nil
46+ }
47+ return &domain.CaptureCursor{Image: c.img, X: int(c.x), Y: int(c.y)}
48+}
49+
39 // draw blends the premultiplied cursor over dst with its hotspot at (x, y).50 // draw blends the premultiplied cursor over dst with its hotspot at (x, y).
40 func (c *Cursor) draw(dst *image.RGBA) {51 func (c *Cursor) draw(dst *image.RGBA) {
41 c.drawSecure(dst, nil)52 c.drawSecure(dst, nil)
M internal/adapters/headless/cursor_test.go +25 -0
@@ -29,3 +29,28 @@ func TestCursorDraw(t *testing.T) {
2929 c.Move(100, -3)
3030 c.draw(dst)
3131 }
32+
33+func TestCaptureCursorSnapshotVisibility(t *testing.T) {
34+ c := &Cursor{}
35+ if c.snapshot() != nil {
36+ t.Fatal("empty cursor visible")
37+ }
38+ c.set(domain.CursorImage{W: 1, H: 1, HotX: 1, Pixels: []byte{0, 0, 255, 255}})
39+ c.Move(12, 34)
40+ got := c.snapshot()
41+ if got == nil || got.X != 12 || got.Y != 34 || got.Image.HotX != 1 {
42+ t.Fatalf("snapshot: %+v", got)
43+ }
44+ c.Hide()
45+ if c.snapshot() != nil {
46+ t.Fatal("hidden cursor visible")
47+ }
48+ c.Move(20, 30)
49+ if c.snapshot() == nil {
50+ t.Fatal("motion did not show cursor")
51+ }
52+ c.set(domain.CursorImage{})
53+ if c.snapshot() != nil {
54+ t.Fatal("client-hidden cursor visible")
55+ }
56+}
@@ -29,3 +29,28 @@ func TestCursorDraw(t *testing.T) {
29 c.Move(100, -3)29 c.Move(100, -3)
30 c.draw(dst)30 c.draw(dst)
31 }31 }
32+
33+func TestCaptureCursorSnapshotVisibility(t *testing.T) {
34+ c := &Cursor{}
35+ if c.snapshot() != nil {
36+ t.Fatal("empty cursor visible")
37+ }
38+ c.set(domain.CursorImage{W: 1, H: 1, HotX: 1, Pixels: []byte{0, 0, 255, 255}})
39+ c.Move(12, 34)
40+ got := c.snapshot()
41+ if got == nil || got.X != 12 || got.Y != 34 || got.Image.HotX != 1 {
42+ t.Fatalf("snapshot: %+v", got)
43+ }
44+ c.Hide()
45+ if c.snapshot() != nil {
46+ t.Fatal("hidden cursor visible")
47+ }
48+ c.Move(20, 30)
49+ if c.snapshot() == nil {
50+ t.Fatal("motion did not show cursor")
51+ }
52+ c.set(domain.CursorImage{})
53+ if c.snapshot() != nil {
54+ t.Fatal("client-hidden cursor visible")
55+ }
56+}
M internal/adapters/headless/output.go +157 -50
@@ -24,8 +24,12 @@ import (
2424 )
2525
2626 // ModeRequest is a live mode transaction. Result must be buffered by its sender.
27+// A non-nil HDR replaces the output's HDR settings in place (same output,
28+// same screen): an enable or SDR white change rebuilds the renderer, a peak
29+// change only republishes the caps. Mode is then the current mode.
2730 type ModeRequest struct {
2831 Mode domain.OutputMode
32+ HDR *domain.OutputHDRSettings
2933 Result chan<- error
3034 }
3135
@@ -36,14 +40,19 @@ type Options struct {
3640 SecurityChanges <-chan domain.SecurityState
3741 Instance domain.OutputInstance
3842 SecurityEvents chan<- ports.SecurityBackendEvent
39- // Cursor, when set, is drawn into screenshots with the image from
40- // LoadCursor at the scene scale and transform. The cursor is drawn in
43+ // Cursor, when set, supplies cursor-requesting captures and debug screenshots
44+ // with the image from LoadCursor at the scene scale and transform. It is in
4145 // target space: the image comes rotated and Move takes target pixels.
4246 Cursor *Cursor
4347 LoadCursor func(c domain.CursorChange, scale float64, t domain.BufferTransform, limit int) (domain.CursorImage, error)
4448 Width, Height int
4549 ScreenshotDir string
46- HDR bool // virtual HDR output for protocol testing only
50+ // HDR is the virtual output's HDR request (protocol testing only);
51+ // HDR.Enabled tries a PQ target and falls back to SDR when unavailable.
52+ HDR domain.OutputHDRSettings
53+ // HDRLuminance is the virtual display's luminance facts reported while
54+ // HDR is confirmed; zero uses DefaultVirtualHDRLuminance.
55+ HDRLuminance domain.OutputHDR
4756 // RawHDR also writes latest-pq.png, the raw PQ codes of an HDR output
4857 // (16-bit), next to the screenshots. Test-only; needs HDR and ScreenshotDir.
4958 RawHDR bool
@@ -93,50 +102,99 @@ func refreshPeriod(refresh int) time.Duration {
93102 return period
94103 }
95104
96-func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, contents <-chan *domain.ContentBatch, returns ports.ContentReturn, cursor <-chan domain.CursorChange, incoming <-chan domain.CaptureRequest) error {
97- r, err := opts.NewRenderer(opts.Width, opts.Height)
105+// DefaultVirtualHDRLuminance is the luminance a virtual HDR output reports
106+// when Options.HDRLuminance is unset.
107+var DefaultVirtualHDRLuminance = domain.OutputHDR{MaxLuminance: 1000, MaxFrameAverage: 400, MinLuminance: .005}
108+
109+// enableHDR switches r to a PQ target at the settings' SDR white and probes
110+// one exported target; the probe's files are closed. On error the caller
111+// falls back or discards r.
112+func enableHDR(r ports.Renderer, settings domain.OutputHDRSettings) error {
113+ r.SetHDR(float64(settings.Normalized().SDRBrightness))
114+ bufs, err := r.ExportTargets(1, nil, false)
98115 if err != nil {
99- return fmt.Errorf("create renderer: %w", err)
116+ return err
100117 }
101- defer func() { r.Close() }()
102- var confirmed *domain.OutputHDR
103- if opts.HDR {
104- r.SetHDR(203)
105- if bufs, err := r.ExportTargets(1, nil, false); err != nil {
106- opts.Log.Warn().Err(err).Str("output", opts.Name).Msg("virtual HDR unavailable; falling back to SDR")
107- r.SetHDR(0)
108- _, _ = r.ExportTargets(0, nil, false)
109- } else {
110- for _, b := range bufs {
111- for _, p := range b.Planes {
112- _ = p.File.Close()
113- }
114- }
115- confirmed = &domain.OutputHDR{MaxLuminance: 1000, MaxFrameAverage: 400, MinLuminance: .005}
116- opts.Log.Info().Str("output", opts.Name).Msg("virtual HDR enabled")
117- }
118- if opts.Formats != nil {
119- select {
120- case opts.Formats <- domain.OutputFormats{Output: opts.Name, HDR: confirmed}:
121- case <-ctx.Done():
122- return nil
123- }
118+ for _, b := range bufs {
119+ for _, p := range b.Planes {
120+ _ = p.File.Close()
124121 }
125122 }
126- event := domain.OutputHDRCaps{Output: opts.Name}
127- in := domain.HDRCapsInput{Reason: "virtual HDR inactive", SDRWhiteNits: 203}
123+ return nil
124+}
125+
126+// setupHDR applies settings to a fresh renderer and returns the confirmed
127+// HDR luminance, nil for SDR (also when HDR was asked but is unavailable).
128+func setupHDR(r ports.Renderer, opts Options, settings domain.OutputHDRSettings) *domain.OutputHDR {
129+ if !settings.Enabled {
130+ return nil
131+ }
132+ if err := enableHDR(r, settings); err != nil {
133+ opts.Log.Warn().Err(err).Str("output", opts.Name).Msg("virtual HDR unavailable; falling back to SDR")
134+ r.SetHDR(0)
135+ _, _ = r.ExportTargets(0, nil, false)
136+ return nil
137+ }
138+ lum := opts.HDRLuminance
139+ if lum == (domain.OutputHDR{}) {
140+ lum = DefaultVirtualHDRLuminance
141+ }
142+ opts.Log.Info().Str("output", opts.Name).Msg("virtual HDR enabled")
143+ return &lum
144+}
145+
146+// reportFormats sends the confirmed color state; false when ctx ended.
147+func reportFormats(ctx context.Context, opts Options, confirmed *domain.OutputHDR) bool {
148+ if opts.Formats == nil {
149+ return true
150+ }
151+ select {
152+ case opts.Formats <- domain.OutputFormats{Output: opts.Name, HDR: confirmed}:
153+ return true
154+ case <-ctx.Done():
155+ return false
156+ }
157+}
158+
159+// reportCaps sends the HDR caps of settings and the confirmed state; false
160+// when ctx ended.
161+func reportCaps(ctx context.Context, opts Options, settings domain.OutputHDRSettings, confirmed *domain.OutputHDR) bool {
162+ if opts.Events == nil {
163+ return true
164+ }
165+ facts := domain.HDRCapsInput{Reason: "virtual HDR inactive"}
128166 if confirmed != nil {
129- in.Capable = true
130- in.MaxLuminance, in.MaxFrameAverage, in.MinLuminance = confirmed.MaxLuminance, confirmed.MaxFrameAverage, confirmed.MinLuminance
131- event.Active = true
167+ facts.Capable = true
168+ facts.MaxLuminance, facts.MaxFrameAverage, facts.MinLuminance = confirmed.MaxLuminance, confirmed.MaxFrameAverage, confirmed.MinLuminance
132169 }
133- event.Caps = domain.ResolveHDRCaps(in)
134- if opts.Events != nil {
135- select {
136- case opts.Events <- ports.OutputHDRCaps{OutputHDRCaps: event}:
137- case <-ctx.Done():
170+ event := domain.NewOutputHDRCaps(opts.Name, settings, facts, confirmed != nil)
171+ select {
172+ case opts.Events <- ports.OutputHDRCaps{OutputHDRCaps: event}:
173+ return true
174+ case <-ctx.Done():
175+ return false
176+ }
177+}
178+
179+func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, contents <-chan *domain.ContentBatch, returns ports.ContentReturn, cursor <-chan domain.CursorChange, incoming <-chan domain.CaptureRequest) error {
180+ r, err := opts.NewRenderer(opts.Width, opts.Height)
181+ if err != nil {
182+ return fmt.Errorf("create renderer: %w", err)
183+ }
184+ defer func() { r.Close() }()
185+ hdrSettings := opts.HDR.Normalized()
186+ confirmed := setupHDR(r, opts, hdrSettings)
187+ // formats: whether the confirmed color state was reported (it is once
188+ // HDR was requested, so a later SDR state is reported too).
189+ formats := false
190+ if hdrSettings.Enabled {
191+ if !reportFormats(ctx, opts, confirmed) {
138192 return nil
139193 }
194+ formats = true
195+ }
196+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
197+ return nil
140198 }
141199 table := surfaces.New()
142200 drawn := table.Map()
@@ -307,6 +365,52 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
307365 if holdDue == nil {
308366 holdTimer.Stop()
309367 }
368+ // applyHDR replaces the HDR settings in place. Enable and SDR white
369+ // rebuild the renderer (as DRM restarts its output) on the same
370+ // output: no screen is removed. The peak only changes the caps.
371+ applyHDR := func(want domain.OutputHDRSettings) error {
372+ want = want.Normalized()
373+ if want == hdrSettings {
374+ return nil
375+ }
376+ if want.Enabled == hdrSettings.Enabled && want.SDRBrightness == hdrSettings.SDRBrightness {
377+ hdrSettings = want
378+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
379+ return ctx.Err()
380+ }
381+ return nil
382+ }
383+ next, err := opts.NewRenderer(opts.Width, opts.Height)
384+ if err != nil {
385+ return fmt.Errorf("recreate renderer: %w", err)
386+ }
387+ nextConfirmed := setupHDR(next, opts, want)
388+ pipeline.EndGate(capture.ErrFrameNotPresented)
389+ pipeline.Close(r)
390+ r.Close()
391+ r = next
392+ pipeline = capture.NewPipeline(ctx, opts.Captured)
393+ pipeline.Security = opts.Security
394+ if opts.NewCaptureRenderer != nil {
395+ pipeline.EnableOffscreen(opts.NewCaptureRenderer)
396+ }
397+ requests.FailPending(capture.ErrFrameNotPresented)
398+ hdrSettings, confirmed = want, nextConfirmed
399+ if want.Enabled || formats {
400+ if !reportFormats(ctx, opts, confirmed) {
401+ return ctx.Err()
402+ }
403+ formats = true
404+ }
405+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
406+ return ctx.Err()
407+ }
408+ // Redraw the current scene on the new renderer.
409+ dirty, securityKnown = haveScene, false
410+ cursorScale = -1
411+ reports.Reset()
412+ return nil
413+ }
310414 applyMode := func(mode domain.OutputMode) error {
311415 if mode.Width <= 0 || mode.Height <= 0 || mode.RefreshMilli < 0 {
312416 return fmt.Errorf("invalid output mode: %dx%d@%d", mode.Width, mode.Height, mode.RefreshMilli)
@@ -320,17 +424,10 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
320424 return fmt.Errorf("recreate renderer: %w", err)
321425 }
322426 if confirmed != nil {
323- next.SetHDR(203)
324- bufs, err := next.ExportTargets(1, nil, false)
325- if err != nil {
427+ if err := enableHDR(next, hdrSettings); err != nil {
326428 next.Close()
327429 return fmt.Errorf("recreate HDR targets: %w", err)
328430 }
329- for _, b := range bufs {
330- for _, p := range b.Planes {
331- _ = p.File.Close()
332- }
333- }
334431 }
335432 // Join workers and return every lease to its original renderer
336433 // before releasing any of that renderer's storage.
@@ -367,7 +464,12 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
367464 opts.ModeRequests = nil
368465 continue
369466 }
370- err := applyMode(req.Mode)
467+ var err error
468+ if req.HDR != nil {
469+ err = applyHDR(*req.HDR)
470+ } else {
471+ err = applyMode(req.Mode)
472+ }
371473 req.Result <- err
372474 if err != nil {
373475 return err
@@ -490,7 +592,8 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
490592 }
491593 return err
492594 }
493- // The cursor is only drawn into screenshots: no new frame.
595+ // Cursor images are sampled by captures and debug screenshots.
596+ // Motion alone does not redraw the display.
494597 want, cursorScale, cursorTransform = c, -1, 0
495598 }
496599 // Drain all queued updates before presenting one frame.
@@ -578,6 +681,10 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
578681 // Requests the scene cannot serve (exclusion of another session, a
579682 // workspace that moved) are failed here; see capture.Pipeline.Split.
580683 // A request whose indicator the scene does not show yet stays held.
684+ pipeline.Cursor = nil
685+ if opts.Cursor != nil && !opts.protected() {
686+ pipeline.Cursor = opts.Cursor.snapshot()
687+ }
581688 ready, _ := pipeline.Hold(scene, requests.List, time.Now())
582689 if len(scene.CaptureIndicators) > 0 {
583690 // The captures of this frame are delivered only once its frame,
@@ -760,7 +867,7 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
760867 return fmt.Errorf("frame index: %w", err)
761868 }
762869 lastShot, lastShotName = now, name
763- if opts.RawHDR && opts.HDR {
870+ if opts.RawHDR && opts.HDR.Enabled {
764871 // No cursor on the raw image. Only a confirmed HDR output
765872 // has a readable PQ target; else HDRPixels is nil.
766873 if opts.protected() || opts.Security != nil && opts.Security.Snapshot() != scene.Security {
@@ -24,8 +24,12 @@ import (
24 )24 )
25 25
26 // ModeRequest is a live mode transaction. Result must be buffered by its sender.26 // ModeRequest is a live mode transaction. Result must be buffered by its sender.
27+// A non-nil HDR replaces the output's HDR settings in place (same output,
28+// same screen): an enable or SDR white change rebuilds the renderer, a peak
29+// change only republishes the caps. Mode is then the current mode.
27 type ModeRequest struct {30 type ModeRequest struct {
28 Mode domain.OutputMode31 Mode domain.OutputMode
32+ HDR *domain.OutputHDRSettings
29 Result chan<- error33 Result chan<- error
30 }34 }
31 35
@@ -36,14 +40,19 @@ type Options struct {
36 SecurityChanges <-chan domain.SecurityState40 SecurityChanges <-chan domain.SecurityState
37 Instance domain.OutputInstance41 Instance domain.OutputInstance
38 SecurityEvents chan<- ports.SecurityBackendEvent42 SecurityEvents chan<- ports.SecurityBackendEvent
39- // Cursor, when set, is drawn into screenshots with the image from43+ // Cursor, when set, supplies cursor-requesting captures and debug screenshots
40- // LoadCursor at the scene scale and transform. The cursor is drawn in44+ // with the image from LoadCursor at the scene scale and transform. It is in
41 // target space: the image comes rotated and Move takes target pixels.45 // target space: the image comes rotated and Move takes target pixels.
42 Cursor *Cursor46 Cursor *Cursor
43 LoadCursor func(c domain.CursorChange, scale float64, t domain.BufferTransform, limit int) (domain.CursorImage, error)47 LoadCursor func(c domain.CursorChange, scale float64, t domain.BufferTransform, limit int) (domain.CursorImage, error)
44 Width, Height int48 Width, Height int
45 ScreenshotDir string49 ScreenshotDir string
46- HDR bool // virtual HDR output for protocol testing only50+ // HDR is the virtual output's HDR request (protocol testing only);
51+ // HDR.Enabled tries a PQ target and falls back to SDR when unavailable.
52+ HDR domain.OutputHDRSettings
53+ // HDRLuminance is the virtual display's luminance facts reported while
54+ // HDR is confirmed; zero uses DefaultVirtualHDRLuminance.
55+ HDRLuminance domain.OutputHDR
47 // RawHDR also writes latest-pq.png, the raw PQ codes of an HDR output56 // RawHDR also writes latest-pq.png, the raw PQ codes of an HDR output
48 // (16-bit), next to the screenshots. Test-only; needs HDR and ScreenshotDir.57 // (16-bit), next to the screenshots. Test-only; needs HDR and ScreenshotDir.
49 RawHDR bool58 RawHDR bool
@@ -93,50 +102,99 @@ func refreshPeriod(refresh int) time.Duration {
93 return period102 return period
94 }103 }
95 104
96-func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, contents <-chan *domain.ContentBatch, returns ports.ContentReturn, cursor <-chan domain.CursorChange, incoming <-chan domain.CaptureRequest) error {105+// DefaultVirtualHDRLuminance is the luminance a virtual HDR output reports
97- r, err := opts.NewRenderer(opts.Width, opts.Height)106+// when Options.HDRLuminance is unset.
107+var DefaultVirtualHDRLuminance = domain.OutputHDR{MaxLuminance: 1000, MaxFrameAverage: 400, MinLuminance: .005}
108+
109+// enableHDR switches r to a PQ target at the settings' SDR white and probes
110+// one exported target; the probe's files are closed. On error the caller
111+// falls back or discards r.
112+func enableHDR(r ports.Renderer, settings domain.OutputHDRSettings) error {
113+ r.SetHDR(float64(settings.Normalized().SDRBrightness))
114+ bufs, err := r.ExportTargets(1, nil, false)
98 if err != nil {115 if err != nil {
99- return fmt.Errorf("create renderer: %w", err)116+ return err
100 }117 }
101- defer func() { r.Close() }()118+ for _, b := range bufs {
102- var confirmed *domain.OutputHDR119+ for _, p := range b.Planes {
103- if opts.HDR {120+ _ = p.File.Close()
104- r.SetHDR(203)
105- if bufs, err := r.ExportTargets(1, nil, false); err != nil {
106- opts.Log.Warn().Err(err).Str("output", opts.Name).Msg("virtual HDR unavailable; falling back to SDR")
107- r.SetHDR(0)
108- _, _ = r.ExportTargets(0, nil, false)
109- } else {
110- for _, b := range bufs {
111- for _, p := range b.Planes {
112- _ = p.File.Close()
113- }
114- }
115- confirmed = &domain.OutputHDR{MaxLuminance: 1000, MaxFrameAverage: 400, MinLuminance: .005}
116- opts.Log.Info().Str("output", opts.Name).Msg("virtual HDR enabled")
117- }
118- if opts.Formats != nil {
119- select {
120- case opts.Formats <- domain.OutputFormats{Output: opts.Name, HDR: confirmed}:
121- case <-ctx.Done():
122- return nil
123- }
124 }121 }
125 }122 }
126- event := domain.OutputHDRCaps{Output: opts.Name}123+ return nil
127- in := domain.HDRCapsInput{Reason: "virtual HDR inactive", SDRWhiteNits: 203}124+}
125+
126+// setupHDR applies settings to a fresh renderer and returns the confirmed
127+// HDR luminance, nil for SDR (also when HDR was asked but is unavailable).
128+func setupHDR(r ports.Renderer, opts Options, settings domain.OutputHDRSettings) *domain.OutputHDR {
129+ if !settings.Enabled {
130+ return nil
131+ }
132+ if err := enableHDR(r, settings); err != nil {
133+ opts.Log.Warn().Err(err).Str("output", opts.Name).Msg("virtual HDR unavailable; falling back to SDR")
134+ r.SetHDR(0)
135+ _, _ = r.ExportTargets(0, nil, false)
136+ return nil
137+ }
138+ lum := opts.HDRLuminance
139+ if lum == (domain.OutputHDR{}) {
140+ lum = DefaultVirtualHDRLuminance
141+ }
142+ opts.Log.Info().Str("output", opts.Name).Msg("virtual HDR enabled")
143+ return &lum
144+}
145+
146+// reportFormats sends the confirmed color state; false when ctx ended.
147+func reportFormats(ctx context.Context, opts Options, confirmed *domain.OutputHDR) bool {
148+ if opts.Formats == nil {
149+ return true
150+ }
151+ select {
152+ case opts.Formats <- domain.OutputFormats{Output: opts.Name, HDR: confirmed}:
153+ return true
154+ case <-ctx.Done():
155+ return false
156+ }
157+}
158+
159+// reportCaps sends the HDR caps of settings and the confirmed state; false
160+// when ctx ended.
161+func reportCaps(ctx context.Context, opts Options, settings domain.OutputHDRSettings, confirmed *domain.OutputHDR) bool {
162+ if opts.Events == nil {
163+ return true
164+ }
165+ facts := domain.HDRCapsInput{Reason: "virtual HDR inactive"}
128 if confirmed != nil {166 if confirmed != nil {
129- in.Capable = true167+ facts.Capable = true
130- in.MaxLuminance, in.MaxFrameAverage, in.MinLuminance = confirmed.MaxLuminance, confirmed.MaxFrameAverage, confirmed.MinLuminance168+ facts.MaxLuminance, facts.MaxFrameAverage, facts.MinLuminance = confirmed.MaxLuminance, confirmed.MaxFrameAverage, confirmed.MinLuminance
131- event.Active = true
132 }169 }
133- event.Caps = domain.ResolveHDRCaps(in)170+ event := domain.NewOutputHDRCaps(opts.Name, settings, facts, confirmed != nil)
134- if opts.Events != nil {171+ select {
135- select {172+ case opts.Events <- ports.OutputHDRCaps{OutputHDRCaps: event}:
136- case opts.Events <- ports.OutputHDRCaps{OutputHDRCaps: event}:173+ return true
137- case <-ctx.Done():174+ case <-ctx.Done():
175+ return false
176+ }
177+}
178+
179+func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, contents <-chan *domain.ContentBatch, returns ports.ContentReturn, cursor <-chan domain.CursorChange, incoming <-chan domain.CaptureRequest) error {
180+ r, err := opts.NewRenderer(opts.Width, opts.Height)
181+ if err != nil {
182+ return fmt.Errorf("create renderer: %w", err)
183+ }
184+ defer func() { r.Close() }()
185+ hdrSettings := opts.HDR.Normalized()
186+ confirmed := setupHDR(r, opts, hdrSettings)
187+ // formats: whether the confirmed color state was reported (it is once
188+ // HDR was requested, so a later SDR state is reported too).
189+ formats := false
190+ if hdrSettings.Enabled {
191+ if !reportFormats(ctx, opts, confirmed) {
138 return nil192 return nil
139 }193 }
194+ formats = true
195+ }
196+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
197+ return nil
140 }198 }
141 table := surfaces.New()199 table := surfaces.New()
142 drawn := table.Map()200 drawn := table.Map()
@@ -307,6 +365,52 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
307 if holdDue == nil {365 if holdDue == nil {
308 holdTimer.Stop()366 holdTimer.Stop()
309 }367 }
368+ // applyHDR replaces the HDR settings in place. Enable and SDR white
369+ // rebuild the renderer (as DRM restarts its output) on the same
370+ // output: no screen is removed. The peak only changes the caps.
371+ applyHDR := func(want domain.OutputHDRSettings) error {
372+ want = want.Normalized()
373+ if want == hdrSettings {
374+ return nil
375+ }
376+ if want.Enabled == hdrSettings.Enabled && want.SDRBrightness == hdrSettings.SDRBrightness {
377+ hdrSettings = want
378+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
379+ return ctx.Err()
380+ }
381+ return nil
382+ }
383+ next, err := opts.NewRenderer(opts.Width, opts.Height)
384+ if err != nil {
385+ return fmt.Errorf("recreate renderer: %w", err)
386+ }
387+ nextConfirmed := setupHDR(next, opts, want)
388+ pipeline.EndGate(capture.ErrFrameNotPresented)
389+ pipeline.Close(r)
390+ r.Close()
391+ r = next
392+ pipeline = capture.NewPipeline(ctx, opts.Captured)
393+ pipeline.Security = opts.Security
394+ if opts.NewCaptureRenderer != nil {
395+ pipeline.EnableOffscreen(opts.NewCaptureRenderer)
396+ }
397+ requests.FailPending(capture.ErrFrameNotPresented)
398+ hdrSettings, confirmed = want, nextConfirmed
399+ if want.Enabled || formats {
400+ if !reportFormats(ctx, opts, confirmed) {
401+ return ctx.Err()
402+ }
403+ formats = true
404+ }
405+ if !reportCaps(ctx, opts, hdrSettings, confirmed) {
406+ return ctx.Err()
407+ }
408+ // Redraw the current scene on the new renderer.
409+ dirty, securityKnown = haveScene, false
410+ cursorScale = -1
411+ reports.Reset()
412+ return nil
413+ }
310 applyMode := func(mode domain.OutputMode) error {414 applyMode := func(mode domain.OutputMode) error {
311 if mode.Width <= 0 || mode.Height <= 0 || mode.RefreshMilli < 0 {415 if mode.Width <= 0 || mode.Height <= 0 || mode.RefreshMilli < 0 {
312 return fmt.Errorf("invalid output mode: %dx%d@%d", mode.Width, mode.Height, mode.RefreshMilli)416 return fmt.Errorf("invalid output mode: %dx%d@%d", mode.Width, mode.Height, mode.RefreshMilli)
@@ -320,17 +424,10 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
320 return fmt.Errorf("recreate renderer: %w", err)424 return fmt.Errorf("recreate renderer: %w", err)
321 }425 }
322 if confirmed != nil {426 if confirmed != nil {
323- next.SetHDR(203)427+ if err := enableHDR(next, hdrSettings); err != nil {
324- bufs, err := next.ExportTargets(1, nil, false)
325- if err != nil {
326 next.Close()428 next.Close()
327 return fmt.Errorf("recreate HDR targets: %w", err)429 return fmt.Errorf("recreate HDR targets: %w", err)
328 }430 }
329- for _, b := range bufs {
330- for _, p := range b.Planes {
331- _ = p.File.Close()
332- }
333- }
334 }431 }
335 // Join workers and return every lease to its original renderer432 // Join workers and return every lease to its original renderer
336 // before releasing any of that renderer's storage.433 // before releasing any of that renderer's storage.
@@ -367,7 +464,12 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
367 opts.ModeRequests = nil464 opts.ModeRequests = nil
368 continue465 continue
369 }466 }
370- err := applyMode(req.Mode)467+ var err error
468+ if req.HDR != nil {
469+ err = applyHDR(*req.HDR)
470+ } else {
471+ err = applyMode(req.Mode)
472+ }
371 req.Result <- err473 req.Result <- err
372 if err != nil {474 if err != nil {
373 return err475 return err
@@ -490,7 +592,8 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
490 }592 }
491 return err593 return err
492 }594 }
493- // The cursor is only drawn into screenshots: no new frame.595+ // Cursor images are sampled by captures and debug screenshots.
596+ // Motion alone does not redraw the display.
494 want, cursorScale, cursorTransform = c, -1, 0597 want, cursorScale, cursorTransform = c, -1, 0
495 }598 }
496 // Drain all queued updates before presenting one frame.599 // Drain all queued updates before presenting one frame.
@@ -578,6 +681,10 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
578 // Requests the scene cannot serve (exclusion of another session, a681 // Requests the scene cannot serve (exclusion of another session, a
579 // workspace that moved) are failed here; see capture.Pipeline.Split.682 // workspace that moved) are failed here; see capture.Pipeline.Split.
580 // A request whose indicator the scene does not show yet stays held.683 // A request whose indicator the scene does not show yet stays held.
684+ pipeline.Cursor = nil
685+ if opts.Cursor != nil && !opts.protected() {
686+ pipeline.Cursor = opts.Cursor.snapshot()
687+ }
581 ready, _ := pipeline.Hold(scene, requests.List, time.Now())688 ready, _ := pipeline.Hold(scene, requests.List, time.Now())
582 if len(scene.CaptureIndicators) > 0 {689 if len(scene.CaptureIndicators) > 0 {
583 // The captures of this frame are delivered only once its frame,690 // The captures of this frame are delivered only once its frame,
@@ -760,7 +867,7 @@ func RunOutput(ctx context.Context, opts Options, scenes <-chan domain.Scene, co
760 return fmt.Errorf("frame index: %w", err)867 return fmt.Errorf("frame index: %w", err)
761 }868 }
762 lastShot, lastShotName = now, name869 lastShot, lastShotName = now, name
763- if opts.RawHDR && opts.HDR {870+ if opts.RawHDR && opts.HDR.Enabled {
764 // No cursor on the raw image. Only a confirmed HDR output871 // No cursor on the raw image. Only a confirmed HDR output
765 // has a readable PQ target; else HDRPixels is nil.872 // has a readable PQ target; else HDRPixels is nil.
766 if opts.protected() || opts.Security != nil && opts.Security.Snapshot() != scene.Security {873 if opts.protected() || opts.Security != nil && opts.Security.Snapshot() != scene.Security {
M internal/adapters/headless/output_test.go +2 -2
M internal/adapters/headless/security_test.go +1 -1
M internal/adapters/outputkit/capture/capture.go +7 -0
M internal/adapters/outputkit/capture/excluded.go +3 -1
M internal/adapters/outputkit/capture/pipeline.go +156 -10
A internal/adapters/outputkit/capture/pipeline_cursor_test.go +69 -0
A internal/adapters/outputkit/capture/pipeline_dmabuf_test.go +132 -0
A internal/adapters/outputkit/capture/pipeline_pq_test.go +104 -0
M internal/adapters/outputkit/headlessbackend/backend.go +1 -1
M internal/adapters/outputkit/virtuals/virtuals.go +29 -12
M internal/adapters/outputkit/virtuals/virtuals_test.go +124 -0
A internal/adapters/screencast/allocator.go +170 -0
A internal/adapters/screencast/allocator_test.go +169 -0
M internal/adapters/screencast/harness_test.go +17 -0
M internal/adapters/screencast/producer.go +95 -25
A internal/adapters/screencast/producer_hdr_test.go +153 -0
M internal/adapters/screencast/producer_test.go +39 -6
M internal/adapters/screencast/screencast.go +5 -0
M internal/adapters/screencast/seams.go +1 -0
M internal/adapters/screencast/shutdown_test.go +13 -3
M internal/adapters/screencast/stream.go +29 -10
M internal/adapters/screencast/video_source_mock_test.go +57 -0
M internal/adapters/vulkan/capture.go +52 -5
A internal/adapters/vulkan/capture_cursor.go +195 -0
A internal/adapters/vulkan/capture_cursor_test.go +166 -0
A internal/adapters/vulkan/capture_dmabuf.go +325 -0
A internal/adapters/vulkan/capture_dmabuf_test.go +185 -0
A internal/adapters/vulkan/capture_pq.go +136 -0
A internal/adapters/vulkan/capture_pq_test.go +69 -0
A internal/adapters/vulkan/cast_alloc.go +171 -0
A internal/adapters/vulkan/cast_alloc_test.go +166 -0
A internal/adapters/vulkan/cast_sync_test.go +112 -0
M internal/adapters/vulkan/compose.go +5 -0
M internal/adapters/vulkan/copy.go +38 -22
M internal/adapters/vulkan/dmabuf.go +8 -1
A internal/adapters/vulkan/dmabuf_fences_mock_test.go +258 -0
M internal/adapters/vulkan/frame.go +8 -0
M internal/adapters/vulkan/hdr.go +5 -3
M internal/adapters/vulkan/renderer.go +5 -2
A internal/adapters/vulkan/shaders/capture_cursor.frag +30 -0
A internal/adapters/vulkan/shaders/capture_cursor.frag.spv +0 -0 binary file: no text diff
M internal/adapters/wayland/colormanagement_test.go +46 -0
D internal/adapters/wayland/content_source.go +0 -84
D internal/adapters/wayland/content_source_test.go +0 -144
M internal/adapters/wayland/dmabuf.go +1 -0
M internal/adapters/wayland/outputs.go +3 -0
M internal/adapters/wayland/screencast.go +34 -9
M internal/adapters/wayland/screencast_test.go +59 -13
M internal/adapters/wayland/screencopy.go +96 -11
A internal/adapters/wayland/screencopy_dmabuf_test.go +197 -0
M internal/adapters/wayland/seat.go +0 -1
M internal/adapters/wayland/server.go +11 -1
M internal/adapters/wayland/session_lock.go +1 -0
M internal/adapters/wayland/surface.go +15 -15
M internal/adapters/wayland/winstats.go +3 -5
M internal/adapters/wayland/x11window.go +7 -5
M internal/adapters/wayland/x11window_test.go +42 -1
M internal/adapters/wayland/xdg.go +1 -1
M internal/adapters/wayland/xwm/selection_test.go +21 -71
A internal/app/screencast_hdr_test.go +150 -0
M internal/app/screencast_test.go +12 -5
M internal/app/session.go +15 -13
M internal/app/testdata/x11probe/main.go +98 -4
A internal/app/xwayland_keepfocus_test.go +167 -0
M internal/app/xwayland_test.go +34 -2
M internal/core/client.go +3 -1
M internal/core/configdiff_test.go +6 -0
M internal/core/core.go +7 -0
M internal/core/drag_test.go +4 -1
M internal/core/outputoverrides.go +8 -1
M internal/core/rules.go +20 -6
M internal/core/rules_test.go +63 -3
M internal/core/scene.go +2 -1
M internal/core/security.go +7 -0
M internal/core/spawn_placement.go +14 -12
M internal/core/transition.go +10 -8
M internal/core/virtual_test.go +1 -0
A internal/core/x11active.go +98 -0
A internal/core/x11active_test.go +350 -0
A internal/domain/capture_cursor.go +11 -0
M internal/domain/capture_messages.go +31 -1
A internal/domain/capture_messages_test.go +27 -0
A internal/domain/cast_formats.go +23 -0
A internal/domain/cast_formats_test.go +23 -0
M internal/domain/config.go +3 -0
A internal/domain/hdr_settings.go +33 -0
A internal/domain/hdr_settings_test.go +44 -0
M internal/domain/screencast_messages.go +10 -8
M internal/mocks/ports/devices_mock.go +521 -0
M internal/ports/client_commands.go +8 -0
M internal/ports/devices.go +38 -0

Comments00 unresolved

    no comments yet.

    Keyboard shortcuts

    Single-key shortcuts are on. ctrl k and esc work whatever this says.

    ctrl k :
    go to a section, branch, tag, file or repository
    ?
    this list
    j k
    move the row cursor down / up
    enter
    open the row under the cursor; on Files, a directory opens or closes in place
    ↑ ↓ ← → home end
    in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
    l h
    on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
    g g G
    first / last row
    /
    filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
    b
    switch branch or tag
    g s g f g c g b g m g i g r g a
    tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
    g h
    home
    w
    wide mode: use the whole width of the screen, or not (remembered)
    y
    copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
    d u x
    diff: split / unified / collapse or expand all
    e E
    diff: the whole file in view / every file, with the lines the hunks hide
    n
    merge request: next note in the diff
    l
    merge request: the list of files (j k move, enter opens, esc back)
    M
    merge request: the merge menu; there 1–3 pick the mode, D deletes the branch, enter merges
    R
    merge request: mark the head read
    esc
    close a dialog, leave a field

    Branches 33

    Tags 15

    ↑↓ moveenter openesc close