问题
我在我的应用程序中使用xdotool keydown Control
andxdotool keyup Control
来模拟 Ctrl 按下。当布局设置为 时us
,一切正常,但当布局更改为其他内容(fr
或ru
)时,应用程序将停止看到 ctrl 事件。
问题
为什么会这样?我该怎么做才能使 ctrl 键操作在布局中统一工作?
一些信息
我用来设置布局的命令:
setxkbmap -layout us,fr -option -option "grp:lctrl_lshift_toggle,ctrl:nocaps"
us
带有布局的 xev 输出:
KeyPress event, serial 25, synthetic NO, window 0x4a00001,
root 0x5c, subw 0x0, time 11278564, (317,709), root:(1279,736),
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x4a00001,
root 0x5c, subw 0x0, time 11278676, (317,709), root:(1279,736),
state 0x14, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
fr
带有布局的 xev 输出:
KeyPress event, serial 109, synthetic NO, window 0x4a00001,
root 0x5c, subw 0x0, time 11343218, (312,520), root:(1274,547),
state 0x2010, keycode 8 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 109, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 116, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
KeyRelease event, serial 123, synthetic NO, window 0x4a00001,
root 0x5c, subw 0x0, time 11343460, (312,520), root:(1274,547),
state 0x2010, keycode 8 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
MappingNotify event, serial 123, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 1
setxkbmap 的详细输出:
Setting verbose level to 10
locale is C
Applied rules from evdev:
rules: evdev
model: pc105
layout: us,fr
options: grp:lctrl_lshift_toggle,ctrl:nocaps
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+fr:2+inet(evdev)+group(lctrl_lshift_toggle)+ctrl(nocaps)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+fr:2+inet(evdev)+group(lctrl_lshift_toggle)+ctrl(nocaps)" };
xkb_geometry { include "pc(pc105)" };
};
用于控制的 xmodmap 输出:
$ xmodmap -pme | grep -i control
control Control_L (0x25), Control_L (0x42), Control_R (0x69)
$ xmodmap -pke | grep -i control
keycode 37 = Control_L Control_L Control_L Control_L
keycode 66 = Control_L Control_L Control_L Control_L
keycode 105 = Control_R NoSymbol Control_R