GLFW's applicationShouldTerminate: converts all quit paths (Cmd+Q, dock, menu bar) into window close requests and returns NSTerminateCancel, so our close-to-hide intercept was hiding the window instead of letting the app exit. Fix by implementing applicationShouldTerminate: in ReopenDelegate, setting a darwinQuitting flag before forwarding to GLFW's delegate. The close intercept checks this flag and calls Window.Close() instead of Hide() when quitting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
720 B
Go
41 lines
720 B
Go
//go:build darwin
|
|
|
|
package ui
|
|
|
|
/*
|
|
void installReopenDelegate();
|
|
*/
|
|
import "C"
|
|
|
|
import "fyne.io/fyne/v2"
|
|
|
|
var darwinAppDelegateReopenWindow fyne.Window
|
|
|
|
// darwinQuitting is set to true when applicationShouldTerminate: fires so
|
|
// the close intercept knows to actually close instead of hide.
|
|
var darwinQuitting bool
|
|
|
|
func isRealQuit() bool {
|
|
return darwinQuitting
|
|
}
|
|
|
|
func installReopenHandler(w fyne.Window) {
|
|
darwinAppDelegateReopenWindow = w
|
|
C.installReopenDelegate()
|
|
}
|
|
|
|
//export appReopened
|
|
func appReopened() {
|
|
if darwinAppDelegateReopenWindow == nil {
|
|
return
|
|
}
|
|
go func() {
|
|
fyne.Do(darwinAppDelegateReopenWindow.Show)
|
|
}()
|
|
}
|
|
|
|
//export appShouldTerminate
|
|
func appShouldTerminate() {
|
|
darwinQuitting = true
|
|
}
|