GetWindowTitle was returning info.Name (the window's identifier) instead of the actual title. Added Title() to the PlatformWindow interface and Title field to WindowInfo so the real title flows through queries. Added wsRequire() helper and input validation for all webview:* WS message cases — window name is required for every webview action, and selectors/URLs are validated where they'd cause errors if empty. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
// pkg/window/platform.go
|
|
package window
|
|
|
|
// Platform abstracts the windowing backend (Wails v3).
|
|
type Platform interface {
|
|
CreateWindow(opts PlatformWindowOptions) PlatformWindow
|
|
GetWindows() []PlatformWindow
|
|
}
|
|
|
|
// PlatformWindowOptions are the backend-specific options passed to CreateWindow.
|
|
type PlatformWindowOptions struct {
|
|
Name string
|
|
Title string
|
|
URL string
|
|
Width, Height int
|
|
X, Y int
|
|
MinWidth, MinHeight int
|
|
MaxWidth, MaxHeight int
|
|
Frameless bool
|
|
Hidden bool
|
|
AlwaysOnTop bool
|
|
BackgroundColour [4]uint8 // RGBA
|
|
DisableResize bool
|
|
EnableFileDrop bool
|
|
}
|
|
|
|
// PlatformWindow is a live window handle from the backend.
|
|
type PlatformWindow interface {
|
|
// Identity
|
|
Name() string
|
|
Title() string
|
|
|
|
// Queries
|
|
Position() (int, int)
|
|
Size() (int, int)
|
|
IsMaximised() bool
|
|
IsFocused() bool
|
|
|
|
// Mutations
|
|
SetTitle(title string)
|
|
SetPosition(x, y int)
|
|
SetSize(width, height int)
|
|
SetBackgroundColour(r, g, b, a uint8)
|
|
SetVisibility(visible bool)
|
|
SetAlwaysOnTop(alwaysOnTop bool)
|
|
|
|
// Window state
|
|
Maximise()
|
|
Restore()
|
|
Minimise()
|
|
Focus()
|
|
Close()
|
|
Show()
|
|
Hide()
|
|
Fullscreen()
|
|
UnFullscreen()
|
|
|
|
// Events
|
|
OnWindowEvent(handler func(event WindowEvent))
|
|
|
|
// File drop
|
|
OnFileDrop(handler func(paths []string, targetID string))
|
|
}
|
|
|
|
// WindowEvent is emitted by the backend for window state changes.
|
|
type WindowEvent struct {
|
|
Type string // "focus", "blur", "move", "resize", "close"
|
|
Name string // window name
|
|
Data map[string]any
|
|
}
|