internal/ui: bug fix: show a black dot at the red button when needed

When SetWindowClosingHandled(true) is called, a black dot should be
shown at the red button to close the window.

Closes #3020
This commit is contained in:
Hajime Hoshi 2024-07-31 23:54:16 +09:00
parent 3106f98b52
commit 856b339298
4 changed files with 42 additions and 0 deletions

View File

@ -238,6 +238,7 @@ var (
sel_origResizable = objc.RegisterName("isOrigResizable") sel_origResizable = objc.RegisterName("isOrigResizable")
sel_setCollectionBehavior = objc.RegisterName("setCollectionBehavior:") sel_setCollectionBehavior = objc.RegisterName("setCollectionBehavior:")
sel_setDelegate = objc.RegisterName("setDelegate:") sel_setDelegate = objc.RegisterName("setDelegate:")
sel_setDocumentEdited = objc.RegisterName("setDocumentEdited:")
sel_setOrigDelegate = objc.RegisterName("setOrigDelegate:") sel_setOrigDelegate = objc.RegisterName("setOrigDelegate:")
sel_setOrigResizable = objc.RegisterName("setOrigResizable:") sel_setOrigResizable = objc.RegisterName("setOrigResizable:")
sel_toggleFullScreen = objc.RegisterName("toggleFullScreen:") sel_toggleFullScreen = objc.RegisterName("toggleFullScreen:")
@ -433,3 +434,13 @@ func initializeWindowAfterCreation(w *glfw.Window) error {
func (u *UserInterface) skipTaskbar() error { func (u *UserInterface) skipTaskbar() error {
return nil return nil
} }
// setDocumentEdited must be called from the main thread.
func (u *UserInterface) setDocumentEdited(edited bool) error {
w, err := u.window.GetCocoaWindow()
if err != nil {
return err
}
objc.ID(w).Send(sel_setDocumentEdited, edited)
return nil
}

View File

@ -568,6 +568,22 @@ func (u *UserInterface) setWindowClosingHandled(handled bool) {
u.m.Lock() u.m.Lock()
u.windowClosingHandled = handled u.windowClosingHandled = handled
u.m.Unlock() u.m.Unlock()
if !u.isRunning() {
return
}
if u.isTerminated() {
return
}
u.mainThread.Call(func() {
if u.isTerminated() {
return
}
if err := u.setDocumentEdited(handled); err != nil {
u.setError(err)
return
}
})
} }
// isFullscreen must be called from the main thread. // isFullscreen must be called from the main thread.
@ -874,6 +890,13 @@ func (u *UserInterface) createWindow() error {
return err return err
} }
u.m.Lock()
closingHandled := u.windowClosingHandled
u.m.Unlock()
if err := u.setDocumentEdited(closingHandled); err != nil {
return err
}
return nil return nil
} }

View File

@ -200,3 +200,7 @@ func initializeWindowAfterCreation(w *glfw.Window) error {
func (u *UserInterface) skipTaskbar() error { func (u *UserInterface) skipTaskbar() error {
return nil return nil
} }
func (u *UserInterface) setDocumentEdited(edited bool) error {
return nil
}

View File

@ -242,6 +242,10 @@ func (u *UserInterface) skipTaskbar() error {
return nil return nil
} }
func (u *UserInterface) setDocumentEdited(edited bool) error {
return nil
}
func init() { func init() {
if microsoftgdk.IsXbox() { if microsoftgdk.IsXbox() {
// TimeBeginPeriod might not be defined in Xbox. // TimeBeginPeriod might not be defined in Xbox.