diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 6fdfaf28a..1782e4b7d 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -19383,8 +19383,10 @@ const CURRENCIES = [["usd", "$ USD"], ["cny", "¥ CNY"], ["provider", "By provid // The text size is the windows' own zoom, as a browser's Ctrl/Cmd +: the // page is laid out again in larger CSS pixels, so everything it measures is // as at 100%, and magpie sizes the windows around it (textsize.go). None is -// under 100%: WebView2 and WebKitGTK zoom no smaller through Wails. -const TEXT_SIZES = [100, 110, 125, 150]; +// under 100%: WebView2 and WebKitGTK zoom no smaller through Wails. 115 and +// 120 sit between 110 and 125, where 110 read small and 125 crowded on a 4K +// screen at 200% (WeltAn_X on X). +const TEXT_SIZES = [100, 110, 115, 120, 125, 150]; const textSizeKeys = () => /^Mac/.test(navigator.platform) ? "⌘+ ⌘− ⌘0" : "Ctrl+ Ctrl− Ctrl+0"; // --zoom is the text size for what is placed against the window's own // drawing, which does not grow with the page: the Mac's traffic lights. diff --git a/internal/gui/tests/text-size.test.cjs b/internal/gui/tests/text-size.test.cjs index 35654d081..ccac51c5c 100644 --- a/internal/gui/tests/text-size.test.cjs +++ b/internal/gui/tests/text-size.test.cjs @@ -1,8 +1,8 @@ // Run with Node's test runner and Playwright on the module path; see README.md. // The Text size setting (Settings → Preferences, Ctrl/Cmd + − 0): a pick // posts to /api/settings/text-size and stays picked after a reload (boot.js -// carries it); the shortcuts step through 100/110/125/150% and back, in the -// window and the tray panel, and a click on the control never scrolls the +// carries it); the shortcuts step through 100/110/115/120/125/150% and +// back, in the window and the tray panel, and a click on the control never scrolls the // page. The zoom itself is the webview's (Go), so here it is as a browser // zoomed: the window's points over the zoom in CSS pixels, deviceScaleFactor // the zoom — and at 150% nothing in any view runs off to the side, the Mac @@ -139,7 +139,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const segs = page.locator("#textSizeSegs .opt"); await segs.first().waitFor(); assert.equal((await page.locator("#textSizeRow .name").textContent()).trim(), name); - assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["100%", "110%", "125%", "150%"]); + assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["100%", "110%", "115%", "120%", "125%", "150%"]); assert.equal(await segs.nth(0).evaluate((b) => b.classList.contains("on")), true, "100% starts picked"); // the name alone (1ooogle on X), the keys in the choices' tooltip assert.equal(await page.locator("#textSizeRow .sub").count(), 0); @@ -151,7 +151,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", for (let i = 0; i < 20 && !(await settingsTop(page)); i++) { await page.mouse.wheel(0, 30); await page.waitForTimeout(20); } const before = await settingsTop(page); assert(before > 0, "the settings list must scroll"); - await segs.nth(2).click(); + await segs.nth(4).click(); await page.locator("#textSizeSegs .opt.on", { hasText: "125%" }).waitFor(); await page.waitForTimeout(300); assert.equal(await settingsTop(page), before, "picking a text size must not scroll the settings page"); @@ -195,11 +195,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const mod = await page.evaluate(() => /^Mac/.test(navigator.platform) ? "Meta" : "Control"); await page.locator("#view-agents").waitFor(); assert.equal(await zoomVar(page), "1.1"); - await page.keyboard.press(mod + "+Equal"); + // the steps between 110 and 125 (WeltAn_X on X: 110 small, 125 + // crowded at 4K and 200%), one at a time + for (const n of ["1.15", "1.2", "1.25"]) { + await page.keyboard.press(mod + "+Equal"); + await page.waitForFunction((n) => getComputedStyle(document.documentElement).getPropertyValue("--zoom").trim() === n, n); + } + await page.keyboard.press(mod + "+Minus"); await page.waitForTimeout(200); await page.keyboard.press(mod + "+Digit0"); await page.waitForTimeout(200); - assert.deepEqual(posts, [125, 100]); + assert.deepEqual(posts, [115, 120, 125, 120, 100]); assert.deepEqual(page.errors, []); await page.context().close(); }); diff --git a/internal/settings/settings.go b/internal/settings/settings.go index 5bc6e2ba9..dc14ff0aa 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -1581,7 +1581,9 @@ var ( UpdateEveries = []int{30, 60, 360, 1440} // TextSizes are TextSize's values, in percent. None is under 100: the // webviews' zoom on Windows and Linux (Wails' SetZoom) goes no lower. - TextSizes = []int{100, 110, 125, 150} + // 115 and 120 are the steps between 110 and 125 (WeltAn_X on X: 110 + // small, 125 crowded at 4K and 200%). + TextSizes = []int{100, 110, 115, 120, 125, 150} ) // SearchFirst's values: a provider's search first, saved as "", or the diff --git a/internal/settings/settings_test.go b/internal/settings/settings_test.go index 797756ebc..abfc59c4a 100644 --- a/internal/settings/settings_test.go +++ b/internal/settings/settings_test.go @@ -61,10 +61,12 @@ func TestRoundTrip(t *testing.T) { if Save(Settings{}) != nil || Load().TextSize != DefaultTextSize() { t.Fatalf("default text size: %+v", Load()) } - if Save(Settings{TextSize: 125}) != nil || Load().TextSize != 125 { - t.Fatal("text size not kept") + for _, n := range []int{115, 120, 125} { + if Save(Settings{TextSize: n}) != nil || Load().TextSize != n { + t.Fatalf("text size %d not kept", n) + } } - for _, bad := range []int{90, 120, 300, -1} { + for _, bad := range []int{90, 105, 130, 300, -1} { if Save(Settings{TextSize: bad}) == nil { t.Fatalf("text size %d accepted", bad) }