fix: restore grab-resilient X11 shortcuts - #127
Conversation
Restore the legacy X RECORD path for screenshot, screen recorder, and standalone modifier shortcuts while another X11 client owns an active keyboard grab. Keep passive XGrabKey and XI2 fallback paths available, isolate RECORD lifecycle and keymap connections, and deduplicate XCB/RECORD events. Add policy, RECORD lifecycle, fallback, active-grab, and parallel test coverage. 恢复旧版 X RECORD 路径,使截图、录屏和独立修饰键快捷键在其他 X11 客户端持有主动键盘 grab 时仍可使用。 保留被动 XGrabKey 和 XI2 回退路径,隔离 RECORD 生命周期与键盘映射连接,并对 XCB/RECORD 事件去重。 增加策略、RECORD 生命周期、回退、主动 grab 和并行测试覆盖。 Log: restore grab-resilient X11 shortcuts Pms: BUG-372643 Change-Id: I9498c98fe60a953447beedda08e4e916ac493247
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideRestores X RECORD-based grab-resilient X11 shortcut handling with a dual-transport (RECORD/XI2) modifier monitor, integrates it with X11KeyHandler to avoid duplicate activations across RECORD and XCB streams, adds explicit policy for legacy grab-resilient shortcuts, and introduces targeted X11 integration and unit tests plus build dependencies for RECORD/XTest. Sequence diagram for grab-resilient shortcut activation via X RECORDsequenceDiagram
participant X11Server
participant ModifierKeyMonitor
participant X11KeyHandler
participant X11ShortcutPolicy
X11KeyHandler->>ModifierKeyMonitor: ModifierKeyMonitor(parent, allowRecord=true)
ModifierKeyMonitor->>ModifierKeyMonitor: initializeRecord()
alt RECORD available
ModifierKeyMonitor->>ModifierKeyMonitor: m_transport = Record
else RECORD unavailable
ModifierKeyMonitor->>ModifierKeyMonitor: fallbackToXInput2()
end
X11KeyHandler->>X11ShortcutPolicy: isLegacyGrabResilientShortcut(shortcutId)
X11ShortcutPolicy-->>X11KeyHandler: true
X11KeyHandler->>X11KeyHandler: m_recordShortcutIds.insert(shortcutId)
X11Server-->>ModifierKeyMonitor: RECORD key event
ModifierKeyMonitor-->>X11KeyHandler: keyEventRecorded(pressed, keycode, state, time)
X11KeyHandler->>X11KeyHandler: onRecordedKeyEvent(pressed=true,...)
alt shortcutId in m_recordShortcutIds
X11KeyHandler->>X11KeyHandler: m_recordPressedBindings.insert(keycode, shortcutId)
X11KeyHandler->>X11KeyHandler: activate(shortcutId, Press)
else non-legacy or claimed by XCB
X11KeyHandler-->>X11KeyHandler: ignore to avoid duplicate
end
X11Server-->>X11KeyHandler: XCB KeyPress
X11KeyHandler->>X11KeyHandler: handleKeyPress()
alt key already in m_recordPressedBindings or m_recordObservedPresses
X11KeyHandler-->>X11KeyHandler: ignore XCB event
else
X11KeyHandler->>X11KeyHandler: activate(shortcutId, Press)
end
X11Server-->>ModifierKeyMonitor: RECORD KeyRelease
ModifierKeyMonitor-->>X11KeyHandler: keyEventRecorded(pressed=false,...)
X11KeyHandler->>X11KeyHandler: onRecordedKeyEvent(pressed=false,...)
X11KeyHandler->>X11KeyHandler: flushRecordedPendingReleases()
X11KeyHandler->>X11KeyHandler: activate(shortcutId, Release)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:98分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // modifierkeymonitor.cpp:在 initializeRecord 失败路径增加明确的所有权交接注释
bool ModifierKeyMonitor::initializeRecord()
{
m_controlDisplay = XOpenDisplay(nullptr);
if (!m_controlDisplay) {
qCWarning(logShortcut) << "ModifierMonitor: failed to connect to X server for RECORD";
return false;
}
int major = 0;
int minor = 0;
if (!XRecordQueryVersion(m_controlDisplay, &major, &minor)) {
qCWarning(logShortcut) << "ModifierMonitor: X RECORD extension is unavailable";
// Resource ownership of m_controlDisplay is transferred to and cleaned up by cleanupRecordResources()
return false;
}
m_keyConnection = xcb_connect(nullptr, nullptr);
if (!m_keyConnection || xcb_connection_has_error(m_keyConnection)) {
qCWarning(logShortcut) << "ModifierMonitor: failed to open keymap connection";
// Resource ownership of m_controlDisplay is transferred to and cleaned up by cleanupRecordResources()
return false;
}
m_keySymbols = xcb_key_symbols_alloc(m_keyConnection);
if (!m_keySymbols) {
qCWarning(logShortcut) << "ModifierMonitor: failed to initialize RECORD key symbols";
return false;
}
if (!createContext())
return false;
qCInfo(logShortcut) << "ModifierMonitor: X RECORD" << major << minor << "available";
return true;
} |
Summary
Test plan
-j9: passed 5 consecutive runsDISPLAY=:0 dpkg-buildpackage -b -us -uc: passedPms: BUG-372643
Summary by Sourcery
Restore grab-resilient X11 shortcut handling while keeping XInput2 as a fallback path and preventing duplicate activations across event streams.
Bug Fixes:
Enhancements:
Build:
Tests: