Fix x/event.go

This commit is contained in:
Sasha Koshka 2024-09-12 02:06:16 -04:00
parent 55215dedc2
commit ee64650c19

View File

@ -7,6 +7,7 @@ import "github.com/jezek/xgb/xproto"
import "git.tebibyte.media/tomo/xgbkb" import "git.tebibyte.media/tomo/xgbkb"
import "github.com/jezek/xgbutil/xevent" import "github.com/jezek/xgbutil/xevent"
import "git.tebibyte.media/tomo/tomo/input" import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/config"
type scrollSum struct { type scrollSum struct {
x, y int x, y int
@ -226,7 +227,7 @@ func (window *window) handleKeyPress (
key, numberPad := keycodeToKey(keyEvent.Detail, keyEvent.State) key, numberPad := keycodeToKey(keyEvent.Detail, keyEvent.State)
window.updateModifiers(keyEvent.State) window.updateModifiers(keyEvent.State)
if key == input.KeyEscape && window.shy { if config.KeyChordClose.Pressed(key, window.Modifiers()) && window.shy {
window.Close() window.Close()
} else { } else {
window.hierarchy.HandleKeyDown(key, numberPad) window.hierarchy.HandleKeyDown(key, numberPad)
@ -433,14 +434,15 @@ func (window *window) compressMotionNotify (
func (window *window) updateModifiers (state uint16) { func (window *window) updateModifiers (state uint16) {
xModifiers := xgbkb.StateToModifiers(state) xModifiers := xgbkb.StateToModifiers(state)
window.hierarchy.HandleModifiers(input.Modifiers { var modifiers input.Modifiers
Shift: xModifiers.Shift || xModifiers.ShiftLock, if xModifiers.Shift { modifiers |= input.ModShift }
Control: xModifiers.Control, if xModifiers.ShiftLock { modifiers |= input.ModShift }
Alt: xModifiers.Alt, if xModifiers.Control { modifiers |= input.ModControl }
Meta: xModifiers.Meta, if xModifiers.Alt { modifiers |= input.ModAlt }
Super: xModifiers.Super, if xModifiers.Meta { modifiers |= input.ModMeta }
Hyper: xModifiers.Hyper, if xModifiers.Super { modifiers |= input.ModSuper }
}) if xModifiers.Hyper { modifiers |= input.ModHyper }
window.hierarchy.HandleModifiers(modifiers)
} }
func (window *window) updateMousePosition (x, y int16) { func (window *window) updateMousePosition (x, y int16) {