OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // NaCl GUI events. | 5 // NaCl GUI events. |
6 // Clients do not have raw access to the event stream | 6 // Clients do not have raw access to the event stream |
7 // (only filtered through the lens of package draw) | 7 // (only filtered through the lens of package draw) |
8 // but perhaps they will. | 8 // but perhaps they will. |
9 | 9 |
10 package av | 10 package av |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 type event interface{} | 377 type event interface{} |
378 | 378 |
379 type reader []byte | 379 type reader []byte |
380 | 380 |
381 func (r *reader) Read(p []byte) (n int, err os.Error) { | 381 func (r *reader) Read(p []byte) (n int, err os.Error) { |
382 b := *r; | 382 b := *r; |
383 if len(b) == 0 && len(p) > 0 { | 383 if len(b) == 0 && len(p) > 0 { |
384 return 0, os.EOF | 384 return 0, os.EOF |
385 } | 385 } |
386 n = bytes.Copy(p, b); | 386 n = bytes.Copy(p, b); |
387 » *r = b[n:len(b)]; | 387 » *r = b[n:]; |
388 return; | 388 return; |
389 } | 389 } |
390 | 390 |
391 func (w *Window) readEvents() { | 391 func (w *Window) readEvents() { |
392 buf := make([]byte, maxEventBytes); | 392 buf := make([]byte, maxEventBytes); |
393 clean := false; | 393 clean := false; |
394 var ( | 394 var ( |
395 ea *activeEvent; | 395 ea *activeEvent; |
396 ee *exposeEvent; | 396 ee *exposeEvent; |
397 ke *keyboardEvent; | 397 ke *keyboardEvent; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 m.Y = int(mbe.Y); | 464 m.Y = int(mbe.Y); |
465 // TODO(rsc): Remove uint cast once 8g bug is fixed. | 465 // TODO(rsc): Remove uint cast once 8g bug is fixed. |
466 m.Buttons &^= 1 << uint(mbe.Button-1); | 466 m.Buttons &^= 1 << uint(mbe.Button-1); |
467 m.Nsec = time.Nanoseconds(); | 467 m.Nsec = time.Nanoseconds(); |
468 _ = w.mousec <- m; | 468 _ = w.mousec <- m; |
469 case eventQuit: | 469 case eventQuit: |
470 w.quitc <- true | 470 w.quitc <- true |
471 } | 471 } |
472 } | 472 } |
473 } | 473 } |
OLD | NEW |