app/internal: [Windows] support Window.Close

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2020-06-19 13:04:26 +03:00
committed by Elias Naur
parent c35d81e828
commit 0b713032fb
4 changed files with 13 additions and 8 deletions
-1
View File
@@ -133,7 +133,6 @@ func (w *window) SetAnimating(anim bool) {
}
}
// Close the window. Only implemented for macOS.
func (w *window) Close() {
runOnMain(func() {
// Make sure the view is still valid. The window might've been closed
+10 -5
View File
@@ -178,10 +178,13 @@ func createNativeWindow(opts *Options) (*window, error) {
}
func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr {
var w *window
if win, exists := winMap.Load(hwnd); exists {
w = win.(*window)
win, exists := winMap.Load(hwnd)
if !exists {
return windows.DefWindowProc(hwnd, msg, wParam, lParam)
}
w := win.(*window)
switch msg {
case windows.WM_UNICHAR:
if wParam == windows.UNICODE_NOCHAR {
@@ -249,6 +252,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
w.setStage(system.StageRunning)
}
}
return windows.DefWindowProc(hwnd, msg, wParam, lParam)
}
@@ -501,8 +505,9 @@ func (w *window) HWND() (syscall.Handle, int, int) {
return w.hwnd, w.width, w.height
}
// Close the window. Not implemented for Windows.
func (w *window) Close() {}
func (w *window) Close() {
windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0)
}
func convertKeyCode(code uintptr) (string, bool) {
if '0' <= code && code <= '9' || 'A' <= code && code <= 'Z' {