summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-27 20:31:23 -0400
committerPietro Gagliardi <[email protected]>2014-03-27 20:31:23 -0400
commitab6e7121e47e7339822aa3e0180285b2a1c38c7c (patch)
treef3be96564689b259d72b12d6f279369d3995c478 /test
parent9dc4f8694c39304140df92a5466be862ed22f912 (diff)
Added a flag to AreaHandler.Key()/Mouse() to indicate that a repaint is needed after that event has been handled. (Having Repaint() as a method deadlocked for the same reason resizing deadlocked before.)
Diffstat (limited to 'test')
-rw-r--r--test/kbtest.go10
-rw-r--r--test/main.go7
2 files changed, 10 insertions, 7 deletions
diff --git a/test/kbtest.go b/test/kbtest.go
index 0a21954..d6fa7c1 100644
--- a/test/kbtest.go
+++ b/test/kbtest.go
@@ -34,7 +34,9 @@ func (a *keyboardArea) Paint(cliprect image.Rectangle) *image.NRGBA {
return a.kbd.SubImage(cliprect).(*image.NRGBA)
}
-func (a *keyboardArea) Mouse(MouseEvent) {}
+func (a *keyboardArea) Mouse(MouseEvent) (repaint bool) {
+ return false
+}
func markkey(dest *image.NRGBA, keypt image.Point, m Modifiers) {
xr := keyrect(m).Add(keypt)
@@ -42,7 +44,7 @@ func markkey(dest *image.NRGBA, keypt image.Point, m Modifiers) {
draw.Draw(dest, xr, xi, image.ZP, draw.Over)
}
-func (a *keyboardArea) Key(e KeyEvent) bool {
+func (a *keyboardArea) Key(e KeyEvent) (handled bool, repaint bool) {
a.lock.Lock()
defer a.lock.Unlock()
@@ -68,9 +70,9 @@ func (a *keyboardArea) Key(e KeyEvent) bool {
// markkey(a.kbd, modpoints[Super], m &^ Super)
// }
default:
- return false
+ return false, false
}
- return true
+ return true, true
}
var doKeyboard = flag.Bool("kb", false, "run keyboard test")
diff --git a/test/main.go b/test/main.go
index 60108ab..1e2b465 100644
--- a/test/main.go
+++ b/test/main.go
@@ -131,12 +131,13 @@ func (a *areaHandler) Paint(rect image.Rectangle) *image.NRGBA {
*/
return a.img.SubImage(rect).(*image.NRGBA)
}
-func (a *areaHandler) Mouse(e MouseEvent) {
+func (a *areaHandler) Mouse(e MouseEvent) bool {
fmt.Printf("%#v\n", e)
+ return false
}
-func (a *areaHandler) Key(e KeyEvent) bool {
+func (a *areaHandler) Key(e KeyEvent) (bool, bool) {
fmt.Printf("%#v\n", e)
- return false
+ return false, false
}
var doArea = flag.Bool("area", false, "run area test instead (overrides -kb)")