从Mac到Centos 6使用VNC时如何设置Meta key?

从Mac到Centos 6使用VNC时如何设置Meta key?

我在 Centos 6.9 机器上运行 emacs 26.1,通过 TightVNC 服务器向在 Mac OS X 10.14.2 上运行的客户端显示。为了让事情变得棘手,我还使用了德沃夏克键盘布局。

当我在 Mac 上运行 emacs 时,一切都运行良好。我的 Mac 键盘是Apple Magic Keyboard with Numeric Keypad (Wireless, Rechargable) (US English) - Silver.如果我option按左侧或右侧的 ,它就会按预期工作并meta在 Emacs 中生成。如果我command按左侧或右侧的 ,它也会按需要工作并且也会meta在 Emacs 中生成。我相信这是通过以下方法完成的(这并不能解决我在 Linux 上的问题):

  (setq mac-option-modifier  'meta)
  (setq mac-command-modifier 'meta)

现在,我尝试通过 TigerVNC 从 Mac 连接到也运行 Emacs 的 Linux 计算机。在 Centos 6.9 机器上,我必须禁用 Dvorok 键盘布局首选项,因为它会扰乱 Mac 键盘的输入,我认为执行转换两次,一次在我的 Mac 上,第二次在 Linux 机器上。

但是,修饰键无法按预期工作。以下是我尝试以M-x各种方式生成时得到的结果:

  • 左选项-x => 不正确:
  • 左命令-x => 正确:M-x
  • 右选项-x => 不正确:
  • 右命令-x => 错误:s-x

我跑了xmodmap -pm

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

我跑过去xev看到以下内容:

左选项:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19839468, (104,80), root:(106,131),
    state 0x0, keycode 203 (keysym 0xff7e, Mode_switch), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 38, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 19839468, state PropertyNewValue

PropertyNotify event, serial 38, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 19839468, state PropertyNewValue

左命令:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19937256, (103,75), root:(105,126),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

右选项:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19987161, (132,152), root:(134,203),
    state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: (1b) ""
    XmbLookupString gives 1 bytes: (1b) ""
    XFilterEvent returns: False

右键命令:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20026188, (93,166), root:(95,217),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

因此,我尝试了以下操作xmodmap

! Map the right Macintosh Command key to Meta:
remove mod4 = Super_L
add mod1 = Super_L

! Map the left Macintosh Option key to Meta:
remove mod5 = Mode_switch
add mod1 = Mode_switch

! Map the right Macintosh Option key to Meta:
remove mod5 = ISO_Level3_Shift
add mod1 = ISO_Level3_Shift

通过以下方式导致此状态xmodmap -pm

xmodmap:  up to 7 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  ISO_Level3_Shift (0x5c),  Alt_R (0x6c),  Super_L (0x85),  Mode_switch (0xcb),  Meta_L (0xcd),  Super_L (0xce)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_R (0x86),  Hyper_L (0xcf)
mod5      

但这表现得很糟糕:

  • 左选项-x => 不正确:
  • 左命令-x => 错误:M-b
  • 右选项-x => 不正确:M-≈
  • 右命令-x => 错误:M-b

请注意,Dvorak 上的“x”键对应于 Qwerty 上的“b”键。

使用xev我现在得到:

左选项:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20512286, (121,123), root:(123,174),
    state 0x0, keycode 203 (keysym 0xff7e, Mode_switch), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 40, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 20512286, state PropertyNewValue

PropertyNotify event, serial 40, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 20512288, state PropertyNewValue

左命令:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20568312, (140,155), root:(142,206),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

右选项:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20606634, (88,106), root:(90,157),
    state 0x0, keycode 92 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

右键命令:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20656211, (126,127), root:(128,178),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

因此,我不清楚如何解决此问题并获得两个选项和两个命令键的所需行为,就像meta在带有 Dvorak 键盘的 Emacs 中一样。

相关内容