mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
gesture: only report TypePress for Click gestures if pointer is grabbed
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+17
-1
@@ -36,6 +36,8 @@ type Click struct {
|
|||||||
// clicks is incremented if successive clicks
|
// clicks is incremented if successive clicks
|
||||||
// are performed within a fixed duration.
|
// are performed within a fixed duration.
|
||||||
clicks int
|
clicks int
|
||||||
|
// pressRep tracks whether a TypePress has been reported.
|
||||||
|
pressRep bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClickState uint8
|
type ClickState uint8
|
||||||
@@ -140,6 +142,9 @@ func (c *Click) Events(q event.Queue) []ClickEvent {
|
|||||||
c.clicks = 1
|
c.clicks = 1
|
||||||
}
|
}
|
||||||
c.clickedAt = e.Time
|
c.clickedAt = e.Time
|
||||||
|
if c.reportPress(pointer.Grabbed) {
|
||||||
|
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers})
|
||||||
|
}
|
||||||
events = append(events, ClickEvent{Type: TypeClick, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers, NumClicks: c.clicks})
|
events = append(events, ClickEvent{Type: TypeClick, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers, NumClicks: c.clicks})
|
||||||
}
|
}
|
||||||
case pointer.Cancel:
|
case pointer.Cancel:
|
||||||
@@ -152,7 +157,10 @@ func (c *Click) Events(q event.Queue) []ClickEvent {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
c.state = StatePressed
|
c.state = StatePressed
|
||||||
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers})
|
c.pressRep = false
|
||||||
|
if c.reportPress(e.Priority) {
|
||||||
|
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers})
|
||||||
|
}
|
||||||
case pointer.Leave:
|
case pointer.Leave:
|
||||||
if c.state == StatePressed {
|
if c.state == StatePressed {
|
||||||
c.state = StateNormal
|
c.state = StateNormal
|
||||||
@@ -166,6 +174,14 @@ func (c *Click) Events(q event.Queue) []ClickEvent {
|
|||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Click) reportPress(pri pointer.Priority) bool {
|
||||||
|
send := !c.pressRep && pri == pointer.Grabbed
|
||||||
|
if send {
|
||||||
|
c.pressRep = true
|
||||||
|
}
|
||||||
|
return send
|
||||||
|
}
|
||||||
|
|
||||||
// Add the handler to the operation list to receive scroll events.
|
// Add the handler to the operation list to receive scroll events.
|
||||||
func (s *Scroll) Add(ops *op.Ops) {
|
func (s *Scroll) Add(ops *op.Ops) {
|
||||||
oph := pointer.InputOp{Key: s, Grab: s.grab}
|
oph := pointer.InputOp{Key: s, Grab: s.grab}
|
||||||
|
|||||||
Reference in New Issue
Block a user