gui/window: keep the window frame across starts, take the first click

- Options.FrameFile: the window's position, size and maximized state in
  a small JSON file, read at New (a frame on no connected screen is
  ignored, the window opens centered), written shortly after every move
  or resize and at Destroy. macOS: NSWindow frame (the normal frame
  under a zoomed one), checked against NSScreen visible frames; Windows:
  Get/SetWindowPlacement, checked with MonitorFromRect.
- macOS: the web view is a WKWebView subclass that accepts the first
  mouse click, so a page in an inactive window reacts to it instead of
  the click only activating the window (yanks' start dialog).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-11-15 15:19:45 +01:00
1 parent c16b871db5
commit 31dbc347e8
9 files changed
+325 -13

No files matched your search

+18 -1
View File
@@ -63,7 +63,16 @@ func newBackend(opt Options) (backend, string, string, error) {
if opt.Debug {
debug = 1
}
b.h = C.yt_create(C.uintptr_t(b.handle), title, C.int(opt.Width), C.int(opt.Height), C.int(debug), scheme)
var has, zoomed C.int
var f Frame
if opt.restore != nil {
has, f = 1, *opt.restore
if f.Maximized {
zoomed = 1
}
}
b.h = C.yt_create(C.uintptr_t(b.handle), title, C.int(opt.Width), C.int(opt.Height), C.int(debug), scheme,
has, C.int(f.X), C.int(f.Y), C.int(f.Width), C.int(f.Height), zoomed)
if b.h == nil {
b.handle.Delete()
return nil, "", "", errUnavailable("WKWebView could not be created")
@@ -122,6 +131,14 @@ func ytGoDispatch(fn C.uintptr_t) {
f()
}
//export ytGoFrame
func ytGoFrame(h C.uintptr_t, x, y, w, hgt, zoomed C.int) {
b := cgo.Handle(h).Value().(*darwinBackend)
if b.opt.onFrame != nil {
b.opt.onFrame(Frame{X: int(x), Y: int(y), Width: int(w), Height: int(hgt), Maximized: zoomed != 0})
}
}
//export ytGoMessage
func ytGoMessage(h C.uintptr_t, msg *C.char) {
b := cgo.Handle(h).Value().(*darwinBackend)