internal/glfw: bug fix: the window should be focused when closing is handled

Closes #2165
This commit is contained in:
Hajime Hoshi 2022-08-12 22:34:17 +09:00
parent dd292552d5
commit bc8e2fe6ac
3 changed files with 17 additions and 6 deletions

View File

@ -105,6 +105,10 @@ func (w *Window) Destroy() {
theWindows.remove(w.w)
}
func (w *Window) Focus() {
w.w.Focus()
}
func (w *Window) GetAttrib(attrib Hint) int {
return w.w.GetAttrib(glfw.Hint(attrib))
}

View File

@ -66,6 +66,12 @@ func (w *Window) Destroy() {
}
}
func (w *Window) Focus() {
if err := (*glfwwin.Window)(w).Focus(); err != nil {
panic(err)
}
}
func (w *Window) GetAttrib(attrib Hint) int {
r, err := (*glfwwin.Window)(w).GetAttrib(glfwwin.Hint(attrib))
if err != nil {
@ -74,12 +80,6 @@ func (w *Window) GetAttrib(attrib Hint) int {
return r
}
func (w *Window) SetAttrib(attrib Hint, value int) {
if err := (*glfwwin.Window)(w).SetAttrib(glfwwin.Hint(attrib), value); err != nil {
panic(err)
}
}
func (w *Window) GetCursorPos() (x, y float64) {
x, y, err := (*glfwwin.Window)(w).GetCursorPos()
if err != nil {
@ -166,6 +166,12 @@ func (w *Window) Restore() {
}
}
func (w *Window) SetAttrib(attrib Hint, value int) {
if err := (*glfwwin.Window)(w).SetAttrib(glfwwin.Hint(attrib), value); err != nil {
panic(err)
}
}
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback) {
f, err := (*glfwwin.Window)(w).SetCharModsCallback(cbfun)
if err != nil {

View File

@ -780,6 +780,7 @@ func (u *userInterfaceImpl) registerWindowCloseCallback() {
if !u.isWindowClosingHandled() {
return
}
u.window.Focus()
u.window.SetShouldClose(false)
})
}