aboutsummaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorfaiface <faiface@ksp.sk>2017-08-19 00:17:05 +0200
committerfaiface <faiface@ksp.sk>2017-08-19 00:17:05 +0200
commit2320ce245c794386bc58660a9e20c476638ada5e (patch)
treed0bc82f312513756602203ac3f32fb08cac57003 /win
parent7b33704534e9e32016b7acfc586c32ae1df0c140 (diff)
downloadgui-2320ce245c794386bc58660a9e20c476638ada5e.zip
win: weird fixes, will clean up
Diffstat (limited to 'win')
-rw-r--r--win/events.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/win/events.go b/win/events.go
index 7ce93e5..95ef961 100644
--- a/win/events.go
+++ b/win/events.go
@@ -14,24 +14,24 @@ func (w *Win) setUpEvents(events chan<- string) {
w.w.SetMouseButtonCallback(func(_ *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey) {
switch action {
case glfw.Press:
- events <- mkEvent("mo", "down", moX, moY)
+ sendEvent(events, "mo", "down", moX, moY)
case glfw.Release:
- events <- mkEvent("mo", "up", moX, moY)
+ sendEvent(events, "mo", "up", moX, moY)
}
})
w.w.SetCursorPosCallback(func(_ *glfw.Window, x, y float64) {
moX, moY = int(x), int(y)
- events <- mkEvent("mo", "move", moX, moY)
+ sendEvent(events, "mo", "move", moX, moY)
})
w.w.SetCharCallback(func(_ *glfw.Window, r rune) {
- events <- mkEvent("kb", "type", r)
+ sendEvent(events, "kb", "type", r)
})
w.w.SetSizeCallback(func(_ *glfw.Window, width, height int) {
w.resize(width, height)
- events <- mkEvent("wi", "resize", width, height)
+ sendEvent(events, "wi", "resize", width, height)
})
w.w.SetCloseCallback(func(_ *glfw.Window) {
@@ -40,6 +40,12 @@ func (w *Win) setUpEvents(events chan<- string) {
})
}
+func sendEvent(events chan<- string, a ...interface{}) {
+ go func() {
+ events <- mkEvent(a...)
+ }()
+}
+
func mkEvent(a ...interface{}) string {
s := make([]string, len(a))
for i := range s {