From 44811e5351c13917f400fe5eed0145e224f0c43e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 8 Jul 2014 17:43:50 -0400 Subject: Implemented window closing on Mac OS X. This drops the "single delegate object for everything" setup but keeping that map and holding its lock is already meh so. --- redo/window_darwin.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'redo/window_darwin.go') diff --git a/redo/window_darwin.go b/redo/window_darwin.go index c6d9585..c3d4521 100644 --- a/redo/window_darwin.go +++ b/redo/window_darwin.go @@ -23,11 +23,12 @@ func newWindow(title string, width int, height int) *Request { ctitle := C.CString(title) defer C.free(unsafe.Pointer(ctitle)) C.windowSetTitle(id, ctitle) - C.windowSetAppDelegate(id) - c <- &window{ + w := &window{ id: id, closing: newEvent(), } + C.windowSetDelegate(id, unsafe.Pointer(w)) + c <- w }, resp: c, } @@ -112,7 +113,17 @@ func (w *window) OnClosing(e func(c Doer) bool) *Request { } } -// TODO windowClosing +//export windowClosing +func windowClosing(xw unsafe.Pointer) C.BOOL { + w := (*window)(unsafe.Pointer(xw)) + close := w.closing.fire() + if close { + // TODO make sure this actually closes the window the way we want + return C.YES + } + return C.NO +} + // TODO for testing func newButton(string) *Request { return nil } -- cgit v1.2.3