Documentation
¶
Overview ¶
Package windowstate remembers where a window was: its position, size and whether it was maximized, saved as it changes and restored the next time the app starts.
s, _ := app.NewSurface(tango.SurfaceOptions{Hidden: true, Resizable: true})
windowstate.Track(s, "main", nil) // nil: <UserConfigDir>/<App.ID>/windows.json
s.Show()
Track before showing the window so it does not jump. A saved position that is no longer on any display (a monitor was unplugged) is not restored; the window keeps its size and is centered instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SaveDelay = 400 * time.Millisecond
SaveDelay is how long Track waits after the last change before saving.
Functions ¶
func DefaultPath ¶
DefaultPath returns <os.UserConfigDir>/<appID>/windows.json. An empty appID uses the executable's name.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is a Store backed by one JSON file holding every key.
func NewFileStore ¶
NewFileStore returns the store for the JSON file at path. Stores for the same path are shared, so windows tracked separately do not overwrite each other's entries.
type State ¶
type State struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
Maximized bool `json:"maximized,omitempty"`
}
State is what is remembered of one window. X, Y, Width, Height are the normal (not maximized) bounds, as tango.Surface.Bounds returns them.