我在 Arch Linux 上运行 VMWare Workstation,并将 KeePassX 设置为使用 ALT +“A”作为全局自动类型键绑定。
在运行 VMware 之前,KeePassX 运行良好。当 VMware 将键盘从来宾操作系统释放到主机时,“a”键完全停止工作(KeePassX gui 中和 VMware 中的来宾操作系统内部除外)。我向 xev 确认“a”键没有按应有的方式传递给 X,但似乎被另一个程序拦截(我猜测是 keepassx,因为它是“A”键工作的唯一应用程序)。
在主机上运行 $ showkey --keycodes 表明扫描码(0x1e 向下,0x9e 向上)仍在按预期生成。在第一次 VMware 键盘捕获之前,在主机上运行 xev 表明按键检测和映射正确(按“a”,然后按“shift + a”):
$ xev
KeyPress event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102283463, (137,56), root:(2626,74),
state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (61) "a"
XmbLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102283568, (137,56), root:(2626,74),
state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102286270, (137,56), root:(2626,74),
state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102286698, (137,56), root:(2626,74),
state 0x11, keycode 38 (keysym 0x41, A), same_screen YES,
XLookupString gives 1 bytes: (41) "A"
XmbLookupString gives 1 bytes: (41) "A"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102286826, (137,56), root:(2626,74),
state 0x11, keycode 38 (keysym 0x41, A), same_screen YES,
XLookupString gives 1 bytes: (41) "A"
XFilterEvent returns: False
第一次 VMware 键盘捕获后,xev 不再检测到“A”按键,而是生成以下输出(按“a”,然后按“shift + a”):
$ xev
FocusOut event, serial 37, synthetic NO, window 0x1600001,
mode NotifyGrab, detail NotifyAncestor
FocusOut event, serial 37, synthetic NO, window 0x1600001,
mode NotifyUngrab, detail NotifyPointer
FocusIn event, serial 37, synthetic NO, window 0x1600001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 37, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
KeyPress event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102369614, (6,122), root:(2495,140),
state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102370094, (6,122), root:(2495,140),
state 0x11, keycode 38 (keysym 0x41, A), same_screen YES,
XLookupString gives 1 bytes: (41) "A"
XmbLookupString gives 1 bytes: (41) "A"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x1600001,
root 0x292, subw 0x0, time 102370235, (6,122), root:(2495,140),
state 0x11, keycode 38 (keysym 0x41, A), same_screen YES,
XLookupString gives 1 bytes: (41) "A"
XFilterEvent returns: False
即使终止 VMware 服务后,问题仍然存在。通过注销/登录重新启动 X 会话可以纠正该问题。
我不确定是否要研究 VMware、KeePassX 还是我的桌面环境。