Fix #745: add option to prevent screensaver on Now Playing page

This commit is contained in:
Drew Weymouth
2025-11-10 08:12:46 -08:00
parent 828b5ffc56
commit 8b73765a7d
5 changed files with 51 additions and 24 deletions
+14
View File
@@ -51,6 +51,8 @@ type MainWindow struct {
// updated when changing servers or libraries
librarySubmenu *fyne.Menu
isScreensaverDisabled bool
}
func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string, app *backend.App) MainWindow {
@@ -156,6 +158,18 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
m.Window.SetContent(fynetooltip.AddWindowToolTipLayer(m.content, m.Window.Canvas()))
m.setInitialSize()
m.Router.OnNavigateTo = func(r controller.Route) {
if r.Page == controller.NowPlayingRoute().Page {
if m.App.Config.Application.PreventScreensaverOnNowPlayingPage && !m.isScreensaverDisabled {
fyne.CurrentApp().Driver().SetDisableScreenBlanking(true)
m.isScreensaverDisabled = true
}
} else if m.isScreensaverDisabled {
fyne.CurrentApp().Driver().SetDisableScreenBlanking(false)
m.isScreensaverDisabled = false
}
}
m.Window.SetCloseIntercept(func() {
m.SaveWindowSettings()
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {