handleEvent processes given events.Event. All event processing operates under a RenderContext.Lock so that no rendering update can occur during event-driven updates. Because rendering itself is event driven, this extra level of safety is redundant in this case, but other non-event-driven updates req
(e events.Event)
| 424 | // is redundant in this case, but other non-event-driven updates require |
| 425 | // the lock protection. |
| 426 | func (w *renderWindow) handleEvent(e events.Event) { |
| 427 | rc := w.renderContext() |
| 428 | rc.lock() |
| 429 | // we manually handle Unlock's in this function instead of deferring |
| 430 | // it to avoid a cryptic "sync: can't unlock an already unlocked Mutex" |
| 431 | // error when panicking in the rendering goroutine. This is critical for |
| 432 | // debugging on Android. TODO: maybe figure out a more sustainable approach to this. |
| 433 | |
| 434 | et := e.Type() |
| 435 | if DebugSettings.EventTrace && et != events.WindowPaint && et != events.MouseMove { |
| 436 | fmt.Println("Window got event", e) |
| 437 | } |
| 438 | if et >= events.Window && et <= events.WindowPaint { |
| 439 | w.handleWindowEvents(e) |
| 440 | rc.unlock() |
| 441 | return |
| 442 | } |
| 443 | // fmt.Printf("got event type: %v: %v\n", et.BitIndexString(), evi) |
| 444 | w.mains.mainHandleEvent(e) |
| 445 | rc.unlock() |
| 446 | } |
| 447 | |
| 448 | func (w *renderWindow) handleWindowEvents(e events.Event) { |
| 449 | et := e.Type() |
no test coverage detected