Added Detection if last screen count was 1, no window rescue needed.

Added: On rescuce, start at 0,0
This commit is contained in:
2026-05-19 11:55:20 -04:00
parent 75200ff664
commit a710b6c5de
+12 -6
View File
@@ -211,8 +211,8 @@ function obj.rescueWindowsToLaptop()
if f.w > maxFrame.w then f.w = maxFrame.w - 100 end if f.w > maxFrame.w then f.w = maxFrame.w - 100 end
if f.h > maxFrame.h then f.h = maxFrame.h - 100 end if f.h > maxFrame.h then f.h = maxFrame.h - 100 end
f.x = maxFrame.x + 50 + staggerOffset f.x = maxFrame.x + staggerOffset
f.y = maxFrame.y + 50 + staggerOffset f.y = maxFrame.y + staggerOffset
win:setFrame(f, 0) win:setFrame(f, 0)
staggerOffset = staggerOffset + 30 staggerOffset = staggerOffset + 30
@@ -276,7 +276,9 @@ obj.powerWatcher = hs.caffeinate.watcher.new(function(event)
elseif event == hs.caffeinate.watcher.systemDidWake or event == hs.caffeinate.watcher.screensDidWake or event == hs.caffeinate.watcher.screensDidUnlock then elseif event == hs.caffeinate.watcher.systemDidWake or event == hs.caffeinate.watcher.screensDidWake or event == hs.caffeinate.watcher.screensDidUnlock then
log("POWER: Wake event.") log("POWER: Wake event.")
obj.saveCountdown = obj.saveInterval obj.saveCountdown = obj.saveInterval
obj.isMenuUpdating = false -- Explicitly clean guard flag upon waking up obj.isMenuUpdating = false
obj.isTransitioning = false
obj.isRestoring = false
-- Safely start timers up only after wakeup initialization -- Safely start timers up only after wakeup initialization
if obj.autoSaveTimer then obj.autoSaveTimer:start() end if obj.autoSaveTimer then obj.autoSaveTimer:start() end
@@ -294,9 +296,13 @@ obj.powerWatcher = hs.caffeinate.watcher.new(function(event)
obj.wakeTimer = nil obj.wakeTimer = nil
end) end)
else else
log("WAKE SKIP: Single screen detected. Syncing count only.") -- Only run rescue if the state actually dropped from multi-monitor down to single monitor during sleep
obj.isTransitioning = false if obj.lastScreenCount > 1 then
obj.isRestoring = false log("WAKE ACTIVATE: Screen count dropped from " .. obj.lastScreenCount .. " to 1 during sleep. Running rescue.")
obj.rescueWindowsToLaptop()
else
log("WAKE SKIP: Woke up on single screen, matched previous state. No rescue needed.")
end
obj.lastScreenCount = currentScreens obj.lastScreenCount = currentScreens
updateMenu() updateMenu()
end end