summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-10 09:55:14 -0400
committerPietro Gagliardi <[email protected]>2014-06-10 09:55:14 -0400
commit43b3f1c2a8e62d3fa583af3ad5dde5f98daadc7e (patch)
tree1075d6d90e8e2ff99ff6c53a0499966bc2534a62
parent7b2e6b7fa3799ce686dd7509cf9cf6d9b94c2835 (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...)
-rw-r--r--uitask_darwin.go2
-rw-r--r--uitask_unix.go4
-rw-r--r--uitask_windows.go62
-rw-r--r--window.go26
4 files changed, 47 insertions, 47 deletions
diff --git a/uitask_darwin.go b/uitask_darwin.go
index dce9479..70cbee6 100644
--- a/uitask_darwin.go
+++ b/uitask_darwin.go
@@ -54,6 +54,6 @@ func initCocoa() (err error) {
//export appDelegate_uitask
func appDelegate_uitask(p unsafe.Pointer) {
- f := (*func ())(unsafe.Pointer(p))
+ f := (*func())(unsafe.Pointer(p))
(*f)()
}
diff --git a/uitask_unix.go b/uitask_unix.go
index 0ff07f4..030f096 100644
--- a/uitask_unix.go
+++ b/uitask_unix.go
@@ -30,8 +30,8 @@ func ui(main func()) error {
for f := range uitask {
done := make(chan struct{})
gdk_threads_add_idle(&gtkIdleOp{
- what: f,
- done: done,
+ what: f,
+ done: done,
})
<-done
close(done)
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:
diff --git a/window.go b/window.go
index e65d55d..02b33e9 100644
--- a/window.go
+++ b/window.go
@@ -12,25 +12,25 @@ type Window struct {
// Closing gets a message when the user clicks the window's close button.
// You cannot change it once the Window has been created.
// If you do not respond to this signal, nothing will happen; regardless of whether you handle the signal or not, the window will not be closed.
- Closing chan struct{}
+ Closing chan struct{}
- lock sync.Mutex
- created bool
- sysData *sysData
- initTitle string
- initWidth int
- initHeight int
- shownOnce bool
+ lock sync.Mutex
+ created bool
+ sysData *sysData
+ initTitle string
+ initWidth int
+ initHeight int
+ shownOnce bool
}
// NewWindow allocates a new Window with the given title and size. The window is not created until a call to Create() or Open().
func NewWindow(title string, width int, height int) *Window {
return &Window{
- sysData: mksysdata(c_window),
- initTitle: title,
- initWidth: width,
- initHeight: height,
- Closing: newEvent(),
+ sysData: mksysdata(c_window),
+ initTitle: title,
+ initWidth: width,
+ initHeight: height,
+ Closing: newEvent(),
}
}