mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
io/router: don't trigger redraw for handler reset events
key.InputOp and pointer.InputOp handlers are reset on first registration
through a key.FocusEvent{false} or pointer.Cancel, respectively.
However, the mere act of registering a handle shouldn't result in a
redraw. This is particularly true for misconfigured handlers where a new
tag is supplied every frame, resulting in continously redrawing.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+6
-1
@@ -79,6 +79,7 @@ func (q *Router) Frame(ops *op.Ops) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add an event and report whether at least one handler had an event queued.
|
||||
func (q *Router) Add(events ...event.Event) bool {
|
||||
for _, e := range events {
|
||||
switch e := e.(type) {
|
||||
@@ -159,9 +160,13 @@ func (h *handlerEvents) init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *handlerEvents) Add(k event.Tag, e event.Event) {
|
||||
func (h *handlerEvents) AddNoRedraw(k event.Tag, e event.Event) {
|
||||
h.init()
|
||||
h.handlers[k] = append(h.handlers[k], e)
|
||||
}
|
||||
|
||||
func (h *handlerEvents) Add(k event.Tag, e event.Event) {
|
||||
h.AddNoRedraw(k, e)
|
||||
h.hadEvents = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user