feat: save and restore window position
This commit is contained in:
@@ -39,10 +39,19 @@ func (a *App) Startup(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (a *App) OnDomReady(ctx context.Context) {
|
||||
// Restore saved window position
|
||||
if settings, err := a.store.GetSettings(); err == nil && settings != nil {
|
||||
if settings.WindowX >= 0 && settings.WindowY >= 0 {
|
||||
runtime.WindowSetPosition(ctx, settings.WindowX, settings.WindowY)
|
||||
}
|
||||
}
|
||||
runtime.WindowShow(ctx)
|
||||
}
|
||||
|
||||
func (a *App) Shutdown(ctx context.Context) {
|
||||
// Save window position before closing
|
||||
a.saveWindowPosition()
|
||||
|
||||
if a.timer != nil {
|
||||
a.timer.Close()
|
||||
}
|
||||
@@ -51,6 +60,25 @@ func (a *App) Shutdown(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) saveWindowPosition() {
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
x, y := runtime.WindowGetPosition(a.ctx)
|
||||
if x >= 0 && y >= 0 {
|
||||
if settings, err := a.store.GetSettings(); err == nil && settings != nil {
|
||||
settings.WindowX = x
|
||||
settings.WindowY = y
|
||||
_ = a.store.UpdateSettings(settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SaveWindowPosition saves current window position (can be called from frontend)
|
||||
func (a *App) SaveWindowPosition() {
|
||||
a.saveWindowPosition()
|
||||
}
|
||||
|
||||
// Participants
|
||||
|
||||
func (a *App) GetParticipants() ([]models.Participant, error) {
|
||||
|
||||
Reference in New Issue
Block a user