gui: a pin in the title bar keeps the main window on top (NovaStudiosss on X)
NovaStudiosss wanted to watch Usage and Routing while working in other apps. The main window's toolbar now has a pin between Refresh and Settings. A click keeps the window above other apps' windows (Wails SetAlwaysOnTop through POST /api/window/ontop?on=1|0) and saves it as settings.json's onTop, which this computer keeps for itself (KeepOwn, not synced). makeMain opens the window pinned on the next start, and boot.js shows the pin pressed before the first paint. There is no pin in the panel, in a browser's page (magpie web) or under Wayland, where always-on-top is ignored (GDK_BACKEND=x11 keeps it). A refused pin goes back up. Tooltips "Keep on top" and "Stop keeping on top" are in every language. A Settings save keeps onTop (settingsapi.Merge), which a test showed was lost before. Run (rebased ona80a920f5): - go test -tags nogui ./internal/gui ./internal/settings ./internal/settingsapi on mica: ok. TestPinKeepsWindowOnTop, TestPinRefusedWithoutAWindowToPin, TestSetOnTop*, TestOnTopOwn and the settings-save keep test. - At the rebased head, TestPinRefused had served webHost through Handler and left webPage set, which turned TestSessionTitlesName- OtherAgents and TestCursorEditorChatsAreNotCalledCursorCLI red in a full package run. It now goes through webPageHandler, and the package is ok. TestWebPageHandlerEveryWhere misses a webHost passed in a variable. - window-pin.test.cjs (chromium + webkit, en zh zh-TW ja de) and i18n-keys: 36 pass. - Full GUI suite on mote (pre-rebase tree, still running at push): about 380 reds so far, none in window-pin. Seven of the red files (account-arrange, agent-details-ready, api-key-theme, bark, agent-switch-accounts, allow-ips, agent-bulk-visibility) were run on origin/main30de93e9e: 77 of the same reds, and none red only here. - go vet for darwin, windows, linux nogui and linux gtk3. Windows go test ./internal/gui ./internal/settings: ok. gofmt clean. - Broken by hand: without the route, or without renderOnTop, the Go and GUI tests go red. Without the Merge line the settings-save test goes red. - Real app on mote: with onTop saved, the main window opens at the floating level (CGWindowList layer 3, 0 unpinned). Not tried: clicking the pin in the real app (no Accessibility over ssh), a real Windows or Linux window, Wayland (hidden by design). At the default 660px window, the English tabs now scroll about 15px, as Japanese and German already did on main.
This commit is contained in:
@@ -34,7 +34,7 @@ three.
|
||||
3. The panel and the window load `index.html` from `Handler`. `boot.js` passes the saved language, theme, colorblind mode, text size and desktop font choices before the first paint. It also puts in the look of the reader's own (`appearance.go`, CHENGJIAHEGOXIS on X): Settings › General's Accent color (`accent`, `#rrggbb`; `accentVars` darkens it on the light theme and lightens it on the dark one until it reads as text at 4.5:1; it also sets `--mark`, the ink of what is chosen: the open page's sidebar icon, a switch's or tab's chosen option, Library's switches and radios. `--mark` is `var(--fg)`, graphite, until the user picks an accent, so a picked colour shows on the page it is picked on. A picked colour also tints the theme's grounds, the window's and the tray panel's (`--bg`, `--card`, the pills, lines and the dark menus' `--pop-bg`; `tintVars`): each takes 5% (light) or 8% (dark) of the colour's hue, its own lightness kept, so a grey pick changes nothing and text keeps its contrast. A dark pick, one whose OKLab lightness is under 0.4 (Graphite and every preset are lighter), takes the dark grounds as far toward black as it is dark (`ground`, `darkness`), losing app.css's cool grey cast and taking more of the pick's hue as they go: black draws a #000000 page with its cards, pills, lines and menus the same neutral steps above it, and a deep navy a near-black navy page (`TestDarkPickDarkensPage`). Black's ink starts most of the way to white (`lifted`, by `depth`), so it is not Graphite's grey; on the light theme black is black ink, and white the light theme's dark ink (`TestBlackIsBlack`); with no accent, or under Omarchy, they are app.css's own. `TestTintBasesAreAppCSS` holds the Go bases to app.css, and `TestLookFixture` the GUI tests' `fixtures/look-accents.json` to `lookCSS`) and Background image (a PNG, JPEG, GIF or WebP of 16 MB at most, saved as `wallpaper` in magpie's folder by `POST /api/appearance/wallpaper` as base64 JSON, `{remove: true}` to take it away; `settings.Wallpaper` is its stamp), drawn behind the window's pages under a veil of the theme's background, never in the tray panel or under Omarchy. `bootPrefs.look` says which look was drawn; `applyPrefs` asks `/api/appearance/css` again only when the settings' look differs, and the rows are drawn by the lazy `appearance.js` (`appearance-look.test.cjs`, `appearance_test.go`).
|
||||
4. The page reads `GET /api/state` and writes through `POST` routes. Each write answers with the new state, built under `held`.
|
||||
5. Closing the window hides it. On the Mac a full-screen window first leaves full screen (`closeStep`). The system's close on the panel (a title bar's X, Alt+F4, a window manager's close key) hides it as Escape does, so the tray icon opens it again; a panel lightweight mode let go, no longer `h.panel`, closes (`makePanel`, `TestPanelCloseHidesIt`). A hidden macOS window keeps its WKWebView's page marked visible, so `hideWebview` tells the page it is out of sight before `orderOut`; that makes `document.hidden` and `visibilityState` true, stops the page's polling and frame loops, and pauses CSS animations. `showWebview` tells it it is visible again (#4293). Lightweight mode lets go only of a window closed this way: one covered by another app's window, minimised, or open as magpie was hidden is still open (`windowUp`, not Wails' `IsVisible`, which is the occlusion state), and so is it for the Dock while the window is open and for a restart (#1381, `TestCoveredWindowStaysUp`). On the Mac the tray icon and a usage cell close an open panel by the same test (`windowOpen` in `togglePanelNow` and `trayCellClick`, not Wails' `ToggleWindow`), so under a window over the whole screen, such as a remote-desktop server's privacy curtain, the icon still closes the panel instead of showing it again (#1661, `TestTrayCellClickReleasedPanel`). On Windows a hidden window's WebView2 is put on its low memory target (`lowWhileHidden`, [`memtarget_windows.go`](../../internal/gui/memtarget_windows.go): `ICoreWebView2_19::put_MemoryUsageTargetLevel`, on each hide, on a page that comes while hidden, and back to normal on each show), so the panel and the window kept loaded in the tray stop holding what they last drew; the page stays loaded and running, unlike lightweight mode. In the tray the WebView2 processes' private working set went from ~170 MB to 20 to 40 MB, while their commit charge stayed where it was (molamaker11 on X). WKWebView and WebKitGTK have nothing magpie can set for it.
|
||||
6. The window opens as it was last left. Its settled size and whether it was maximised are kept in `settings.Window` and `settings.WindowMaximised` (`settle`; per machine, see `KeepOwn`). A maximised window keeps the size it restores to. `makeMain` opens it at that size (`openSize`). On its first show, `placeMain` maximises it again on the Mac and Windows (on Windows once the page has come). On Linux, `makeMain` makes it maximised with `StartState`. On Windows a size larger than the screen's work area is fitted and centred (`fitRoom`), and the larger size stays kept. Where it was left is kept too, in `settings.WindowAt` (its top left corner across every screen, in the system's coordinates), so after a restart or an update it opens there rather than in the middle (jorbenzhu on Discord). `keepAt` saves it once a move or resize has rested for half a second, unless the window is maximised, full screen, minimised or hidden; `settings.Save` writes through temp and rename, and a settings file that can't be read is left alone. On its first show `placeMain` puts it back (`putBack`): `openAt` takes the screen holding most of the window, moves the window fully onto that screen's work area, and leaves it centred when no screen holds any of it, such as a monitor that is gone, or when the screens or the file can't be read (`TestOpenAt`). Under Wayland a window can't place itself, so nothing is kept or put back there unless GDK_BACKEND is x11 (`keepsPlace`, `TestKeepsPlace`). The tray's panel isn't kept: on the Mac and Windows it opens under the tray icon, and on Linux where the click was.
|
||||
6. The window opens as it was last left. Its settled size and whether it was maximised are kept in `settings.Window` and `settings.WindowMaximised` (`settle`; per machine, see `KeepOwn`). A maximised window keeps the size it restores to. `makeMain` opens it at that size (`openSize`). On its first show, `placeMain` maximises it again on the Mac and Windows (on Windows once the page has come). On Linux, `makeMain` makes it maximised with `StartState`. On Windows a size larger than the screen's work area is fitted and centred (`fitRoom`), and the larger size stays kept. Where it was left is kept too, in `settings.WindowAt` (its top left corner across every screen, in the system's coordinates), so after a restart or an update it opens there rather than in the middle (jorbenzhu on Discord). `keepAt` saves it once a move or resize has rested for half a second, unless the window is maximised, full screen, minimised or hidden; `settings.Save` writes through temp and rename, and a settings file that can't be read is left alone. On its first show `placeMain` puts it back (`putBack`): `openAt` takes the screen holding most of the window, moves the window fully onto that screen's work area, and leaves it centred when no screen holds any of it, such as a monitor that is gone, or when the screens or the file can't be read (`TestOpenAt`). Under Wayland a window can't place itself, so nothing is kept or put back there unless GDK_BACKEND is x11 (`keepsPlace`, `TestKeepsPlace`). The pin in the window's title bar, between Refresh and Settings (`#pin`, `renderOnTop`; NovaStudiosss on X, to watch Usage and Routing while working in another app), keeps the window above other apps' windows: `POST /api/window/ontop?on=1` (or `0`) saves `settings.OnTop` (`SetOnTop`, this computer's own, kept through a Settings save) and calls `SetAlwaysOnTop`, and `makeMain` opens the window pinned when it is set. boot.js says whether there is a pin (`pin`, `pinnable` in `ontop.go`) and whether it is pressed (`onTop`) before the first paint. There is none in the panel, in a browser page or `magpie web`, or under Wayland (the same `keepsPlace`: GTK's keep-above does nothing there), and the route refuses there with 400 and saves nothing (`TestPinKeepsWindowOnTop`, `TestPinRefusedWithoutAWindowToPin`, `window-pin.test.cjs`). The tray's panel isn't kept: on the Mac and Windows it opens under the tray icon, and on Linux where the click was.
|
||||
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 where it doesn't change the corners: in the earlier design, and on macOS 27, which gives a window with a toolbar a plain title bar's 16pt corners (`toolbarRounder` holds the window's radius against a window of its style with no toolbar, never shown); 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)).
|
||||
|
||||
@@ -40,8 +40,8 @@ The settings part carries the user's preferences, but not what is only about
|
||||
one computer. [`Settings.KeepOwn`](../../internal/settings/settings.go) puts
|
||||
those back from this computer's settings whenever a sync, a join, a Restore,
|
||||
an Undo or a backup file brings settings in, and `hashes` blanks them, so
|
||||
changing one is no change to push. They are: the window's size and whether it
|
||||
was maximised, the fonts, the proxy, the gateway's port, sharing on the local
|
||||
changing one is no change to push. They are: the window's size, whether it
|
||||
was maximised and whether it is kept on top (`OnTop`), the fonts, the proxy, the gateway's port, sharing on the local
|
||||
network (`LAN`) and the addresses let in to it (`AllowIPs`), the private
|
||||
hosts magpie may download from (`FetchPrivate`), the Dock, gateway
|
||||
mode, keeping awake, lightweight windows, WSL lookups, account discovery, when
|
||||
|
||||
@@ -1249,6 +1249,12 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
if s.NoBird {
|
||||
boot["noBird"] = true
|
||||
}
|
||||
// and the title bar's pin, where the window can be kept on top
|
||||
// (ontop.go): shown, and pressed, from the first paint
|
||||
if pinnable(w) {
|
||||
boot["pin"] = true
|
||||
boot["onTop"] = s.OnTop
|
||||
}
|
||||
// a browser tab keeps its own font choice (fonts.js)
|
||||
if !isWeb(w) {
|
||||
boot["uiFont"], boot["codeFont"] = s.UIFont, s.CodeFont
|
||||
@@ -3212,6 +3218,15 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
w.HidePanel()
|
||||
case "main":
|
||||
w.ShowMain(mainView(r.URL.Query()))
|
||||
case "ontop":
|
||||
// the title bar's pin (ontop.go)
|
||||
on := r.URL.Query().Get("on") == "1"
|
||||
if err := pinMain(w, on); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
writeJSON(rw, map[string]bool{"onTop": on})
|
||||
return
|
||||
case "quit":
|
||||
// the question's "Don't ask again" (noAsk=1, zhujiu on
|
||||
// Discord) is saved before the quit; a save that fails keeps
|
||||
|
||||
@@ -605,6 +605,9 @@ body.side-nav :is(#usageTab, #view-library .lib-tabs, #view-plugins .lib-tabs, #
|
||||
.side-toggle .st-pane { fill: currentColor; opacity: .32; transition: opacity .2s var(--ease); }
|
||||
body:not(.side-nav) .side-toggle .st-pane { opacity: 0; }
|
||||
@media (prefers-reduced-motion: reduce) { .side-toggle .st-pane { transition: none; } }
|
||||
/* the window kept on top (app.js renderOnTop): pressed, its pin filled */
|
||||
.icon.pin .pin-body { fill: currentColor; fill-opacity: 0; transition: fill-opacity .16s ease; }
|
||||
.icon.pin.on .pin-body { fill-opacity: 1; }
|
||||
/* the two layouts trade places as one motion (app.js navMorph): the sidebar
|
||||
slides in from the window's edge or back to it, each page's tab flies to
|
||||
its place in the other, and the page moves over, together. Each piece is
|
||||
|
||||
@@ -23623,6 +23623,39 @@ if (mode === "window") { $("#open").remove(); $("#openMain").remove(); $("#quit"
|
||||
else { $("#nav").remove(); $("#side").remove(); }
|
||||
if (mode !== "window" || !document.body.classList.contains("linux")) $("#winclose").remove();
|
||||
|
||||
// The title bar's pin keeps the window above other apps' windows, for Usage
|
||||
// or Routing watched while working elsewhere (NovaStudiosss on X): in the
|
||||
// app's main window, where boot.js says it can be pinned (ontop.go). Pressed,
|
||||
// the pin is filled; each click is saved in turn, and one that fails puts
|
||||
// back what is saved.
|
||||
let onTop = !!window.bootPrefs?.onTop, onTopSaved = onTop, onTopQueue = Promise.resolve();
|
||||
function renderOnTop() {
|
||||
const b = $("#pin");
|
||||
if (!b) return;
|
||||
b.classList.toggle("on", onTop);
|
||||
b.setAttribute("aria-pressed", String(onTop));
|
||||
b.dataset.enTitle = onTop ? "Stop keeping on top" : "Keep on top";
|
||||
b.title = t(b.dataset.enTitle);
|
||||
}
|
||||
if (mode === "window" && window.bootPrefs?.pin && !web) {
|
||||
$("#pin").hidden = false;
|
||||
renderOnTop();
|
||||
$("#pin").onclick = () => {
|
||||
onTop = !onTop;
|
||||
renderOnTop();
|
||||
const want = onTop;
|
||||
onTopQueue = onTopQueue.then(async () => {
|
||||
try {
|
||||
onTopSaved = (await api("window/ontop?on=" + (want ? 1 : 0), {})).onTop;
|
||||
} catch (e) {
|
||||
onTop = onTopSaved;
|
||||
renderOnTop();
|
||||
statusErr(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
} else $("#pin").remove();
|
||||
|
||||
// reload the config files when the panel comes back into view
|
||||
// The magpie in the corner flaps and wags its tail as the window opens and
|
||||
// when the pointer comes over it.
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
// works. {name} slots are filled by t(str, vars).
|
||||
const I18N = {
|
||||
zh: {
|
||||
"Keep on top": "窗口置顶",
|
||||
"Stop keeping on top": "取消置顶",
|
||||
"Calls": "调用次数",
|
||||
"Cards": "卡片",
|
||||
"Table": "表格",
|
||||
@@ -5331,6 +5333,8 @@ const I18N = {
|
||||
"runs everything without asking": "所有操作都直接运行,不询问",
|
||||
},
|
||||
"zh-TW": {
|
||||
"Keep on top": "視窗置頂",
|
||||
"Stop keeping on top": "取消置頂",
|
||||
"Calls": "呼叫次數",
|
||||
"Cards": "卡片",
|
||||
"Table": "表格",
|
||||
@@ -10642,6 +10646,8 @@ const I18N = {
|
||||
"runs everything without asking": "所有操作都直接執行,不詢問",
|
||||
},
|
||||
ja: {
|
||||
"Keep on top": "最前面に固定",
|
||||
"Stop keeping on top": "最前面の固定を解除",
|
||||
"Calls": "呼び出し数",
|
||||
"Cards": "カード",
|
||||
"Table": "表",
|
||||
@@ -15955,6 +15961,8 @@ const I18N = {
|
||||
"runs everything without asking": "すべて確認せずに実行する",
|
||||
},
|
||||
de: {
|
||||
"Keep on top": "Im Vordergrund halten",
|
||||
"Stop keeping on top": "Nicht mehr im Vordergrund halten",
|
||||
"Calls": "Aufrufe",
|
||||
"Cards": "Karten",
|
||||
"Table": "Tabelle",
|
||||
|
||||
@@ -99,6 +99,10 @@
|
||||
<button class="icon" id="sync" title="Look for agents on this computer again: one just installed or removed, or its settings changed" data-tt>
|
||||
<svg viewBox="0 0 16 16" width="14" height="14"><path d="M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
</button>
|
||||
<!-- the window kept above other apps' (app.js renderOnTop), where it can be -->
|
||||
<button type="button" class="icon pin" id="pin" hidden aria-pressed="false" data-tt="Keep on top">
|
||||
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 17v5"/><path class="pin-body" d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></g></svg>
|
||||
</button>
|
||||
<button class="icon" id="open" title="Open the main window" data-tt>
|
||||
<svg viewBox="0 0 16 16" width="14" height="14"><path d="M6 3H3.5A1.5 1.5 0 0 0 2 4.5v8A1.5 1.5 0 0 0 3.5 14h8a1.5 1.5 0 0 0 1.5-1.5V10M9 2h5v5M14 2 8 8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
</button>
|
||||
|
||||
@@ -248,6 +248,9 @@ func (c remoteWindows) TintTitleBar(rgba [4]uint8, dark bool) bool {
|
||||
func (c remoteWindows) SetTextSize(percent int) {
|
||||
c.post("textsize", url.Values{"arg": {strconv.Itoa(percent)}})
|
||||
}
|
||||
func (c remoteWindows) SetOnTop(on bool) {
|
||||
c.post("ontop", url.Values{"arg": {strconv.FormatBool(on)}})
|
||||
}
|
||||
|
||||
// backendClient waits out a backend's restart: a request made while the old
|
||||
// one is gone connects to the new one once it listens.
|
||||
@@ -318,6 +321,8 @@ func devShell(h *host) http.Handler {
|
||||
if n, g, ok := parseFit(q); ok {
|
||||
h.FitPanel(n, g)
|
||||
}
|
||||
case "ontop":
|
||||
h.SetOnTop(arg == "true")
|
||||
case "textsize":
|
||||
if n, err := strconv.Atoi(arg); err == nil {
|
||||
h.SetTextSize(n)
|
||||
|
||||
@@ -41,6 +41,8 @@ func (h *host) makeMain(url string) *application.WebviewWindow {
|
||||
// Windows' title bar in the page's colour from the first frame; the
|
||||
// page keeps it so as its theme changes (TintTitleBar)
|
||||
winOpts, winBg := windowChrome(cmp.Or(os.Getenv("MAGPIE_THEME"), settings.Shared().Theme))
|
||||
// pinned above other windows, as the title bar's pin left it (ontop.go)
|
||||
onTop := settings.Load().OnTop && canOnTop(runtime.GOOS, os.Getenv)
|
||||
w := h.app.Window.NewWithOptions(application.WebviewWindowOptions{
|
||||
Name: "main",
|
||||
Title: "magpie",
|
||||
@@ -52,6 +54,7 @@ func (h *host) makeMain(url string) *application.WebviewWindow {
|
||||
Zoom: z,
|
||||
Hidden: true,
|
||||
StartState: state,
|
||||
AlwaysOnTop: onTop,
|
||||
Mac: mainMacWindow(),
|
||||
Windows: winOpts,
|
||||
BackgroundColour: winBg,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// The main window's pin keeps it above other apps' windows, for Usage or
|
||||
// Routing watched while working elsewhere (NovaStudiosss on X). The title
|
||||
// bar's pin (app.js renderOnTop, shown where boot.js says pin) asks POST
|
||||
// /api/window/ontop; the choice is this computer's own setting
|
||||
// (settings.OnTop), put on the window as it is made (makeMain) and at once
|
||||
// on the one showing.
|
||||
|
||||
// onTopper is a host whose main window can stay on top; a browser's page
|
||||
// (magpie web) has no window of its own to pin.
|
||||
type onTopper interface {
|
||||
// SetOnTop puts the main window above other windows, or back among
|
||||
// them.
|
||||
SetOnTop(on bool)
|
||||
}
|
||||
|
||||
// canOnTop says whether a window can keep itself above others on goos: not
|
||||
// in a Wayland session, which has no way for an app to ask it (Wails sets
|
||||
// _NET_WM_STATE_ABOVE, an X11 hint), unless GTK speaks X11 there
|
||||
// (GDK_BACKEND=x11), as with the window's place (keepsPlace).
|
||||
func canOnTop(goos string, getenv func(string) string) bool {
|
||||
return keepsPlace(goos, getenv)
|
||||
}
|
||||
|
||||
var errNoOnTop = errors.New("this window can't stay on top here")
|
||||
|
||||
// pinnable says whether w's main window can be pinned: the app's host
|
||||
// (not a browser's page, magpie web's or the app's served to a browser) on
|
||||
// a desktop that can keep a window on top.
|
||||
func pinnable(w Windows) bool {
|
||||
_, ok := w.(onTopper)
|
||||
return ok && !isWeb(w) && canOnTop(runtime.GOOS, os.Getenv)
|
||||
}
|
||||
|
||||
// pinMain saves the pin and puts it on the window; where the window can't
|
||||
// be pinned (pinnable) nothing is saved.
|
||||
func pinMain(w Windows, on bool) error {
|
||||
if !pinnable(w) {
|
||||
return errNoOnTop
|
||||
}
|
||||
p := w.(onTopper)
|
||||
if err := settings.SetOnTop(on); err != nil {
|
||||
return err
|
||||
}
|
||||
p.SetOnTop(on)
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build !nogui
|
||||
|
||||
package gui
|
||||
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
// SetOnTop pins the main window that shows, if one does; one lightweight
|
||||
// mode let go is made again with the pin (makeMain).
|
||||
func (h *host) SetOnTop(on bool) {
|
||||
application.InvokeSync(func() {
|
||||
if h.main != nil {
|
||||
h.main.SetAlwaysOnTop(on)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// pinHost is the app's host as the pin sees it: a window that can be
|
||||
// kept on top, and what it was last told.
|
||||
type pinHost struct {
|
||||
Windows
|
||||
on *[]bool
|
||||
}
|
||||
|
||||
func (h pinHost) SetOnTop(on bool) { *h.on = append(*h.on, on) }
|
||||
|
||||
// tabPinHost is a browser's page in front of a host that could pin: the
|
||||
// app's page served to a browser.
|
||||
type tabPinHost struct{ pinHost }
|
||||
|
||||
func (tabPinHost) browserTab() {}
|
||||
|
||||
// The title bar's pin (NovaStudiosss on X) puts the main window on top at
|
||||
// once and saves it, so the window is made pinned after a restart
|
||||
// (makeMain reads settings.OnTop); unpinning does both back. The settings
|
||||
// state says the pin can be used.
|
||||
func TestPinKeepsWindowOnTop(t *testing.T) {
|
||||
sandboxHome(t)
|
||||
if !canOnTop(runtime.GOOS, func(string) string { return "" }) {
|
||||
t.Skip("no desktop that can pin here")
|
||||
}
|
||||
t.Setenv("XDG_SESSION_TYPE", "")
|
||||
t.Setenv("WAYLAND_DISPLAY", "")
|
||||
var told []bool
|
||||
h := Handler(pinHost{on: &told}, nil)
|
||||
post := func(url string) {
|
||||
t.Helper()
|
||||
r := httptest.NewRecorder()
|
||||
h.ServeHTTP(r, httptest.NewRequest("POST", url, nil))
|
||||
if r.Code != 200 {
|
||||
t.Fatalf("%s: %d %s", url, r.Code, r.Body)
|
||||
}
|
||||
var out struct{ OnTop bool }
|
||||
if err := json.Unmarshal(r.Body.Bytes(), &out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want := url == "/api/window/ontop?on=1"; out.OnTop != want {
|
||||
t.Fatalf("%s answered onTop %v", url, out.OnTop)
|
||||
}
|
||||
}
|
||||
post("/api/window/ontop?on=1")
|
||||
if len(told) != 1 || !told[0] {
|
||||
t.Fatalf("the window was told %v, want [true]", told)
|
||||
}
|
||||
if !settings.Load().OnTop {
|
||||
t.Fatal("the pin wasn't saved for the next start")
|
||||
}
|
||||
if boot := bootOf(t, h); boot["pin"] != true || boot["onTop"] != true {
|
||||
t.Fatalf("boot.js doesn't show the pin pressed: %v", boot)
|
||||
}
|
||||
post("/api/window/ontop?on=0")
|
||||
if len(told) != 2 || told[1] || settings.Load().OnTop {
|
||||
t.Fatalf("unpinned: told %v, saved %v", told, settings.Load().OnTop)
|
||||
}
|
||||
if boot := bootOf(t, h); boot["pin"] != true || boot["onTop"] != false {
|
||||
t.Fatalf("boot.js doesn't show the pin up: %v", boot)
|
||||
}
|
||||
}
|
||||
|
||||
// bootOf is what boot.js tells the page.
|
||||
func bootOf(t *testing.T, h http.Handler) map[string]any {
|
||||
t.Helper()
|
||||
r := httptest.NewRecorder()
|
||||
h.ServeHTTP(r, httptest.NewRequest("GET", "/boot.js", nil))
|
||||
body := r.Body.String()
|
||||
i, j := strings.Index(body, "{"), strings.Index(body, "};")
|
||||
if i < 0 || j < i {
|
||||
t.Fatalf("boot.js: %.300s", body)
|
||||
}
|
||||
var out map[string]any
|
||||
if err := json.Unmarshal([]byte(body[i:j+1]), &out); err != nil {
|
||||
t.Fatalf("boot.js: %v in %.300s", err, body)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// A browser's page (magpie web, or the app's page served to a browser)
|
||||
// has no window of its own to pin, and a Wayland session can't keep one
|
||||
// on top: the pin is refused there and nothing is saved.
|
||||
func TestPinRefusedWithoutAWindowToPin(t *testing.T) {
|
||||
sandboxHome(t)
|
||||
var told []bool
|
||||
for name, w := range map[string]Windows{
|
||||
"magpie web": webHost{},
|
||||
"no pin to make": folderOnly{},
|
||||
"browser tab": tabPinHost{pinHost{on: &told}},
|
||||
} {
|
||||
r := httptest.NewRecorder()
|
||||
webPageHandler(t, w, nil).ServeHTTP(r, httptest.NewRequest("POST", "/api/window/ontop?on=1", nil))
|
||||
if r.Code != 400 {
|
||||
t.Fatalf("%s: %d %s, want refused", name, r.Code, r.Body)
|
||||
}
|
||||
if boot := bootOf(t, webPageHandler(t, w, nil)); boot["pin"] != nil {
|
||||
t.Fatalf("%s: boot.js shows the pin: %v", name, boot)
|
||||
}
|
||||
}
|
||||
if len(told) != 0 || settings.Load().OnTop {
|
||||
t.Fatalf("a refused pin reached the window (%v) or was saved (%v)", told, settings.Load().OnTop)
|
||||
}
|
||||
|
||||
env := func(m map[string]string) func(string) string { return func(k string) string { return m[k] } }
|
||||
for _, c := range []struct {
|
||||
goos string
|
||||
env map[string]string
|
||||
can bool
|
||||
}{
|
||||
{"darwin", nil, true},
|
||||
{"windows", nil, true},
|
||||
{"linux", map[string]string{"XDG_SESSION_TYPE": "x11"}, true},
|
||||
{"linux", map[string]string{"XDG_SESSION_TYPE": "wayland"}, false},
|
||||
{"linux", map[string]string{"WAYLAND_DISPLAY": "wayland-0"}, false},
|
||||
{"linux", map[string]string{"XDG_SESSION_TYPE": "wayland", "GDK_BACKEND": "x11"}, true},
|
||||
} {
|
||||
if got := canOnTop(c.goos, env(c.env)); got != c.can {
|
||||
t.Errorf("canOnTop(%s, %v) = %v, want %v", c.goos, c.env, got, c.can)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,6 +235,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) {
|
||||
was.MTLS = true // Network and sharing's settings/mtls
|
||||
was.Wallpaper = 1700000000000 // Settings > General's Background image, appearance/wallpaper
|
||||
was.HTTPS = true // Network and sharing's settings/https
|
||||
was.OnTop = true // the title bar's pin, window/ontop
|
||||
// Settings > Usage's Bark row has its own route (settings/bark)
|
||||
was.BarkServer, was.BarkKey, was.BarkDaily = "https://bark.example.com", "kept", "21:30"
|
||||
// the Routing groups page's defaults for every group (groups/defaults)
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// NovaStudiosss on X: a pin at the top right of the main window keeps it
|
||||
// above other apps' windows, to watch Usage and Routing while working
|
||||
// elsewhere. The pin (#pin, app.js renderOnTop) shows only where boot.js
|
||||
// says the window can be pinned (bootPrefs.pin: the app's own window, not
|
||||
// a browser page, not Wayland), never in the panel. A click posts
|
||||
// window/ontop?on=1 or ?on=0 and the pin is pressed (.on, aria-pressed)
|
||||
// with its tooltip saying what the next click does; a refused post puts
|
||||
// it back. bootPrefs.onTop has it pressed from the first paint. In every
|
||||
// language and both engines; no backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const keys = ["Keep on top", "Stop keeping on top"];
|
||||
|
||||
// until waits for f to hold (the posts the page makes), at most 5s
|
||||
const until = async (f) => { for (let i = 0; i < 250 && !f(); i++) await new Promise((r) => setTimeout(r, 20)); };
|
||||
|
||||
function server(lang, posts, o) {
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data, status = 200) => route.fulfill({ status, json: data });
|
||||
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: "light", web: !!o.web, ...o.boot })};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (req.method() === "POST" && url.pathname === "/api/window/ontop") {
|
||||
posts.push(url.pathname + url.search);
|
||||
if (o.refuse) return json({ error: "this window can't stay on top here" }, 400);
|
||||
return json({ onTop: url.searchParams.get("on") === "1" });
|
||||
}
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
const open = async (t, o, url = "/", width = 980) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 560 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [], posts = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, posts, o));
|
||||
await page.goto("http://magpie.test" + url);
|
||||
await page.locator("#status").waitFor({ state: "attached" });
|
||||
const tr = (k) => page.evaluate((k) => t(k), k);
|
||||
t.after(() => assert.deepEqual(errors, []));
|
||||
return { page, posts, tr };
|
||||
};
|
||||
|
||||
test(`${engine} ${lang}: the pin keeps the window on top, and lets it go`, async (t) => {
|
||||
const { page, posts, tr } = await open(t, { boot: { pin: true, onTop: false } });
|
||||
if (lang !== "en") {
|
||||
const missing = await page.evaluate(([lang, keys]) => keys.filter((k) => !I18N[lang][k]), [lang, keys]);
|
||||
assert.deepEqual(missing, [], "every string has its " + lang);
|
||||
}
|
||||
const pin = page.locator("header .actions #pin");
|
||||
await pin.waitFor();
|
||||
assert.equal(await pin.getAttribute("aria-pressed"), "false");
|
||||
assert.equal(await pin.getAttribute("title"), await tr("Keep on top"));
|
||||
assert.ok(!(await pin.evaluate((b) => b.classList.contains("on"))));
|
||||
// as big as the toolbar's other icons
|
||||
const [a, b] = await Promise.all([pin.boundingBox(), page.locator("header .actions #sync").boundingBox()]);
|
||||
assert.ok(Math.abs(a.width - b.width) < 1 && Math.abs(a.height - b.height) < 1, `pin ${a.width}x${a.height}, sync ${b.width}x${b.height}`);
|
||||
|
||||
await pin.click();
|
||||
await until(() => posts.length === 1);
|
||||
assert.deepEqual(posts, ["/api/window/ontop?on=1"]);
|
||||
assert.equal(await pin.getAttribute("aria-pressed"), "true");
|
||||
assert.ok(await pin.evaluate((b) => b.classList.contains("on")), "pressed");
|
||||
assert.equal(await pin.getAttribute("title"), await tr("Stop keeping on top"));
|
||||
|
||||
await pin.click();
|
||||
await until(() => posts.length === 2);
|
||||
assert.deepEqual(posts, ["/api/window/ontop?on=1", "/api/window/ontop?on=0"]);
|
||||
assert.equal(await pin.getAttribute("aria-pressed"), "false");
|
||||
assert.equal(await pin.getAttribute("title"), await tr("Keep on top"));
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: a pinned window shows its pin pressed from the start`, async (t) => {
|
||||
const { page, tr } = await open(t, { boot: { pin: true, onTop: true } });
|
||||
const pin = page.locator("#pin");
|
||||
await pin.waitFor();
|
||||
assert.equal(await pin.getAttribute("aria-pressed"), "true");
|
||||
assert.equal(await pin.getAttribute("title"), await tr("Stop keeping on top"));
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: a refused pin goes back up`, async (t) => {
|
||||
const { page, posts } = await open(t, { boot: { pin: true, onTop: false }, refuse: true });
|
||||
const pin = page.locator("#pin");
|
||||
await pin.click();
|
||||
await until(() => posts.length === 1);
|
||||
await page.waitForFunction(() => document.querySelector("#pin").getAttribute("aria-pressed") === "false");
|
||||
assert.ok(!(await pin.evaluate((b) => b.classList.contains("on"))));
|
||||
});
|
||||
}
|
||||
|
||||
test(`${engine}: no pin where the window can't be pinned, nor in the panel or a browser`, async (t) => {
|
||||
for (const [o, url, why] of [
|
||||
[{ boot: {} }, "/", "the server didn't offer one (Wayland)"],
|
||||
[{ boot: { pin: true } }, "/?mode=panel", "the panel"],
|
||||
[{ boot: { pin: true }, web: true }, "/", "a browser page"],
|
||||
]) {
|
||||
const { page } = await open0(engine, t, o, url);
|
||||
assert.equal(await page.locator("#pin").count(), 0, why);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// open0 is open for a test outside the language loop, in English
|
||||
async function open0(engine, t, o, url) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width: 980, height: 560 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server("en", [], o));
|
||||
await page.goto("http://magpie.test" + url);
|
||||
await page.locator("#status").waitFor({ state: "attached" });
|
||||
t.after(() => assert.deepEqual(errors, []));
|
||||
return { page };
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The main window's pin (NovaStudiosss on X) is saved alone, keeping what
|
||||
// the user set elsewhere, and turns back off the same way.
|
||||
func TestSetOnTop(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
if Load().OnTop {
|
||||
t.Fatal("the window is pinned by default")
|
||||
}
|
||||
s := Load()
|
||||
s.Theme, s.NoBird = "dark", true
|
||||
if err := Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := SetOnTop(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := Load(); !got.OnTop || got.Theme != "dark" || !got.NoBird {
|
||||
t.Fatalf("after SetOnTop(true): onTop %v, theme %q, noBird %v", got.OnTop, got.Theme, got.NoBird)
|
||||
}
|
||||
if err := SetOnTop(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := Load(); got.OnTop || got.Theme != "dark" {
|
||||
t.Fatalf("after SetOnTop(false): onTop %v, theme %q", got.OnTop, got.Theme)
|
||||
}
|
||||
}
|
||||
|
||||
// A settings file that can't be read is not written over with defaults by
|
||||
// the pin: the save fails and the file stays as it was.
|
||||
func TestSetOnTopLeavesAnUnreadFile(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
if err := Save(Settings{Theme: "dark"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p := Path()
|
||||
if err := os.WriteFile(p, []byte("{not json"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := SetOnTop(true); err == nil {
|
||||
t.Fatal("SetOnTop saved over a file it couldn't read")
|
||||
}
|
||||
if b, _ := os.ReadFile(p); string(b) != "{not json" {
|
||||
t.Fatalf("the unread file was written: %q", b)
|
||||
}
|
||||
}
|
||||
|
||||
// The pin is this computer's own, as the window's size and place are: a
|
||||
// synced or restored bundle neither brings another's nor drops this one's.
|
||||
func TestOnTopOwn(t *testing.T) {
|
||||
from := Settings{Theme: "dark"}
|
||||
from.KeepOwn(Settings{OnTop: true})
|
||||
if !from.OnTop || from.Theme != "dark" {
|
||||
t.Fatalf("KeepOwn dropped it: %+v", from.OnTop)
|
||||
}
|
||||
from = Settings{OnTop: true}
|
||||
from.KeepOwn(Settings{})
|
||||
if from.OnTop {
|
||||
t.Fatal("another computer's pin here")
|
||||
}
|
||||
}
|
||||
@@ -1275,6 +1275,11 @@ type Settings struct {
|
||||
// minimised; not at all under Wayland, where a window can't place
|
||||
// itself. gui's openAt moves it onto a screen there now.
|
||||
WindowAt []int `json:"windowAt,omitempty"`
|
||||
// OnTop keeps the main window above other apps' windows, pinned from
|
||||
// its title bar's pin (NovaStudiosss on X: Usage and Routing watched
|
||||
// while working elsewhere). This computer's own, as the window's size
|
||||
// and place are.
|
||||
OnTop bool `json:"onTop,omitempty"`
|
||||
}
|
||||
|
||||
// ModelPrice is the price of one model as the user states it. Each part is a
|
||||
@@ -1786,7 +1791,7 @@ func (s *Settings) KeepOwn(cur Settings) {
|
||||
s.UpdateProxy, s.UpdateProxyCustom = cur.UpdateProxy, cur.UpdateProxyCustom
|
||||
s.UpdateSource = cur.UpdateSource
|
||||
s.WindowMaximised, s.KeepAwake, s.KeepAwakeDisplay = cur.WindowMaximised, cur.KeepAwake, cur.KeepAwakeDisplay
|
||||
s.WindowAt = cur.WindowAt
|
||||
s.WindowAt, s.OnTop = cur.WindowAt, cur.OnTop
|
||||
s.TrayUsages, s.TrayUsage, s.TrayUsageEvery, s.TrayNoLogos, s.TrayNoBird, s.TrayPace, s.TrayNoCost = cur.TrayUsages, cur.TrayUsage, cur.TrayUsageEvery, cur.TrayNoLogos, cur.TrayNoBird, cur.TrayPace, cur.TrayNoCost
|
||||
s.TrayWindows, s.TrayNoNumber, s.TrayCurrency = cur.TrayWindows, cur.TrayNoNumber, cur.TrayCurrency
|
||||
s.GatewayMode = cur.GatewayMode
|
||||
@@ -2342,6 +2347,18 @@ func SetQuitNoAsk(on bool) error {
|
||||
return save(s, false)
|
||||
}
|
||||
|
||||
// SetOnTop sets OnTop alone, from what the file holds now; a file that
|
||||
// can't be read is left as it is.
|
||||
func SetOnTop(on bool) error {
|
||||
defer lockFile()()
|
||||
s, err := loadChecked()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.OnTop = on
|
||||
return save(s, false)
|
||||
}
|
||||
|
||||
// RouterNoteMost is how many characters RouterNote keeps: a few words,
|
||||
// said before every tool's description.
|
||||
const RouterNoteMost = 80
|
||||
|
||||
@@ -275,6 +275,7 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err
|
||||
}
|
||||
in.AgentOrder, in.AgentsHidden, in.AgentsShown, in.AgentsHere = cur.AgentOrder, cur.AgentsHidden, cur.AgentsShown, cur.AgentsHere
|
||||
in.Window, in.WindowMaximised, in.WindowAt = cur.Window, cur.WindowMaximised, cur.WindowAt // the window's own, as it was last resized and moved
|
||||
in.OnTop = cur.OnTop // and pinned on top, by its title bar's pin (window/ontop)
|
||||
// and what other pages keep here: which models an agent is shown, and
|
||||
// everything the user said of a model anywhere else in the app, set on
|
||||
// its own. The per-model maps are carried whole rather than named one
|
||||
|
||||
Reference in New Issue
Block a user