diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index aed8fe484..700ed4afb 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -37,7 +37,7 @@ three. 7. The page's header is the window's title bar. `plainTitlebar` sets it up once the app has started, and again on a window lightweight mode made again (`madeAgain`). On Linux it hides GTK's title bar and keeps the shadow and the resize edges; GTK 3 leaves the corners square. On the Mac the traffic lights are inset into the header (`MacTitleBarHiddenInset`). In the design of macOS 26 a window with a toolbar has larger corners than one with a plain title bar, so `insetLights` ([`titlebar_darwin.go`](../../internal/gui/titlebar_darwin.go)) takes the toolbar off, and `MagpieLights` keeps the lights and the title bar's height where the toolbar had them: after a resize, a new title, light or dark, more contrast or less transparency, and leaving full screen. A sheet, such as the folder chooser, still begins below the title bar. A first press while another app is in front still moves the window from anywhere in that title bar (`firstPress`), as AppKit moved it with the toolbar; AppKit itself now does so only in a plain title bar's top 32pt. AppKit gives a program that design from macOS 26 when the program is linked against the macOS 26 SDK or a later one and its Info.plist doesn't ask for the earlier design (`UIDesignRequiresCompatibility`); `designOf26` reads each at run time, as the SDK depends on the toolchain that built magpie. The toolbar stays in the earlier design, where it doesn't change the corners, with the lights on the right (a right-to-left language), or when the title bar isn't laid out as expected; this is decided once, when the window is set up. In full screen the title bar is AppKit's own. Windows keeps its own title bar. 8. On the Mac, Settings › Show in Dock puts magpie in the Dock never (`DockNever`), while the window is open (the default; `DockWindow` records it chosen, for an older magpie that took none for never) or always (`Dock`, which wins). The default was never until ShouguangCao on X found the open window out of Command-Tab, so going back to it to paste a key copied elsewhere took the menu bar; a new install (no settings.json) reads With window, and Hide is a choice of its own (`inDock`, `dockChoice` in app.js, `TestDockFollowsWindowByDefault`, `dock-choice.test.cjs`). A file written before that has no `dockSettled`, and stored Hide as nothing, so a user who chose Hide can't be told from one who never chose: such a file with no Dock choice reads as Hide, and the first save writes it so with `dockSettled` (`settleDock`, `TestOlderSettingsKeepHide`, `TestNewInstallFollowsWindow`). A file nobody can read reads the same way. The page never sends `dockSettled`; the save keeps the file's (`TestSettingsSaveKeepsDockReading`). It is this computer's own, as the Dock choice is (`KeepOwn`). A full-screen window joins it whatever the setting (`inDock`, `dockOnFullscreen`). `openMain` joins before it shows the window (`setDock` runs on the main thread at once). An app activated out of the Dock (the quick panel's focus) that then joins it stays last in Command-Tab's order though it is in front, so joining to the front activates magpie by way of the Dock (`dockStep`, `activateAgain`; #1381, `TestDockStep`, `TestDockJoinLeadsCommandTab`). It does so without asking NSApp whether magpie is active: the Mac makes it the front app at once, and NSApp says so only once the main thread has taken that in, after the join on a busy Mac (#1651). 9. Settings › General › Quick panel shortcut binds a key combination that opens the tray's panel from any app (ben hanks on Discord); none is set by default. The page records the keys and posts them to `POST /api/settings/panel-shortcut`, which checks them (`panelShortcut`: a letter, digit, Space or F1–F20 with Ctrl, Alt/Option or Cmd/Super, or an F key alone, written as Wails' accelerator), has the running app bind them (`onPanelShortcut`, `bindPanelKey` through Wails' `GlobalShortcut`: Carbon's hot keys on the Mac, `RegisterHotKey` on Windows, `XGrabKey` on X11) and saves them only once bound. One the system refuses (on Windows and X11, another app holding it) is not saved and the old one stays bound; one saved but refused as magpie starts is retried after a handed-over magpie exits and else said in the row (`panelKeysJSON.Taken`). A pressed shortcut toggles the panel as a tray click does (`togglePanel`). The Mac's Carbon hot keys don't refuse a combination another app registered too, so there both are taken and magpie can't tell the user. The shortcut is per computer (`KeepOwn`), and the Mac's old process lets go of it as it hands over (`leaveMenuBar`). On Wayland no app may grab keys itself, so the field is off and the row says the command to bind in the desktop's own keyboard settings (`magpie panel`); Wails' GlobalShortcuts portal is not used, since the compositor decides its keys and Hyprland binds none unless configured. From there a not-connected Claude Code's or Codex's opened row switches its account (shuizhuyu on X, [Switch accounts only](providers-accounts.md)). -10. A click on the tray icon opens the quick panel, or the main window when Settings › General › Click the tray icon to says so. The panel opens the main window from the header's icon (`#open`, named "Open the main window"; its foot keeps Profiles, the status line and Quit, `panel-open-once.test.cjs`). On Windows a double-click on the icon opens the main window too (isaac_bai on Discord): Wails passes the icon's `WM_LBUTTONDBLCLK` on as `OnDoubleClick`, the panel its first click opened is hidden by `openMain`, and the `WM_LBUTTONUP` that ends the double-click is swallowed once (`trayDouble`, within `trayDoubleRelease`) so it does not open the panel over the window. The Mac's status item calls its action on each mouse-down with no click count, and Linux's StatusNotifierItem has only `Activate`, so there a double-click is two clicks and is left as such (`trayDoubleClicks`, `TestTrayDoubleClickOpensTheWindowOnWindowsOnly`, `TestTrayDoubleClickReleaseSwallowedOnce`; [`traydouble.go`](../../internal/gui/traydouble.go)). +10. A click on the tray icon opens the quick panel, or the main window when Settings › General › Click the tray icon to says so. The panel opens the main window from one control, on its edge nearest the tray (isaac_bai on Discord): hung below its icon (the Mac's menu bar, a taskbar or bar at the top) it is the header's icon (`#open`, named "Open the main window"); standing above it (Windows' taskbar at the bottom, a bottom panel on Linux) it is the foot's "Open the main window" left of Quit (`#openMain`), and the header has no icon. The two are never shown together (yogurt36 on Discord). Once `togglePanelNow` has placed and shown the panel, `tellPanelSide` reads the panel's bounds and its screen's and sends `magpiePanelOpenAt("foot")` when the panel is nearer the screen's bottom, `"head"` otherwise (`panelOpenAt`; the Mac is always `head`). Under Wayland a window can't read where the compositor put it, and until the app says, layout.js sets `body[data-open-at]` by the system: `foot` on Windows, `head` elsewhere ([`panelside.go`](../../internal/gui/panelside.go), `TestPanelOpensTheWindowFromTheEdgeNearestTheTray`, `panel-open-once.test.cjs`). On Windows a double-click on the icon opens the main window too (isaac_bai on Discord): Wails passes the icon's `WM_LBUTTONDBLCLK` on as `OnDoubleClick`, the panel its first click opened is hidden by `openMain`, and the `WM_LBUTTONUP` that ends the double-click is swallowed once (`trayDouble`, within `trayDoubleRelease`) so it does not open the panel over the window. The Mac's status item calls its action on each mouse-down with no click count, and Linux's StatusNotifierItem has only `Activate`, so there a double-click is two clicks and is left as such (`trayDoubleClicks`, `TestTrayDoubleClickOpensTheWindowOnWindowsOnly`, `TestTrayDoubleClickReleaseSwallowedOnce`; [`traydouble.go`](../../internal/gui/traydouble.go)). ## Constraints and failure behavior diff --git a/internal/gui/app.go b/internal/gui/app.go index eac0a2ac8..dbb12d377 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -924,9 +924,29 @@ func (h *host) togglePanelNow() { } _ = h.tray.PositionWindow(h.panel, 6) showWebview(h.panel).Focus() + h.tellPanelSide() return } h.tray.ToggleWindow() + if h.panel.IsVisible() { + h.tellPanelSide() + } +} + +// tellPanelSide tells the panel, just placed, which of its edges opens the +// main window: the one nearest the tray (panelOpenAt). Wayland doesn't say +// where the compositor put a window, so there it goes by the system. +func (h *host) tellPanelSide() { + b := h.panel.Bounds() + panel := panelRect{b.X, b.Y, b.Width, b.Height} + var screen panelRect + known := !waylandSession(runtime.GOOS, os.Getenv) + if s, err := h.panel.GetScreen(); err == nil && s != nil { + screen = panelRect{s.Bounds.X, s.Bounds.Y, s.Bounds.Width, s.Bounds.Height} + } else { + known = false + } + h.panel.ExecJS(panelOpenAtJS(panelOpenAt(runtime.GOOS, panel, screen, known))) } // placePanel puts the panel, about to open, under Hyprland's bar at the diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index f8e301d5b..b6f522000 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -212,7 +212,11 @@ body.window.mac .seg { top: calc(50% + 1px / var(--zoom, 1)); } /* 50% centres i .brand { display: flex; align-items: center; gap: 6px; font-weight: 600; letter-spacing: .01em; } body.window:not(.mac):not(.linux):not(.web) .brand { display: none; } /* Windows' title bar above already shows the icon and the name; a browser tab has no title bar of the app's */ /* app.js removes these controls later; keep them out of the first paint too. */ -body.window :is(#open, #quit), +body.window :is(#open, #openMain, #quit), +/* one control opens the main window, on the panel's edge nearest the tray + (panelside.go): the header's icon, or the foot's button left of Quit */ +body.panel[data-open-at="foot"] .top #open, +body:not([data-open-at="foot"]) #openMain, body:not(.window.linux) #winclose { display: none; } /* Linux: the header is the title bar, so it closes the window too — round, as GNOME draws its close button, and set a little apart from the icons */ diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 3f29308a3..37a94ac46 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -23365,12 +23365,18 @@ $("#sync").onclick = async () => { } }; $("#open").onclick = () => api("window/main", {}); +$("#openMain").onclick = () => api("window/main", {}); +// the app says which edge of the placed panel is nearest the tray +// (panelside.go); that edge alone opens the main window +window.magpiePanelOpenAt = (side) => { + if (mode === "panel" && (side === "head" || side === "foot")) document.body.dataset.openAt = side; +}; $("#quit").onclick = () => api("window/quit", {}); $("#winclose").onclick = () => winRuntime.then((w) => w?.Window.Close()); // hides it: the tray stays $(".top").addEventListener("dblclick", (e) => { if (document.body.classList.contains("linux") && !e.target.closest("button, nav")) winRuntime.then((w) => w?.Window.ToggleMaximise()); }); -if (mode === "window") { $("#open").remove(); $("#quit").remove(); } +if (mode === "window") { $("#open").remove(); $("#openMain").remove(); $("#quit").remove(); } else { $("#nav").remove(); $("#side").remove(); } if (mode !== "window" || !document.body.classList.contains("linux")) $("#winclose").remove(); diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index 2da2c1f4a..cb679e716 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -473,6 +473,7 @@ + diff --git a/internal/gui/assets/layout.js b/internal/gui/assets/layout.js index 787a6d870..8d0fbdc1b 100644 --- a/internal/gui/assets/layout.js +++ b/internal/gui/assets/layout.js @@ -15,6 +15,10 @@ if (!web && /^Mac/.test(navigator.platform)) document.body.classList.add("mac"); if (!web && /^Linux/.test(navigator.platform)) document.body.classList.add("linux"); if (/^Win/.test(navigator.platform)) document.documentElement.classList.add("win"); + // the panel opens the main window from the edge nearest the tray: its + // foot over Windows' bottom taskbar, its header elsewhere, until the app + // says where the panel was placed (panelside.go, magpiePanelOpenAt) + if (mode === "panel") document.body.dataset.openAt = /^Win/.test(navigator.platform) ? "foot" : "head"; // --bar: see app.css, .view function bar() { var p = document.createElement("div"); p.className = "view"; p.style.cssText = "position:absolute;visibility:hidden;height:9px"; document.body.appendChild(p); document.documentElement.style.setProperty("--bar", p.offsetWidth - p.clientWidth + "px"); p.remove(); } bar(); diff --git a/internal/gui/panelside.go b/internal/gui/panelside.go new file mode 100644 index 000000000..91fac4eb6 --- /dev/null +++ b/internal/gui/panelside.go @@ -0,0 +1,46 @@ +package gui + +// The quick panel has one control that opens the main window, on the edge +// nearest the tray icon (isaac_bai on Discord: with Windows' taskbar at the +// bottom, the header's icon was the panel's whole height from the tray). +// "head" is the header's icon, for a panel that hangs below its icon (the +// Mac's menu bar, a taskbar or bar at the top); "foot" is a text button +// left of Quit, for a panel that stands above it (Windows' taskbar at the +// bottom, a bottom panel on Linux). One of them only: the panel had both +// until e0ad48641 (yogurt36 on Discord). + +// panelRect is a window's or a screen's place, in one coordinate space. +type panelRect struct{ x, y, w, h int } + +// panelOpenAt says which edge of the panel opens the main window: "foot" +// when the placed panel is nearer the screen's bottom than its top, "head" +// when nearer the top. The Mac's is always "head": its menu bar is at the +// top of every screen. A place that isn't known (Wayland, where a window +// can't read where the compositor put it, or a screen not read) goes by +// the system: Windows' taskbar is at the bottom unless moved, the Mac's +// menu bar is at the top, and Linux's bars are mostly at the top. +func panelOpenAt(goos string, panel, screen panelRect, known bool) string { + if goos == "darwin" { + return "head" + } + if known && panel.h > 0 && screen.h > 0 { + above := panel.y - screen.y // room between the screen's top and the panel + below := screen.y + screen.h - (panel.y + panel.h) // and between the panel and the screen's bottom + if below < above { + return "foot" + } + return "head" + } + if goos == "windows" { + return "foot" + } + return "head" +} + +// panelOpenAtJS tells the panel's page the side (app.js magpiePanelOpenAt). +func panelOpenAtJS(side string) string { + if side != "foot" { + side = "head" + } + return `window.magpiePanelOpenAt && window.magpiePanelOpenAt("` + side + `")` +} diff --git a/internal/gui/panelside_test.go b/internal/gui/panelside_test.go new file mode 100644 index 000000000..9b6f09d3a --- /dev/null +++ b/internal/gui/panelside_test.go @@ -0,0 +1,70 @@ +package gui + +import ( + "os" + "regexp" + "strings" + "testing" +) + +// The panel opens the main window from its edge nearest the tray: the +// foot above a bottom taskbar, the header below a top one (isaac_bai). +func TestPanelOpensTheWindowFromTheEdgeNearestTheTray(t *testing.T) { + screen := panelRect{0, 0, 1920, 1080} + for _, c := range []struct { + name string + goos string + panel panelRect + screen panelRect + known bool + want string + }{ + {"Windows, taskbar at the bottom", "windows", panelRect{1540, 520, 360, 520}, screen, true, "foot"}, + {"Windows, taskbar at the top", "windows", panelRect{1540, 48, 360, 520}, screen, true, "head"}, + {"Windows, a tall panel nearer the bottom", "windows", panelRect{1540, 100, 360, 932}, screen, true, "foot"}, + {"Windows, second screen above the first, taskbar at its bottom", "windows", panelRect{1540, -560, 360, 520}, panelRect{0, -1080, 1920, 1080}, true, "foot"}, + {"Windows, place unknown", "windows", panelRect{}, panelRect{}, false, "foot"}, + {"Linux X11, bottom panel", "linux", panelRect{1500, 520, 360, 520}, screen, true, "foot"}, + {"Linux X11, top bar", "linux", panelRect{1500, 32, 360, 520}, screen, true, "head"}, + {"Linux Wayland, place unknown", "linux", panelRect{0, 0, 360, 520}, screen, false, "head"}, + {"Linux, screen not read", "linux", panelRect{1500, 520, 360, 520}, panelRect{}, true, "head"}, + {"Mac menu bar", "darwin", panelRect{1500, 30, 360, 520}, screen, true, "head"}, + {"Mac, place unknown", "darwin", panelRect{}, panelRect{}, false, "head"}, + } { + if got := panelOpenAt(c.goos, c.panel, c.screen, c.known); got != c.want { + t.Errorf("%s: %q, want %q", c.name, got, c.want) + } + } + if js := panelOpenAtJS("foot"); !strings.Contains(js, `magpiePanelOpenAt("foot")`) { + t.Errorf("foot: %s", js) + } + if js := panelOpenAtJS(`x");alert(1);("`); !strings.Contains(js, `magpiePanelOpenAt("head")`) { + t.Errorf("only head or foot reach the page: %s", js) + } +} + +// Each way the tray shows the panel tells it its side once it is placed, +// and the page has the function that hears it. +func TestPanelToldItsSideWhenShown(t *testing.T) { + src, err := os.ReadFile("app.go") + if err != nil { + t.Fatal(err) + } + body := regexp.MustCompile(`(?s)func \(h \*host\) togglePanelNow\(\) \{.*?\n\}\n`).Find(src) + if body == nil { + t.Fatal("togglePanelNow not found") + } + if !regexp.MustCompile(`(?s)PositionWindow\(h\.panel, 6\)\s*showWebview\(h\.panel\)\.Focus\(\)\s*h\.tellPanelSide\(\)\s*return`).Match(body) { + t.Error("the Mac's panel isn't told its side after it is placed") + } + if !regexp.MustCompile(`(?s)h\.tray\.ToggleWindow\(\)\s*if h\.panel\.IsVisible\(\) \{\s*h\.tellPanelSide\(\)`).Match(body) { + t.Error("the panel shown by ToggleWindow isn't told its side") + } + page, err := os.ReadFile("assets/app.js") + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(page), "window.magpiePanelOpenAt = (side)") { + t.Error("app.js has no magpiePanelOpenAt") + } +} diff --git a/internal/gui/tests/panel-open-once.test.cjs b/internal/gui/tests/panel-open-once.test.cjs index 99ace2a03..0d005263f 100644 --- a/internal/gui/tests/panel-open-once.test.cjs +++ b/internal/gui/tests/panel-open-once.test.cjs @@ -1,10 +1,11 @@ // Run with Node's test runner and Playwright on the module path; see README.md. -// The tray panel opens the main window from one place: the header's -// open-as-a-window icon. Its foot had an "Open magpie" button too, which did -// the same (yogurt36 on Discord); the foot keeps Profiles, the status line -// and Quit, which are its own. The icon is named for what it opens, the main -// window: isaac_bai on Discord looked for the foot's button and took the -// icon's "Open as a window" for this panel in a window. +// The tray panel opens the main window from one place, never two (yogurt36 +// on Discord): the edge nearest the tray (isaac_bai on Discord, with +// Windows' taskbar at the bottom). Hung below its icon (the Mac's menu bar, +// a top bar) it is the header's icon; standing above it (Windows' bottom +// taskbar) it is "Open the main window" left of Quit in the foot, and the +// header has no icon. Before the app says where it placed the panel +// (panelside.go), the side goes by the system: the foot on Windows. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); const path = require("node:path"); @@ -34,41 +35,88 @@ function handler(lang, calls) { }; } +const NAMES = { en: "Open the main window", zh: "打开主窗口", "zh-TW": "開啟主視窗", ja: "メインウィンドウを開く", de: "Hauptfenster öffnen" }; +const QUITS = { en: "Quit", zh: "退出", "zh-TW": "退出", ja: "終了", de: "Beenden" }; + +// the controls that open the main window, as shown: [where, its name] +async function openers(page) { + return page.evaluate(() => { + const shown = (e) => e && e.offsetParent !== null && getComputedStyle(e).visibility !== "hidden"; + const out = []; + const head = document.querySelector(".top #open"); + if (shown(head)) out.push(["head", head.title]); + const foot = document.querySelector(".foot #openMain"); + if (shown(foot)) out.push(["foot", foot.textContent.trim()]); + return out; + }); +} + +async function open(engine, lang, platform, t) { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width: 360, height: 520 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(8000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + if (platform) await page.addInitScript((p) => Object.defineProperty(Navigator.prototype, "platform", { get: () => p }), platform); + const calls = []; + await page.route("**/*", handler(lang, calls)); + await page.goto("http://magpie.test/?mode=panel"); + await page.locator("#agents .row.agent").first().waitFor(); + return { page, calls, errors }; +} + +async function clicked(page, calls, sel) { + calls.length = 0; + await page.locator(sel).click(); + for (let i = 0; i < 100 && !calls.length; i++) await page.waitForTimeout(50); + assert.deepEqual(calls, ["/api/window/main"], `${sel} opens the window`); +} + +// the foot's buttons, as shown, left to right, none of them cut or overlapping +async function footRow(page) { + return page.evaluate(() => { + const foot = document.querySelector(".foot").getBoundingClientRect(); + const bs = [...document.querySelectorAll(".foot button")].filter((b) => b.offsetParent !== null); + const rs = bs.map((b) => b.getBoundingClientRect()); + const fits = rs.every((r) => r.left >= foot.left - 0.5 && r.right <= foot.right + 0.5) && rs.every((r, i) => !i || r.left >= rs[i - 1].right - 0.5); + const whole = bs.every((b) => b.scrollWidth <= b.clientWidth + 1); + return { ids: bs.map((b) => b.id), fits, whole }; + }); +} + for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) { - test(`${engine} ${lang}: the tray panel opens the window from one button`, async (t) => { - const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); - t.after(() => browser.close()); - const page = await (await browser.newContext({ viewport: { width: 380, height: 520 }, reducedMotion: "reduce" })).newPage(); - page.setDefaultTimeout(8000); - page.setDefaultNavigationTimeout(60000); - const errors = []; - page.on("pageerror", (e) => errors.push(e.message)); - const calls = []; - await page.route("**/*", handler(lang, calls)); - await page.goto("http://magpie.test/?mode=panel"); - await page.locator("#agents .row.agent").first().waitFor(); + const name = NAMES[lang]; - // the header's icon is named for what it opens, in the panel's language - const name = { en: "Open the main window", zh: "打开主窗口", "zh-TW": "開啟主視窗", ja: "メインウィンドウを開く", de: "Hauptfenster öffnen" }[lang]; - assert.equal(await page.locator(".top #open").getAttribute("title"), name, "the header icon's name"); + test(`${engine} ${lang}: a panel below its icon opens the window from the header only`, async (t) => { + const { page, calls, errors } = await open(engine, lang, "MacIntel", t); + assert.deepEqual(await openers(page), [["head", name]], "one opener, the header's icon"); assert.equal(await page.locator(".top").getByRole("button", { name, exact: true }).count(), 1, "found by its name"); + await clicked(page, calls, ".top #open"); + assert.deepEqual((await footRow(page)).ids, ["profBtn", "quit"], "the foot's buttons"); + assert.equal((await page.locator(".foot #quit").textContent()).trim(), QUITS[lang]); + // the app placed it above the tray (a bottom bar on Linux): the foot's + await page.evaluate(() => window.magpiePanelOpenAt("foot")); + assert.deepEqual(await openers(page), [["foot", name]], "moved to the foot as the app says"); + assert.deepEqual(errors, []); + }); - // the header's icon opens the window - await page.locator(".top #open").click(); - for (let i = 0; i < 100 && !calls.length; i++) await page.waitForTimeout(50); - assert.deepEqual(calls, ["/api/window/main"], "the header's icon opens the window"); - - // and the foot has no second way to it: Profiles and Quit are its only buttons - const foot = await page.locator(".foot button").evaluateAll((bs) => bs.map((b) => b.id)); - assert.deepEqual(foot, ["profBtn", "quit"], "the foot's buttons"); - - // the foot keeps Quit, worded in the panel's language - const quit = page.locator(".foot #quit"); - assert(await quit.isVisible(), "Quit stays in the foot"); - const want = { en: "Quit", zh: "退出", "zh-TW": "退出", ja: "終了", de: "Beenden" }[lang]; - assert.equal((await quit.textContent()).trim(), want); - assert.equal(await page.locator("#openMain").count(), 0); + test(`${engine} ${lang}: a panel above Windows' taskbar opens the window from the foot only, left of Quit`, async (t) => { + const { page, calls, errors } = await open(engine, lang, "Win32", t); + assert.deepEqual(await openers(page), [["foot", name]], "one opener, the foot's button"); + assert.equal(await page.locator(".top #open").isVisible(), false, "no header icon"); + const row = await footRow(page); + assert.deepEqual(row.ids, ["profBtn", "openMain", "quit"], "left of Quit"); + assert(row.fits, "the foot's buttons fit, apart"); + assert(row.whole, "their words whole"); + assert.equal((await page.locator(".foot #quit").textContent()).trim(), QUITS[lang]); + await clicked(page, calls, ".foot #openMain"); + // a taskbar moved to the top: the app says head + await page.evaluate(() => window.magpiePanelOpenAt("head")); + assert.deepEqual(await openers(page), [["head", name]], "back to the header as the app says"); + await page.evaluate(() => window.magpiePanelOpenAt("sideways")); + assert.deepEqual(await openers(page), [["head", name]], "an unknown side changes nothing"); assert.deepEqual(errors, []); }); }