From ab9acc30ac1e0642acbb6952c2dc1292a76078eb Mon Sep 17 00:00:00 2001 From: Max <112043822+Maxaubert@users.noreply.github.com> Date: Sun, 8 Nov 2026 04:33:52 +0100 Subject: [PATCH] mac: Backdrop always zooms with Nearest (no cubic blur) Backdrop mapped renderScaling xBR to WindowServer's cubic filter, and the Scaling row is hidden on Backdrop, so picking xBR on Render left Backdrop blurry with no way to change it. Every magnificationFilter but nearest smooths there: a 1 px checker at 3x is 87% grey on cubic and linear (lanczos and box read as linear), 2% on nearest. - DrawZoom.placeBackdrop: always .nearest - scripts/backdrop_sharp.py: checker grabbed at backing resolution, both renderScaling values must stay sharp - dispcap: DISPCAP_PIXELS=1 grabs at the display's pixel size - VERSION 0.5.7 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SkyGaRqAYDGgt6rzry3bwu --- mac/CLAUDE.md | 1 + mac/Sources/Wind/DrawZoom.swift | 5 ++++- mac/VERSION | 2 +- mac/docs/architecture.md | 5 ++++- mac/scripts/backdrop_sharp.py | 40 +++++++++++++++++++++++++++++++++ mac/tools/cursorchurn/dispcap.m | 5 ++++- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100755 mac/scripts/backdrop_sharp.py diff --git a/mac/CLAUDE.md b/mac/CLAUDE.md index 8930d526..915361bf 100644 --- a/mac/CLAUDE.md +++ b/mac/CLAUDE.md @@ -46,6 +46,7 @@ How the macOS zoom behaves and why: `docs/architecture.md`. Keep it in step with - `python3 scripts/tooltip_truth.py`: AppKit tooltips while zoomed (takes the screen with an active probe window); run it after touching how Wind hides the real cursor. - `python3 scripts/hitch_truth.py`: view stalls as apps open, quit and alerts show, from Wind's `slow tick` lines (`Stall`); run it after touching anything on the main thread's tick path. - `python3 scripts/backdrop_truth.py`: the Backdrop engine (no capture); `WIND_ENGINE=backdrop` runs a suite on it. ScreenCaptureKit cannot see it (`tools/cursorchurn/dispcap` can). +- `python3 scripts/backdrop_sharp.py`: Backdrop stays Nearest (sharp) with either `renderScaling`, scored on a 1 px checker. - `python3 scripts/edge_truth.py`: the pinned view at screen edges on the zoomed screen (edge shake). - `python3 scripts/wobble_from_log.py [HH:MM:SS]`: cursor wobble from a real session in the log (logLevel 2). - `python3 scripts/e2e_screenshot.py`: screenshot mode (area, window, Cmd+Shift+5) and the colour sampler while diff --git a/mac/Sources/Wind/DrawZoom.swift b/mac/Sources/Wind/DrawZoom.swift index 44fb20dc..410431cc 100644 --- a/mac/Sources/Wind/DrawZoom.swift +++ b/mac/Sources/Wind/DrawZoom.swift @@ -198,7 +198,10 @@ final class DrawZoom: NSObject, SCStreamOutput, SCStreamDelegate, @unchecked Sen let at = CGPoint(x: px, y: H - py) if abs(at.x - b.position.x) > 0.01 || abs(at.y - b.position.y) > 0.01 { backdropMovedAt = CACurrentMediaTime() } b.position = at - b.magnificationFilter = scaling == .nearest ? .nearest : CALayerContentsFilter(rawValue: "cubic") + // Always nearest: every other filter WindowServer takes here (cubic, linear, trilinear; lanczos and box + // read as linear) greys a 1 px checker to 72-89% at 3x and 4.37x, nearest to 2% (backdrop_sharp.py, + // owner 2026-11-08: "smoothness which makes things blurry", after xBR on Render had picked cubic here). + b.magnificationFilter = .nearest } /// What is below reaches the screen only as far as the overlay's commit dirties the backdrop. With it idle diff --git a/mac/VERSION b/mac/VERSION index b49b2533..d3532a10 100644 --- a/mac/VERSION +++ b/mac/VERSION @@ -1 +1 @@ -0.5.6 +0.5.7 diff --git a/mac/docs/architecture.md b/mac/docs/architecture.md index 30951e33..0e41c214 100644 --- a/mac/docs/architecture.md +++ b/mac/docs/architecture.md @@ -1138,7 +1138,10 @@ above the overlay, so it stays unmagnified on the zoomed view. It cannot be cove unmagnified, and the lock screen shows unmagnified above the overlay: `DrawZoom.lockUp` gives the real cursor back meanwhile and restarts a capture it stopped. loginwindow also owns the Restart and Shut Down prompts: only `CGSSessionScreenIsLocked`, or a window above the overlay, counts as the lock screen (owner 2026-11-04: the prompt brought the tiny cursor). Tests never open the real prompt, which restarts by itself after 60 s. -- No pixels reach Wind, so no xBR: `renderScaling` 0 is Nearest, 1 is `cubic` (the Scaling row is Render's only for now). +- No pixels reach Wind, so no xBR: Backdrop is always Nearest, whatever `renderScaling` holds (the Scaling row is Render's). + Until 0.5.7 it mapped xBR to `cubic`, which blurred the view with no row to change it (owner 2026-11-08). Every + `magnificationFilter` but nearest smooths here: a 1 px checker at 3x is 87% grey on linear (lanczos and box read as + linear) and on cubic, 2% on nearest. `scripts/backdrop_sharp.py` checks it with both `renderScaling` values. - What is below reaches the screen only as far as a commit dirties the backdrop, so `keepAliveTick` nudges the backdrop layer itself 0.001 pt on every refresh the view does not move it. A nudge of the cursor layer alone, or a tick with the view still, redrew part of the view: a Terminal scrolled with the pointer still tore in half (owner 2026-11-04; `dispcap --tear`, whole-window flips: 666 of 828 frames torn, 2 of diff --git a/mac/scripts/backdrop_sharp.py b/mac/scripts/backdrop_sharp.py new file mode 100755 index 00000000..8353f807 --- /dev/null +++ b/mac/scripts/backdrop_sharp.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 Max Aubert. All rights reserved. +# Proprietary source-available software; see LICENSE. SPDX-License-Identifier: LicenseRef-Wind-Proprietary +"""Backdrop sharpness: a 1-pixel checker (tools/scalecard) magnified by Backdrop, grabbed at the backing resolution +(tools/cursorchurn/dispcap with DISPCAP_PIXELS) and scored by the share of grey pixels. Backdrop is always Nearest +(about none grey) with renderScaling 0 or 1 (owner 2026-11-08: xBR had picked macOS's cubic there, 87% grey). +usage: backdrop_sharp.py [--level 3]""" +import argparse, os, subprocess, sys, time +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import windtest as W +from PIL import Image +ap = argparse.ArgumentParser(); ap.add_argument("--level", type=float, default=3); a = ap.parse_args() +T = os.path.join(W.ROOT, "tools"); OUT = os.path.join(W.ROOT, "build/backdrop-sharp"); os.makedirs(OUT, exist_ok=True) +subprocess.run([T + "/cursorchurn/build.sh"], check=True, stdout=subprocess.DEVNULL) +subprocess.run([T + "/scalecard/build.sh"], check=True, stdout=subprocess.DEVNULL) +W.relaunch_with_channel(direct=True, extra={"engine": "backdrop", "cursor": "wind", "renderScaling": 0}) +CX, CY, CW, CH = 400, 300, 600, 400 +card = subprocess.Popen([T + "/scalecard/scalecard", "card", str(CX), str(CY), str(CW), str(CH), "120"], stdout=subprocess.PIPE, text=True) +card.stdout.readline(); time.sleep(0.5) +qx, qy = CX + CW / 2 + 10, CY + 6 # the checker's top-left (points): 48x24 cells of 0.5 pt +px, py = qx + 12, qy + 50 # the pointer below it, so the drawn cursor stays off it +W.ctl("level 1"); W.ctl(f"warp {px} {py}"); time.sleep(0.4); W.ctl(f"level {a.level}"); time.sleep(1.5) +c = W.ctl("state")["sky"]["center"] + +def grey(tag): + png = os.path.join(OUT, tag + ".png") + subprocess.run([T + "/cursorchurn/dispcap", png, "0.6"], check=True, env=dict(os.environ, DISPCAP_PIXELS="1")) + im = Image.open(png).convert("L"); S = im.width / 1920; L = a.level + x0 = (960 + (qx - c[0]) * L) * S; y0 = (540 + (qy - c[1]) * L) * S + cr = im.crop((int(x0 + 3 * S * L), int(y0 + 3 * S * L), int(x0 + 21 * S * L), int(y0 + 9 * S * L))) + cr.save(os.path.join(OUT, tag + "-crop.png")) + v = list(cr.get_flattened_data()) + return sum(1 for p in v if 50 < p < 205) / len(v) + +for sc in (0, 1): + W.set_config(renderScaling=sc); time.sleep(1) + g = grey(f"scaling{sc}") + W.check(f"Backdrop sharp with renderScaling {sc}", g < 0.08, f"{g * 100:.1f}% grey pixels in the checker") +W.set_config(renderScaling=None) +W.ctl("level 1"); time.sleep(0.5); card.kill(); W.finish() diff --git a/mac/tools/cursorchurn/dispcap.m b/mac/tools/cursorchurn/dispcap.m index 8756a86f..a2f46e10 100644 --- a/mac/tools/cursorchurn/dispcap.m +++ b/mac/tools/cursorchurn/dispcap.m @@ -38,7 +38,10 @@ int main(int argc, char **argv) { if (!strcmp(argv[1], "--tear")) return tear(argc, argv, create, start); NSDictionary *props = @{ @"kCGDisplayStreamShowCursor": @NO, @"kCGDisplayStreamMinimumFrameTime": @(1.0/240) }; double t0 = CFAbsoluteTimeGetCurrent(); - void *s = create(CGMainDisplayID(), 1920, 1080, 'BGRA', (__bridge CFDictionaryRef)props, dispatch_queue_create("cap", 0), + // DISPCAP_PIXELS=1: at the display's backing resolution (sharpness checks), not 1920x1080 points. + size_t W = 1920, Hh = 1080; + if (getenv("DISPCAP_PIXELS")) { CGDisplayModeRef m = CGDisplayCopyDisplayMode(CGMainDisplayID()); W = CGDisplayModeGetPixelWidth(m); Hh = CGDisplayModeGetPixelHeight(m); CGDisplayModeRelease(m); } + void *s = create(CGMainDisplayID(), W, Hh, 'BGRA', (__bridge CFDictionaryRef)props, dispatch_queue_create("cap", 0), ^(int status, uint64_t dt, IOSurfaceRef surf, void *upd) { if (status != 0 || !surf || CFAbsoluteTimeGetCurrent() - t0 < secs) return; IOSurfaceLock(surf, kIOSurfaceLockReadOnly, NULL);