summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/funcnames_windows.go1
-rw-r--r--redo/uitask.go14
-rw-r--r--redo/uitask_windows.go5
-rw-r--r--redo/zz_test.go3
4 files changed, 21 insertions, 2 deletions
diff --git a/redo/funcnames_windows.go b/redo/funcnames_windows.go
index 689e54e..9724b9a 100644
--- a/redo/funcnames_windows.go
+++ b/redo/funcnames_windows.go
@@ -26,3 +26,4 @@ package ui
// wfunc user32 SendMessageW uintptr t_UINT t_WPARAM t_LPARAM t_LRESULT,noerr
// wfunc user32 UpdateWindow uintptr uintptr
// wfunc user32 DestroyWindow uintptr uintptr
+// wfunc user32 PostQuitMessage uintptr void
diff --git a/redo/uitask.go b/redo/uitask.go
index 462a24b..b4fa77c 100644
--- a/redo/uitask.go
+++ b/redo/uitask.go
@@ -19,7 +19,19 @@ func Go() error {
return nil
}
-// TODO Stop
+// Stop returns a Request for package ui to stop.
+// Some time after this request is received, Go() will return without performing any final cleanup.
+// If Stop is issued during an event handler, it will be registered when the event handler returns.
+func Stop() *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ uistop()
+ c <- struct{}{}
+ },
+ resp: c,
+ }
+}
// This is the ui main loop.
// It is spawned by Go as a goroutine.
diff --git a/redo/uitask_windows.go b/redo/uitask_windows.go
index 1d509c1..9d8c8c3 100644
--- a/redo/uitask_windows.go
+++ b/redo/uitask_windows.go
@@ -45,6 +45,11 @@ func uimsgloop() {
}
}
+func uistop() {
+ // this works fine as documented in modal loops, as modal loops are supposed to repost quit messages (http://blogs.msdn.com/b/oldnewthing/archive/2005/02/22/378018.aspx), and all the Windows internal ones do
+ f_PostQuitMessage(0)
+}
+
func issue(req *Request) {
res, err := f_PostMessageW(
msgwin,
diff --git a/redo/zz_test.go b/redo/zz_test.go
index 9df45fd..9127f01 100644
--- a/redo/zz_test.go
+++ b/redo/zz_test.go
@@ -13,7 +13,8 @@ func init() {
go func() {
w := GetNewWindow(Do, "Hello", 320, 240)
done := make(chan struct{})
- Wait(Do, w.OnClosing(func(Doer) bool {
+ Wait(Do, w.OnClosing(func(c Doer) bool {
+ Wait(c, Stop())
done <- struct{}{}
return true
}))