setxkbmap -option ctrl:nocaps 不会将 Caps Lock 映射到在 macOS 上的 Oracle VirtualBox 中运行的 Debian VM 内的 Escape

setxkbmap -option ctrl:nocaps 不会将 Caps Lock 映射到在 macOS 上的 Oracle VirtualBox 中运行的 Debian VM 内的 Escape

我在 Debian 10 上使用 Xfce 4.12,在 macOS Catalina 上运行的 Oracle VirtualBox 6.1 中运行。

我的所有按键映射在 macOS 上都设置为默认值。 (系统偏好设置 > 键盘 > 修饰键 > 恢复默认值 > 确定。)

转义上限效果很好

在 Debian VM 中,我运行:

$ setxkbmap -option
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us

$ setxkbmap -option caps:escape
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    caps:escape

现在,大写锁定的行为类似于 Debian VM 中的转义,而大写锁定的行为类似于 macOS 系统上的大写锁定。这按预期工作。

这是xev我按下大写锁定键后的输出setxkbmap -option

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 128721870, (-31,207), root:(560,530),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 128721874, (-31,207), root:(560,530),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

这是xev我按下大写锁定键后的输出setxkbmap -option caps:escape

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 128844487, (163,5), root:(754,328),
    state 0x0, keycode 66 (keysym 0xff1b, Escape), same_screen YES,
    XKeysymToKeycode returns keycode: 9
    XLookupString gives 1 bytes: (1b) "
mbLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 128844489, (163,5), root:(754,328),
    state 0x0, keycode 66 (keysym 0xff1b, Escape), same_screen YES,
    XKeysymToKeycode returns keycode: 9
    XLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

控制上限不起作用

在 Debian VM 中,我运行:

$ setxkbmap -option
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us

$ setxkbmap -option ctrl:nocaps
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    ctrl:nocaps

现在 Caps Lock 的行为与 Debian VM 中的 Ctrl 修饰符不同。

这是xev我按下大写锁定键后的输出setxkbmap -option

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 129089370, (163,1), root:(754,324),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 129089373, (163,1), root:(754,324),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

这是xev我按下大写锁定键后的输出setxkbmap -option ctrl:nocaps

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 129117033, (163,5), root:(754,328),
    state 0x2, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 129117037, (163,5), root:(754,328),
    state 0x6, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

什么地方出了错?

关于这个问题的更多 xev 输出。

如果您按照下面的评论部分进行操作,您会发现到目前为止我已经确定,在运行后setxkbmap -option ctrl:nocapscaps lock+c键入字母c,但ctrl+c的行为正确(例如:取消 bash 中的当前命令)。

ctrl这是+的 xev 输出c

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176921083, (165,3), root:(756,326),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176921220, (165,3), root:(756,326),
    state 0x4, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (03) ""
    XmbLookupString gives 1 bytes: (03) ""
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176921334, (165,3), root:(756,326),
    state 0x4, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (03) ""
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176921336, (165,3), root:(756,326),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

caps lock这是+的输出c

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176819139, (165,5), root:(756,328),
    state 0x0, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176819141, (165,5), root:(756,328),
    state 0x4, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176819251, (165,5), root:(756,328),
    state 0x0, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (63) "c"
    XmbLookupString gives 1 bytes: (63) "c"
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0x3ac, subw 0x0, time 176819371, (165,5), root:(756,328),
    state 0x0, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (63) "c"
    XFilterEvent returns: False

这里的问题似乎是原始的ctrl+c按正确的顺序发送正确的按键事件:

  • ctrl
  • c
  • c发布
  • ctrl发布)

但是caps lock+c组合以错误的顺序发送关键事件:

  • ctrl
  • ctrl发布
  • c
  • c发布

我怎样才能解决这个问题?

相关内容