key: add ModCtrl, ModShortcut

ModCtrl is the physical Ctrl key, ModShortcut is the virtual
"shortcut" modifier, which is Ctrl on most platforms, Command on
Apple platforms.

Updates #59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-08 18:02:26 +01:00
parent 1eaa5dd15e
commit d293dfe604
6 changed files with 30 additions and 10 deletions
+1 -1
View File
@@ -281,7 +281,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
if n, ok := convertKeyCode(wParam); ok {
cmd := key.Event{Name: n}
if getKeyState(_VK_CONTROL)&0x1000 != 0 {
cmd.Modifiers |= key.ModCommand
cmd.Modifiers |= key.ModCtrl
}
if getKeyState(_VK_SHIFT)&0x1000 != 0 {
cmd.Modifiers |= key.ModShift
+3 -3
View File
@@ -232,7 +232,7 @@ func (h *x11EventHandler) handleEvents() bool {
// available but not CTRL-2.
state := kevt.state
mods := x11KeyStateToModifiers(state)
if mods.Contain(key.ModCommand) {
if mods.Contain(key.ModCtrl) {
kevt.state &^= (C.uint(C.ControlMask) | C.uint(C.ShiftMask))
}
l := int(C.Xutf8LookupString(w.xic, kevt,
@@ -261,7 +261,7 @@ func (h *x11EventHandler) handleEvents() bool {
w.w.Event(key.Event{Name: unicode.ToUpper(r), Modifiers: mods})
}
// Send EditEvent only when not a CTRL key combination.
if !mods.Contain(key.ModCommand) {
if !mods.Contain(key.ModCtrl) {
w.w.Event(key.EditEvent{Text: string(h.text[:l])})
}
}
@@ -335,7 +335,7 @@ func (h *x11EventHandler) handleEvents() bool {
func x11KeyStateToModifiers(s C.uint) key.Modifiers {
var m key.Modifiers
if s&C.ControlMask != 0 {
m |= key.ModCommand
m |= key.ModCtrl
}
if s&C.ShiftMask != 0 {
m |= key.ModShift
+1 -1
View File
@@ -124,7 +124,7 @@ func (x *Context) DispatchKey(keyCode uint32) (events []event.Event) {
if n, ok := convertKeysym(sym); ok {
cmd := key.Event{Name: n}
if C.xkb_state_mod_name_is_active(x.state, (*C.char)(unsafe.Pointer(&_XKB_MOD_NAME_CTRL[0])), C.XKB_STATE_MODS_EFFECTIVE) == 1 {
cmd.Modifiers |= key.ModCommand
cmd.Modifiers |= key.ModCtrl
}
if C.xkb_state_mod_name_is_active(x.state, (*C.char)(unsafe.Pointer(&_XKB_MOD_NAME_SHIFT[0])), C.XKB_STATE_MODS_EFFECTIVE) == 1 {
cmd.Modifiers |= key.ModShift