On Windows the panel opened flush against the right edge and, a moment later, moved a fair way left. The tray placed it as it opened (ToggleWindow -> PositionWindow), and every refit after that placed it by the icon again: fitPanel, each glidePanel step (stepGlide in glide_other.go) and zoomWindows all called tray.PositionWindow. Wails centres the panel on the icon only when Shell_NotifyIconGetRect's rect is inside the taskbar, and flush right otherwise. An icon clicked in Windows 11's overflow flyout isn't in the taskbar as the panel opens, so it went flush right; the page's first fit, once the flyout had closed, read the flyout's arrow and centred the panel over that. Now every refit of the open panel goes through sizeOpenPanel. On Windows it keeps the place the tray gave it as it opened: the centre and the edge by the taskbar held, kept inside the work area (panelRefit, one SetBounds). The Mac and Linux keep SetSize then PositionWindow, as before, in the same order. Run: - gofmt -l; go vet ./internal/gui ./internal/agent on darwin, linux (-tags nogui) and windows, on mote. - go test -count=1 ./internal/gui ./internal/agent on mote: ok (145s, 250s). - win-run on xiaomi-gpu: TestPanel*, TestOpenPanel*: ok. Broken by hand (win-run, ../tray-jump-scratch/break.log): - panelRefit holding the top edge in place of the taskbar's: TestPanelRefitKeepsItsPlace red in 4 cases. - sizeOpenPanel taking the old path on Windows too, and app.go at its base (PositionWindow in fitPanel and zoomWindows): TestOpenPanelRefitsInPlaceOnWindows red each time. Not tried: the real tray click on xiaomi-gpu. Nobody is signed in there (query user: no users, LogonUI up, no explorer), so no tray exists to click and the panel's moves couldn't be watched; the cause above is read from Wails beta.24's systemtray_windows.go positionWindow. No GUI (Playwright) file reaches this: the change is in Go, not the page.
28 lines
806 B
Go
28 lines
806 B
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
// sizeOpenPanel gives the open panel its new size. On Windows the panel
|
|
// stays where the tray put it as it opened (panelRefit); elsewhere it is
|
|
// placed by the icon again, as before.
|
|
func (h *host) sizeOpenPanel(w *application.WebviewWindow, width, height int) {
|
|
if runtime.GOOS != "windows" {
|
|
w.SetSize(width, height)
|
|
_ = h.tray.PositionWindow(w, 6)
|
|
return
|
|
}
|
|
b := w.Bounds()
|
|
var work panelRect
|
|
if s, err := w.GetScreen(); err == nil && s != nil {
|
|
work = panelRect{s.WorkArea.X, s.WorkArea.Y, s.WorkArea.Width, s.WorkArea.Height}
|
|
}
|
|
r := panelRefit(panelRect{b.X, b.Y, b.Width, b.Height}, work, width, height)
|
|
w.SetBounds(application.Rect{X: r.x, Y: r.y, Width: r.w, Height: r.h})
|
|
}
|