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