diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-10 09:55:14 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-10 09:55:14 -0400 |
| commit | 43b3f1c2a8e62d3fa583af3ad5dde5f98daadc7e (patch) | |
| tree | 1075d6d90e8e2ff99ff6c53a0499966bc2534a62 /uitask_windows.go | |
| parent | 7b2e6b7fa3799ce686dd7509cf9cf6d9b94c2835 (diff) | |
Partial go fmt. Will do the rest over the next few commits. While I'm not too happy about it, everyone else uses go fmt, and pull requests will be more convenient if I just do it. (Also do it now, because when I change the Windows backend things are going to change...)
Diffstat (limited to 'uitask_windows.go')
| -rw-r--r-- | uitask_windows.go | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/uitask_windows.go b/uitask_windows.go index 04ab54a..28e9165 100644 --- a/uitask_windows.go +++ b/uitask_windows.go @@ -4,9 +4,9 @@ package ui import ( "fmt" + "runtime" "syscall" "unsafe" - "runtime" ) /* @@ -25,18 +25,18 @@ yay. var uitask chan *uimsg type uimsg struct { - call *syscall.LazyProc - p []uintptr - ret chan uiret + call *syscall.LazyProc + p []uintptr + ret chan uiret } type uiret struct { - ret uintptr - err error + ret uintptr + err error } const ( - msgRequested = _WM_APP + iota + 1 // + 1 just to be safe + msgRequested = _WM_APP + iota + 1 // + 1 just to be safe msgQuit msgSetAreaSize msgRepaintAll @@ -67,7 +67,7 @@ func ui(main func()) error { msgRequested, uintptr(0), uintptr(unsafe.Pointer(m))) - if r1 == 0 { // failure + if r1 == 0 { // failure panic("error sending message to message loop to call function: " + err.Error()) } } @@ -80,7 +80,7 @@ func ui(main func()) error { msgQuit, uintptr(0), uintptr(0)) - if r1 == 0 { // failure + if r1 == 0 { // failure panic("error sending quit message to message loop: " + err.Error()) } }() @@ -90,21 +90,21 @@ func ui(main func()) error { } var ( - _dispatchMessage = user32.NewProc("DispatchMessageW") - _getMessage = user32.NewProc("GetMessageW") - _postQuitMessage = user32.NewProc("PostQuitMessage") - _sendMessage = user32.NewProc("SendMessageW") + _dispatchMessage = user32.NewProc("DispatchMessageW") + _getMessage = user32.NewProc("GetMessageW") + _postQuitMessage = user32.NewProc("PostQuitMessage") + _sendMessage = user32.NewProc("SendMessageW") _translateMessage = user32.NewProc("TranslateMessage") ) func msgloop() { var msg struct { - hwnd _HWND - message uint32 - wParam _WPARAM - lParam _LPARAM - time uint32 - pt _POINT + hwnd _HWND + message uint32 + wParam _WPARAM + lParam _LPARAM + time uint32 + pt _POINT } for { @@ -113,10 +113,10 @@ func msgloop() { uintptr(_NULL), uintptr(0), uintptr(0)) - if r1 == negConst(-1) { // error + if r1 == negConst(-1) { // error panic("error getting message in message loop: " + err.Error()) } - if r1 == 0 { // WM_QUIT message + if r1 == 0 { // WM_QUIT message return } _translateMessage.Call(uintptr(unsafe.Pointer(&msg))) @@ -131,16 +131,16 @@ var ( func makeMessageHandler() (hwnd _HWND, err error) { wc := &_WNDCLASS{ - lpszClassName: utf16ToArg(msghandlerclass), - lpfnWndProc: syscall.NewCallback(messageHandlerWndProc), - hInstance: hInstance, - hIcon: icon, - hCursor: cursor, - hbrBackground: _HBRUSH(_COLOR_BTNFACE + 1), + lpszClassName: utf16ToArg(msghandlerclass), + lpfnWndProc: syscall.NewCallback(messageHandlerWndProc), + hInstance: hInstance, + hIcon: icon, + hCursor: cursor, + hbrBackground: _HBRUSH(_COLOR_BTNFACE + 1), } r1, _, err := _registerClass.Call(uintptr(unsafe.Pointer(wc))) - if r1 == 0 { // failure + if r1 == 0 { // failure return _HWND(_NULL), fmt.Errorf("error registering the class of the invisible window for handling events: %v", err) } @@ -158,7 +158,7 @@ func makeMessageHandler() (hwnd _HWND, err error) { uintptr(_NULL), uintptr(hInstance), uintptr(_NULL)) - if r1 == 0 { // failure + if r1 == 0 { // failure return _HWND(_NULL), fmt.Errorf("error actually creating invisible window for handling events: %v", err) } @@ -171,8 +171,8 @@ func messageHandlerWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPAR m := (*uimsg)(unsafe.Pointer(lParam)) r1, _, err := m.call.Call(m.p...) m.ret <- uiret{ - ret: r1, - err: err, + ret: r1, + err: err, } return 0 case msgQuit: |
