Skip to content

Commit e5e033f

Browse files
authored
Merge pull request #1700 from jhult/fix/1604
fix: break windows not closing correctly on all platforms
2 parents bb80124 + 4c30259 commit e5e033f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [Unreleased]
88
### Fixed
99
- snap package not starting on Wayland
10+
- break windows not closing correctly on all platforms
1011

1112
## [1.19.0] - 2025-11-13
1213
### Added

app/main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ let updateChecker
7777
let currentTrayIconPath = null
7878
let currentTrayMenuTemplate = null
7979
let trayUpdateIntervalObj = null
80-
let skipStrictCloseGuard = false // to allow window closing in strict mode when we want to close it
8180

8281
log.initialize({ preload: true })
8382

@@ -444,12 +443,18 @@ function startPowerMonitoring () {
444443

445444
function closeWindows (windowArray) {
446445
for (const window of windowArray) {
446+
if (!window || window.isDestroyed()) {
447+
continue
448+
}
449+
447450
window.hide()
448451
if (windowArray[0] === window) {
449452
ipcMain.removeHandler('send-long-break-data')
450453
ipcMain.removeHandler('send-mini-break-data')
451454
}
452-
window.close()
455+
456+
// Use destroy() for immediate, guaranteed cleanup on all platforms
457+
window.destroy()
453458
}
454459
return null
455460
}
@@ -781,7 +786,6 @@ function startMicrobreak () {
781786
microbreakWinLocal.setAlwaysOnTop(!showBreaksAsRegularWindows, 'pop-up-menu')
782787
if (microbreakWinLocal) {
783788
microbreakWinLocal.on('close', (e) => {
784-
if (skipStrictCloseGuard) return
785789
if (breakPlanner.scheduler.timeLeft > 0 && settings.get('microbreakStrictMode')) {
786790
log.info('Stretchly: preventing closing break window as in strict mode')
787791
e.preventDefault()
@@ -937,7 +941,6 @@ function startBreak () {
937941
breakWinLocal.setAlwaysOnTop(!showBreaksAsRegularWindows, 'pop-up-menu')
938942
if (breakWinLocal) {
939943
breakWinLocal.on('close', (e) => {
940-
if (skipStrictCloseGuard) return
941944
if (breakPlanner.scheduler.timeLeft > 0 && settings.get('breakStrictMode')) {
942945
log.info('Stretchly: preventing closing break window as in strict mode')
943946
e.preventDefault()
@@ -975,10 +978,7 @@ function breakComplete (shouldPlaySound, windows, breakType) {
975978
// get focus on the last app
976979
Menu.sendActionToFirstResponder('hide:')
977980
}
978-
skipStrictCloseGuard = true
979-
const result = closeWindows(windows)
980-
skipStrictCloseGuard = false
981-
return result
981+
return closeWindows(windows)
982982
}
983983

984984
function enterManualAwaitPhase (type, shouldPlaySound) {

0 commit comments

Comments
 (0)