aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2010-09-20 10:18:09 +1000
committerNigel Tao <nigeltao@golang.org>2010-09-20 10:18:09 +1000
commitafbee9d87d1ce9fd98e1beb9ac8945263c1f3e52 (patch)
tree9b817757a09fe872116f15bda1fbfe5a6a571814
parent1e4b1f93375be572c11af1d4f07a8eb14a4e8afe (diff)
downloadgo-afbee9d87d1ce9fd98e1beb9ac8945263c1f3e52.tar.gz
go-afbee9d87d1ce9fd98e1beb9ac8945263c1f3e52.zip
exp/draw/x11: mouse location is a signed integer.
R=r CC=golang-dev https://golang.org/cl/2192043
-rw-r--r--src/pkg/exp/draw/x11/conn.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pkg/exp/draw/x11/conn.go b/src/pkg/exp/draw/x11/conn.go
index 8dfa9a48c9..beba0a694c 100644
--- a/src/pkg/exp/draw/x11/conn.go
+++ b/src/pkg/exp/draw/x11/conn.go
@@ -218,19 +218,18 @@ func (c *conn) readSocket() {
c.mouseState.Nsec = time.Nanoseconds()
c.eventc <- c.mouseState
case 0x06: // Motion notify.
- c.mouseState.Loc.X = int(c.buf[25])<<8 | int(c.buf[24])
- c.mouseState.Loc.Y = int(c.buf[27])<<8 | int(c.buf[26])
+ c.mouseState.Loc.X = int(int16(c.buf[25])<<8 | int16(c.buf[24]))
+ c.mouseState.Loc.Y = int(int16(c.buf[27])<<8 | int16(c.buf[26]))
c.mouseState.Nsec = time.Nanoseconds()
c.eventc <- c.mouseState
case 0x0c: // Expose.
// A single user action could trigger multiple expose events (e.g. if moving another
- // window with XShape'd rounded corners over our window). In that case, the X server
- // will send a count (in bytes 16-17) of the number of additional expose events coming.
+ // window with XShape'd rounded corners over our window). In that case, the X server will
+ // send a uint16 count (in bytes 16-17) of the number of additional expose events coming.
// We could parse each event for the (x, y, width, height) and maintain a minimal dirty
// rectangle, but for now, the simplest approach is to paint the entire window, when
// receiving the final event in the series.
- count := int(c.buf[17])<<8 | int(c.buf[16])
- if count == 0 {
+ if c.buf[17] == 0 && c.buf[16] == 0 {
// TODO(nigeltao): Should we ignore the very first expose event? A freshly mapped window
// will trigger expose, but until the first c.FlushImage call, there's probably nothing to
// paint but black. For an 800x600 window, at 4 bytes per pixel, each repaint writes about