From 2bafc212291b260f313e10ff70ee6e72fbd2fbc0 Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 24 Jul 2026 10:49:37 -0400 Subject: [PATCH] gamma: replace login1 scheduler re-calculation with suspend-aware boottimer --- core/go.mod | 2 +- core/go.sum | 4 ++-- core/internal/server/wayland/manager.go | 28 ++++++------------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/core/go.mod b/core/go.mod index ddff84283..4792a859d 100644 --- a/core/go.mod +++ b/core/go.mod @@ -69,7 +69,7 @@ require ( ) require ( - github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d + github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05 github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/charmbracelet/colorprofile v0.4.3 // indirect diff --git a/core/go.sum b/core/go.sum index 9d03561b4..ddab0a57d 100644 --- a/core/go.sum +++ b/core/go.sum @@ -1,7 +1,7 @@ filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= -github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d h1:EZN2x2uAX975Uvw4MByqWaaVTp2fOJrNTl4V4EQbSn8= -github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d/go.mod h1:7p7cfydr4WM1G6eOPFlANXF3IV5du3FoA4CbDPprHAo= +github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05 h1:Ij/yzOT8y2HL7V5Rkec1GxJV0rUvhKqfAzyGxVRTk1o= +github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05/go.mod h1:xt8RldAfti0QCWidwYIzsSSoJWsE61WgEhTu2H9UpD4= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM= diff --git a/core/internal/server/wayland/manager.go b/core/internal/server/wayland/manager.go index 0cd47fb6a..a152137f2 100644 --- a/core/internal/server/wayland/manager.go +++ b/core/internal/server/wayland/manager.go @@ -12,6 +12,7 @@ import ( "time" wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client" + "github.com/AvengeMedia/dankgo/boottimer" "github.com/godbus/dbus/v5" "github.com/AvengeMedia/DankMaterialShell/core/internal/errdefs" @@ -23,9 +24,6 @@ import ( const animKelvinStep = 25 -// Go timers freeze during suspend; cap sleeps so wall-clock deadlines can't be missed. -const maxScheduleWait = 5 * time.Minute - func NewManager(display wlclient.WaylandDisplay, config Config) (*Manager, error) { if err := config.Validate(); err != nil { return nil, err @@ -752,7 +750,8 @@ func (m *Manager) schedulerLoop() { m.post(func() { m.applyCurrentTemp("startup") }) } - var timer *time.Timer + timer := boottimer.New(24 * time.Hour) + defer timer.Stop() for { m.configMutex.RLock() enabled := m.config.Enabled @@ -761,31 +760,19 @@ func (m *Manager) schedulerLoop() { now := time.Now() m.recalcSchedule(now) - var waitDur time.Duration + waitDur := 24 * time.Hour if enabled { deadline := m.getNextDeadline(now) - waitDur = time.Until(deadline) - switch { - case waitDur < time.Second: + if waitDur = time.Until(deadline); waitDur < time.Second { waitDur = time.Second - case waitDur > maxScheduleWait: - waitDur = maxScheduleWait } - } else { - waitDur = 24 * time.Hour } - - if timer != nil { - timer.Stop() - } - timer = time.NewTimer(waitDur) + timer.Reset(waitDur) select { case <-m.stopChan: - timer.Stop() return case <-m.updateTrigger: - timer.Stop() m.scheduleMutex.Lock() m.schedule.calcDay = time.Time{} m.scheduleMutex.Unlock() @@ -1086,14 +1073,11 @@ func (m *Manager) handleResume() { } // Compositor gamma state is unknown after resume; force a resend (#1235) - // and re-arm the scheduler timer, which froze during suspend. m.outputs.Range(func(_ uint32, out *outputState) bool { out.lastTemp = 0 return true }) - m.recalcSchedule(time.Now()) m.applyCurrentTemp("resume") - m.triggerUpdate() } func (m *Manager) triggerUpdate() {