Added the scaffolding that will allow us to change uitask on Windows to take a func(). Right now it accepts both; this will allow me to do piecewise conversion.
This commit is contained in:
parent
b0ce712b0e
commit
fc18ecc3d8
|
@ -22,7 +22,7 @@ the only recourse, and the one both Microsoft (http://support.microsoft.com/kb/1
|
|||
yay.
|
||||
*/
|
||||
|
||||
var uitask chan *uimsg
|
||||
var uitask chan interface{}
|
||||
|
||||
type uimsg struct {
|
||||
call *syscall.LazyProc
|
||||
|
@ -49,7 +49,7 @@ var (
|
|||
func ui(main func()) error {
|
||||
runtime.LockOSThread()
|
||||
|
||||
uitask = make(chan *uimsg)
|
||||
uitask = make(chan interface{})
|
||||
err := doWindowsInit()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error doing general Windows initialization: %v", err)
|
||||
|
@ -66,7 +66,7 @@ func ui(main func()) error {
|
|||
uintptr(hwnd),
|
||||
msgRequested,
|
||||
uintptr(0),
|
||||
uintptr(unsafe.Pointer(m)))
|
||||
uintptr(unsafe.Pointer(&m)))
|
||||
if r1 == 0 { // failure
|
||||
panic("error sending message to message loop to call function: " + err.Error())
|
||||
}
|
||||
|
@ -168,12 +168,17 @@ func makeMessageHandler() (hwnd _HWND, err error) {
|
|||
func messageHandlerWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
|
||||
switch uMsg {
|
||||
case msgRequested:
|
||||
m := (*uimsg)(unsafe.Pointer(lParam))
|
||||
mt := (*interface{})(unsafe.Pointer(lParam))
|
||||
switch m := (*mt).(type) {
|
||||
case *uimsg:
|
||||
r1, _, err := m.call.Call(m.p...)
|
||||
m.ret <- uiret{
|
||||
ret: r1,
|
||||
err: err,
|
||||
}
|
||||
case func():
|
||||
m()
|
||||
}
|
||||
return 0
|
||||
case msgQuit:
|
||||
// does not return a value according to MSDN
|
||||
|
|
Loading…
Reference in New Issue