From 41c3fd4934be969fc0863e0d8eb0e6b182729e26 Mon Sep 17 00:00:00 2001 From: Mikhail Kiselev Date: Tue, 10 Feb 2026 23:36:06 +0300 Subject: [PATCH] feat: save and restore window position --- internal/app/app.go | 28 ++++++++++++++++++++++++++++ internal/models/models.go | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/internal/app/app.go b/internal/app/app.go index 6525b3f..e66946c 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -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) { diff --git a/internal/models/models.go b/internal/models/models.go index ffbfe20..267c469 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -67,6 +67,8 @@ type Settings struct { SoundMeetingEnd string `json:"soundMeetingEnd" gorm:"default:meeting_end.mp3"` WarningThreshold int `json:"warningThreshold" gorm:"default:30"` // seconds before time up Theme string `json:"theme" gorm:"default:dark"` - WindowWidth int `json:"windowWidth" gorm:"default:800"` // minimum 480 + WindowWidth int `json:"windowWidth" gorm:"default:800"` // minimum 480 WindowFullHeight bool `json:"windowFullHeight" gorm:"default:true"` // use full screen height + WindowX int `json:"windowX" gorm:"default:-1"` // -1 = not set (center) + WindowY int `json:"windowY" gorm:"default:-1"` // -1 = not set (center) }