mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
io/input: implement key.Filter.Name special case for matching every key
The empty key.Filter.Name now means matching every key name. This is a replacement for the previous special case where the top-level key.InputOp handler would get all unmatched events. Add special case for system events such as focus switch shortcuts. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-4
@@ -250,20 +250,20 @@ func (q *keyQueue) AreaFor(k *keyHandler) int {
|
||||
return q.dirOrder[order].area
|
||||
}
|
||||
|
||||
func (k *keyFilter) Matches(focus event.Tag, e key.Event) bool {
|
||||
func (k *keyFilter) Matches(focus event.Tag, e key.Event, system bool) bool {
|
||||
for _, f := range *k {
|
||||
if keyFilterMatch(focus, f, e) {
|
||||
if keyFilterMatch(focus, f, e, system) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func keyFilterMatch(focus event.Tag, f key.Filter, e key.Event) bool {
|
||||
func keyFilterMatch(focus event.Tag, f key.Filter, e key.Event, system bool) bool {
|
||||
if f.Focus != nil && f.Focus != focus {
|
||||
return false
|
||||
}
|
||||
if f.Name != e.Name {
|
||||
if (f.Name != "" || system) && f.Name != e.Name {
|
||||
return false
|
||||
}
|
||||
if e.Modifiers&f.Required != f.Required {
|
||||
|
||||
Reference in New Issue
Block a user