io/router: expose the event router

For integrating with external window implementations (replacing
package app), access to the event router is required. Extract it
and put it into the new package router.

Router may belong in package io/event, but can't without introducing
import cycles.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-07 20:41:04 +01:00
parent 6e98132ebb
commit 34c6a2f735
4 changed files with 27 additions and 9 deletions
+4 -4
View File
@@ -8,10 +8,10 @@ import (
"image"
"time"
"gioui.org/app/internal/input"
"gioui.org/app/internal/window"
"gioui.org/io/event"
"gioui.org/io/profile"
"gioui.org/io/router"
"gioui.org/io/system"
"gioui.org/op"
"gioui.org/unit"
@@ -56,7 +56,7 @@ type callbacks struct {
// Queue is an event.Queue implementation that distributes system events
// to the input handlers declared in the most recent frame.
type Queue struct {
q input.Router
q router.Router
}
// driverEvent is sent when a new native driver
@@ -128,9 +128,9 @@ func (w *Window) draw(frameStart time.Time, size image.Point, frame *op.Ops) {
sync := w.loop.Draw(size, frame)
w.queue.q.Frame(frame)
switch w.queue.q.TextInputState() {
case input.TextInputOpen:
case router.TextInputOpen:
w.driver.ShowTextInput(true)
case input.TextInputClose:
case router.TextInputClose:
w.driver.ShowTextInput(false)
}
if w.queue.q.Profiling() {