键盘快捷键偶尔会停止工作

键盘快捷键偶尔会停止工作

编辑:从答案可以看出,这实际上与待机或休眠无关,而是与我经常在进入待机状态之前关闭应用程序窗口(这会触发错误)有关。

我看到网上多个地方有多人报告了这个问题,但都没有任何解决方案,但无论如何我还是想添加我的解决方案:

很多时候,在一段时间后返回计算机(当计算机进入待机状态时),我注意到一些快捷方式已停止工作。这确实不仅发生在终端中,也发生在 Chrome 中(Ctrl-L、Ctrl-R、F5 均停止工作)。它也不会影响所有 ctrl 快捷键:例如 Ctrl-C 仍然有效(感谢上帝!)。

有什么方法可以调试这个问题吗?之前尝试过的方法xev没有成功,但也许有办法找出是什么原因阻止我的按键到达程序?

编辑:我发现使用 Ctrl-R 时会发生一些奇怪的事情

有东西正在抓取键盘快捷键!

输出捕获自xev

KeyPress event, serial 37, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 24547557, (-130,529), root:(0,633),
    state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 37, synthetic NO, window 0x5200001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 37, synthetic NO, window 0x5200001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 37, synthetic NO, window 0x0,
    keys:  4294967278 0   0   0   0   0   0   0   0   0   0   0   0   2   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 37, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 24548550, (-130,529), root:(0,633),
    state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

与 Ctrl-C 比较

我们可以很容易地看到这里发生了四个合乎逻辑的事件

KeyPress event, serial 37, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 24724066, (572,852), root:(702,956),
    state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 24724818, (572,852), root:(702,956),
    state 0x14, 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 0x5200001,
    root 0xee, subw 0x0, time 24724966, (572,852), root:(702,956),
    state 0x14, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (03) ""
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 24725339, (572,852), root:(702,956),
    state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

答案1

我设法找到了最不可能的罪魁祸首:Caprine Messenger 应用程序。!使用 Electron 框架(Spotify、Atom、VS Code)制作的许多其他应用程序也可能会发生这种情况,直到快捷方式库中的错误是固定的。

我现在知道如何持续重现这个错误在阅读电子问题跟踪器上的错误报告后:只需关闭应用程序,使其驻留在系统托盘中。但在我到达那里之前,我设法找到了确凿的证据,证明是 Caprine 捕获了快捷方式,并且将其关闭可以解决问题。这就是我发现的方法(可用于类似情况):

A对这个问题的重复回答有些不透明解释说,可以通过发出一些神奇的按键来检测哪个应用程序正在抓取按键。起初我不太明白如何设置这一切,以为我必须经历各种各样的麻烦(弄乱 Xorg 配置、禁用 vty 切换、++)来设置一个特殊的键映射配置,直到我突然意识到答案实际上还描述了如何以编程方式触发这些组合键!

因此我需要做的就是打开两个终端窗口。在第一个终端窗口中,我开始在 Xorg 系统中记录事件:

tail -f /var/log/Xorg.0.log > out.txt

在另一个窗口中,我触发了向 Xorg 系统发出组合键的事件:

KEY="ctrl+r"                  # the combination that was "grabbed"
xdotool keydown ${KEY};       # start pressing the key combo
xdotool key XF86LogGrabInfo;  # the keysym that when emitted asks X to print info on the grabber of the current keys
xdotool keyup ${KEY}          # stop pressing the key combo

这样做以编程方式这样做比像手指章鱼一样手动做要容易得多:-) 在另一个窗口捕获的事件日志(13'000 行!)中,有趣的部分在前几行中显而易见:

[ 24264.517]     detail 71 (mask 0), modifiersDetail 128 (mask 0)
[ 24264.517]     device 'Virtual core keyboard' (3), modifierDevice 'Virtual core keyboard' (3)
[ 24264.517]     core event mask 0x3
[ 24264.517]     owner-events false, kb 1 ptr 1, confine 0x0, cursor 0x0
[ 24264.517]   Printing all registered grabs of client pid 5643 /opt/Caprine/caprine --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,23,59,71 --gpu-vendor-id=0x8086 --gpu-device-id=0x5916 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --service-request-channel-token=B68A5099B5760C39675F51019B3D4F7A --v8-natives-passed-by-fd --v8-snapshot-passed-by-f 
[ 24264.517]   Printing all registered grabs of client pid 5643 /opt/Caprine/caprine --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,23,59,71 --gpu-vendor-id=0x8086 --gpu-device-id=0x5916 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --service-request-channel-token=B68A5099B5760C39675F51019B3D4F7A --v8-natives-passed-by-fd --v8-snapshot-passed-by-f 
[ 24264.517]   Printing all registered grabs of client pid 5684 /usr/lib/slack/slack --disable-gp 
[ 24264.517]   Printing all registered grabs of client pid 5684 /usr/lib/slack/slack --disable-gp 
[ 24264.517]   Printing all registered grabs of client pid 18336 xdotool key XF86LogGrabInfo
[ 24264.517] End list of registered passive grabs
[ 24308.177] (II) Printing all currently active device grabs:
[ 24308.177] Active grab 0x44800160 (core) on device 'Virtual core keyboard' (3):
[ 24308.177]       client pid 5614 /opt/Caprine/caprine 
[ 24308.177]       at 24308139 (from passive grab) (device thawed, state 1)
[ 24308.177]         core event mask 0x3
[ 24308.177]       passive grab type 2, detail 0x1b, activating key 27
[ 24308.177]       owner-events false, kb 1 ptr 1, confine 0, cursor 0x0
[ 24308.177] (II) End list of active device grabs

在终止 Caprine 之后,我终于可以再次在终端中使用 Ctrl-R 进行反向历史搜索,以及刷新 Chrome!xev输出的内容也与我在问题中详述的内容完全不同,现在与 Ctrl-L 的输出非常相似:

KeyPress event, serial 39, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 25356738, (917,877), root:(1047,981),
    state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 39, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 25357181, (917,877), root:(1047,981),
    state 0x14, keycode 27 (keysym 0x72, r), same_screen YES,
    XLookupString gives 1 bytes: (12) ""
    XmbLookupString gives 1 bytes: (12) ""
    XFilterEvent returns: False

KeyRelease event, serial 39, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 25357315, (917,877), root:(1047,981),
    state 0x14, keycode 27 (keysym 0x72, r), same_screen YES,
    XLookupString gives 1 bytes: (12) ""
    XFilterEvent returns: False

KeyRelease event, serial 39, synthetic NO, window 0x5200001,
    root 0xee, subw 0x0, time 25357710, (917,877), root:(1047,981),
    state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

编辑:结果该错误已知

该错误问题还显示了如何一致地重现此问题(最小化)。这是由electron-localshortcut图书馆。


做了一个小工具以编程方式轻松发送这些快捷方式。

相关内容