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.
|
yay.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var uitask chan *uimsg
|
var uitask chan interface{}
|
||||||
|
|
||||||
type uimsg struct {
|
type uimsg struct {
|
||||||
call *syscall.LazyProc
|
call *syscall.LazyProc
|
||||||
|
@ -49,7 +49,7 @@ var (
|
||||||
func ui(main func()) error {
|
func ui(main func()) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
uitask = make(chan *uimsg)
|
uitask = make(chan interface{})
|
||||||
err := doWindowsInit()
|
err := doWindowsInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error doing general Windows initialization: %v", err)
|
return fmt.Errorf("error doing general Windows initialization: %v", err)
|
||||||
|
@ -66,7 +66,7 @@ func ui(main func()) error {
|
||||||
uintptr(hwnd),
|
uintptr(hwnd),
|
||||||
msgRequested,
|
msgRequested,
|
||||||
uintptr(0),
|
uintptr(0),
|
||||||
uintptr(unsafe.Pointer(m)))
|
uintptr(unsafe.Pointer(&m)))
|
||||||
if r1 == 0 { // failure
|
if r1 == 0 { // failure
|
||||||
panic("error sending message to message loop to call function: " + err.Error())
|
panic("error sending message to message loop to call function: " + err.Error())
|
||||||
}
|
}
|
||||||
|
@ -168,11 +168,16 @@ func makeMessageHandler() (hwnd _HWND, err error) {
|
||||||
func messageHandlerWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
|
func messageHandlerWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
|
||||||
switch uMsg {
|
switch uMsg {
|
||||||
case msgRequested:
|
case msgRequested:
|
||||||
m := (*uimsg)(unsafe.Pointer(lParam))
|
mt := (*interface{})(unsafe.Pointer(lParam))
|
||||||
r1, _, err := m.call.Call(m.p...)
|
switch m := (*mt).(type) {
|
||||||
m.ret <- uiret{
|
case *uimsg:
|
||||||
ret: r1,
|
r1, _, err := m.call.Call(m.p...)
|
||||||
err: err,
|
m.ret <- uiret{
|
||||||
|
ret: r1,
|
||||||
|
err: err,
|
||||||
|
}
|
||||||
|
case func():
|
||||||
|
m()
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
case msgQuit:
|
case msgQuit:
|
||||||
|
|
Loading…
Reference in New Issue