mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app/internal: [Windows] support Window.Close
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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' {
|
||||
|
||||
@@ -135,6 +135,7 @@ const (
|
||||
WM_MOUSEMOVE = 0x0200
|
||||
WM_MOUSEWHEEL = 0x020A
|
||||
WM_PAINT = 0x000F
|
||||
WM_CLOSE = 0x0010
|
||||
WM_QUIT = 0x0012
|
||||
WM_SETFOCUS = 0x0007
|
||||
WM_KILLFOCUS = 0x0008
|
||||
|
||||
+2
-2
@@ -211,8 +211,8 @@ func (w *Window) WriteClipboard(s string) {
|
||||
// Close the window. The window's event loop should exit when it receives
|
||||
// system.DestroyEvent.
|
||||
//
|
||||
// Currently, only the macOS driver implements this functionality, all others
|
||||
// are stubbed.
|
||||
// Currently, only macOS and Windows driver implements this functionality,
|
||||
// all others are stubbed.
|
||||
func (w *Window) Close() {
|
||||
w.driverDo(func() {
|
||||
w.driver.Close()
|
||||
|
||||
Reference in New Issue
Block a user