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.
16 lines
343 B
Go
16 lines
343 B
Go
//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)
|
|
}
|
|
})
|
|
}
|