Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wr5537 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 |
|
TAG Bot TAG: 2.0.52.1 |
|
Hi @wr5537. Thanks for your PR. 😃 |
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
Hi @wr5537. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
The dxcb platform plugin creates override-redirect popup windows with an event mask that only selects property/visibility/substructure notification. Keyboard events are delivered per-client based on the event mask each client selected, so without KeyPressMask/KeyReleaseMask/FocusChangeMask no key event ever reaches Qt - while mouse events (delivered through XInput2) keep working. This silently breaks text input in popup windows of the process, e.g. the launcher search box. Install a native event filter on QCoreApplication startup which restores the keyboard/focus masks through Qt's own xcb connection whenever one of our top-level windows gets mapped, configured or focused. Event masks are per-client, so only Qt's own event delivery is affected.
c1ef458 to
f9a417a
Compare
Reviewer's GuideImplementationAdd a native X11 event filter that restores keyboard and focus event masks on Qt top-level windows, fixing text input in popup windows.
ConfigurationAdd the X11 key-mask fixer source and header to the CMake source list so they are built with the application.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 6 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="CMakeLists.txt" line_range="77" />
<code_context>
launchercontroller.cpp launchercontroller.h
debughelper.cpp debughelper.h
inputeventitem.h inputeventitem.cpp
+ x11keymaskfixer.h x11keymaskfixer.cpp
)
</code_context>
<issue_to_address>
**Launcher fails to load**
When the build or runtime does not supply libxcb transitively, `launchpadcommon` uses XCB symbols without linking XCB, so strict undefined-symbol checks fail or the loader cannot resolve the symbols and the launcher applet fails to load.
Declare and link the XCB dependency for `launchpadcommon`.
Also at `x11keymaskfixer.cpp:10`, `x11keymaskfixer.cpp:36`, `x11keymaskfixer.cpp:59`.
</issue_to_address>
### Comment 2
<location path="x11keymaskfixer.cpp" line_range="99" />
<code_context>
+ X11KeyMaskFixer::install();
+}
+
+Q_COREAPP_STARTUP_FUNCTION(installX11KeyMaskFixer)
</code_context>
<issue_to_address>
**Launcher input stays broken**
When the shell loads the launcher applet after constructing its `QCoreApplication`, `Q_COREAPP_STARTUP_FUNCTION` has already run, so `X11KeyMaskFixer::install()` is never called and no native event filter repairs the popup masks; launcher search input remains broken.
Install the filter when the applet loads, including when the application object already exists.
</issue_to_address>
### Comment 3
<location path="x11keymaskfixer.cpp" line_range="51" />
<code_context>
+
+ // OR in the missing masks, keeping whatever this client already selected.
+ const uint32_t newMask = mask | keyboardMask
+ | XCB_EVENT_MASK_BUTTON_PRESS
+ | XCB_EVENT_MASK_BUTTON_RELEASE
+ | XCB_EVENT_MASK_BUTTON_MOTION
</code_context>
<issue_to_address>
**Keyboard masks remain unset**
When another X11 client has already selected button-press events on the popup window, `xcb_change_window_attributes` requests the exclusive `ButtonPress` mask with the keyboard masks, so the server rejects the whole request with `BadAccess` and text input remains broken.
Do not request the exclusive `ButtonPress` mask in the same change as the keyboard masks.
</issue_to_address>
### Comment 4
<location path="x11keymaskfixer.cpp" line_range="69-82" />
<code_context>
+
+ auto *event = static_cast<xcb_generic_event_t *>(message);
+ xcb_window_t windowId = 0;
+ switch (event->response_type & 0x7f) {
+ case XCB_MAP_NOTIFY:
+ windowId = reinterpret_cast<xcb_map_notify_event_t *>(event)->window;
+ break;
+ case XCB_CONFIGURE_NOTIFY:
+ windowId = reinterpret_cast<xcb_configure_notify_event_t *>(event)->window;
+ break;
+ case XCB_FOCUS_IN:
+ case XCB_FOCUS_OUT:
+ windowId = reinterpret_cast<xcb_focus_in_event_t *>(event)->event;
+ break;
+ default:
+ return false;
+ }
+
+ const auto windows = QGuiApplication::topLevelWindows();
</code_context>
<issue_to_address>
**Repair can never be triggered**
When a popup's parent has not selected `SubstructureNotify` for it and the popup itself lacks `StructureNotify`, the filter relies on `MapNotify` or `ConfigureNotify` to discover the window, but those events require `StructureNotify` on that window or `SubstructureNotify` on its parent. The repair adds neither guarantee; if the parent is not subscribed, no callback reaches `fixWindow` and keyboard input remains broken.
Ensure the fixer is called from a window lifecycle hook, or otherwise subscribe to a notification that is guaranteed to arrive before relying on these events to repair the mask.
Also at `x11keymaskfixer.cpp:50-58`.
</issue_to_address>
### Comment 5
<location path="x11keymaskfixer.cpp" line_range="70" />
<code_context>
+ auto *event = static_cast<xcb_generic_event_t *>(message);
+ xcb_window_t windowId = 0;
+ switch (event->response_type & 0x7f) {
+ case XCB_MAP_NOTIFY:
+ windowId = reinterpret_cast<xcb_map_notify_event_t *>(event)->window;
+ break;
</code_context>
<issue_to_address>
**First keystroke can be lost**
When the user types before the server processes the mask update after mapping the popup, `nativeEventFilter` repairs the window only after receiving `MapNotify`; until `fixWindow` sends and flushes the mask change, the X server still drops keyboard events for that window. A key pressed in that interval is lost, so the first character typed into the search box disappears.
Apply the keyboard masks before mapping or activating the window, or otherwise preserve input received before the repair completes.
</issue_to_address>
### Comment 6
<location path="x11keymaskfixer.cpp" line_range="87" />
<code_context>
+ const auto windows = QGuiApplication::topLevelWindows();
+ for (QWindow *window : windows) {
+ if (window->isVisible() && window->winId() == windowId) {
+ fixWindow(window);
+ break;
+ }
</code_context>
<issue_to_address>
**Window resizing blocks on X server**
When a visible top-level window generates repeated configure events, such as during interactive resizing, `nativeEventFilter` calls `fixWindow` for every matching configure event, and `fixWindow` synchronously waits for `xcb_get_window_attributes_reply` even after the keyboard masks have already been repaired. Repeated resize or move events therefore block the GUI thread on X-server round trips, making the window stutter.
Avoid a synchronous attributes round trip for every configure event, for example by tracking repaired windows or using an asynchronous query.
</issue_to_address>| launchercontroller.cpp launchercontroller.h | ||
| debughelper.cpp debughelper.h | ||
| inputeventitem.h inputeventitem.cpp | ||
| x11keymaskfixer.h x11keymaskfixer.cpp |
There was a problem hiding this comment.
🟠 High · Launcher fails to load
When the build or runtime does not supply libxcb transitively, launchpadcommon uses XCB symbols without linking XCB, so strict undefined-symbol checks fail or the loader cannot resolve the symbols and the launcher applet fails to load.
Declare and link the XCB dependency for launchpadcommon.
Also at x11keymaskfixer.cpp:10, x11keymaskfixer.cpp:36, x11keymaskfixer.cpp:59.
Prompt for AI agents
In `CMakeLists.txt` at line 77:
**Launcher fails to load**
When the build or runtime does not supply libxcb transitively, `launchpadcommon` uses XCB symbols without linking XCB, so strict undefined-symbol checks fail or the loader cannot resolve the symbols and the launcher applet fails to load.
Declare and link the XCB dependency for `launchpadcommon`.
Also at `x11keymaskfixer.cpp:10`, `x11keymaskfixer.cpp:36`, `x11keymaskfixer.cpp:59`.| X11KeyMaskFixer::install(); | ||
| } | ||
|
|
||
| Q_COREAPP_STARTUP_FUNCTION(installX11KeyMaskFixer) |
There was a problem hiding this comment.
🟠 High · Launcher input stays broken
When the shell loads the launcher applet after constructing its QCoreApplication, Q_COREAPP_STARTUP_FUNCTION has already run, so X11KeyMaskFixer::install() is never called and no native event filter repairs the popup masks; launcher search input remains broken.
Install the filter when the applet loads, including when the application object already exists.
Prompt for AI agents
In `x11keymaskfixer.cpp` at line 99:
**Launcher input stays broken**
When the shell loads the launcher applet after constructing its `QCoreApplication`, `Q_COREAPP_STARTUP_FUNCTION` has already run, so `X11KeyMaskFixer::install()` is never called and no native event filter repairs the popup masks; launcher search input remains broken.
Install the filter when the applet loads, including when the application object already exists.|
|
||
| // OR in the missing masks, keeping whatever this client already selected. | ||
| const uint32_t newMask = mask | keyboardMask | ||
| | XCB_EVENT_MASK_BUTTON_PRESS |
There was a problem hiding this comment.
🟡 Medium · Keyboard masks remain unset
When another X11 client has already selected button-press events on the popup window, xcb_change_window_attributes requests the exclusive ButtonPress mask with the keyboard masks, so the server rejects the whole request with BadAccess and text input remains broken.
Do not request the exclusive ButtonPress mask in the same change as the keyboard masks.
Prompt for AI agents
In `x11keymaskfixer.cpp` at line 51:
**Keyboard masks remain unset**
When another X11 client has already selected button-press events on the popup window, `xcb_change_window_attributes` requests the exclusive `ButtonPress` mask with the keyboard masks, so the server rejects the whole request with `BadAccess` and text input remains broken.
Do not request the exclusive `ButtonPress` mask in the same change as the keyboard masks.| switch (event->response_type & 0x7f) { | ||
| case XCB_MAP_NOTIFY: | ||
| windowId = reinterpret_cast<xcb_map_notify_event_t *>(event)->window; | ||
| break; | ||
| case XCB_CONFIGURE_NOTIFY: | ||
| windowId = reinterpret_cast<xcb_configure_notify_event_t *>(event)->window; | ||
| break; | ||
| case XCB_FOCUS_IN: | ||
| case XCB_FOCUS_OUT: | ||
| windowId = reinterpret_cast<xcb_focus_in_event_t *>(event)->event; | ||
| break; | ||
| default: | ||
| return false; | ||
| } |
There was a problem hiding this comment.
🟠 High · Repair can never be triggered
When a popup's parent has not selected SubstructureNotify for it and the popup itself lacks StructureNotify, the filter relies on MapNotify or ConfigureNotify to discover the window, but those events require StructureNotify on that window or SubstructureNotify on its parent. The repair adds neither guarantee; if the parent is not subscribed, no callback reaches fixWindow and keyboard input remains broken.
Ensure the fixer is called from a window lifecycle hook, or otherwise subscribe to a notification that is guaranteed to arrive before relying on these events to repair the mask.
Also at x11keymaskfixer.cpp:50-58.
Prompt for AI agents
In `x11keymaskfixer.cpp` at lines 69-82:
**Repair can never be triggered**
When a popup's parent has not selected `SubstructureNotify` for it and the popup itself lacks `StructureNotify`, the filter relies on `MapNotify` or `ConfigureNotify` to discover the window, but those events require `StructureNotify` on that window or `SubstructureNotify` on its parent. The repair adds neither guarantee; if the parent is not subscribed, no callback reaches `fixWindow` and keyboard input remains broken.
Ensure the fixer is called from a window lifecycle hook, or otherwise subscribe to a notification that is guaranteed to arrive before relying on these events to repair the mask.
Also at `x11keymaskfixer.cpp:50-58`.| auto *event = static_cast<xcb_generic_event_t *>(message); | ||
| xcb_window_t windowId = 0; | ||
| switch (event->response_type & 0x7f) { | ||
| case XCB_MAP_NOTIFY: |
There was a problem hiding this comment.
🟡 Medium · First keystroke can be lost
When the user types before the server processes the mask update after mapping the popup, nativeEventFilter repairs the window only after receiving MapNotify; until fixWindow sends and flushes the mask change, the X server still drops keyboard events for that window. A key pressed in that interval is lost, so the first character typed into the search box disappears.
Apply the keyboard masks before mapping or activating the window, or otherwise preserve input received before the repair completes.
Prompt for AI agents
In `x11keymaskfixer.cpp` at line 70:
**First keystroke can be lost**
When the user types before the server processes the mask update after mapping the popup, `nativeEventFilter` repairs the window only after receiving `MapNotify`; until `fixWindow` sends and flushes the mask change, the X server still drops keyboard events for that window. A key pressed in that interval is lost, so the first character typed into the search box disappears.
Apply the keyboard masks before mapping or activating the window, or otherwise preserve input received before the repair completes.| const auto windows = QGuiApplication::topLevelWindows(); | ||
| for (QWindow *window : windows) { | ||
| if (window->isVisible() && window->winId() == windowId) { | ||
| fixWindow(window); |
There was a problem hiding this comment.
🟡 Medium · Window resizing blocks on X server
When a visible top-level window generates repeated configure events, such as during interactive resizing, nativeEventFilter calls fixWindow for every matching configure event, and fixWindow synchronously waits for xcb_get_window_attributes_reply even after the keyboard masks have already been repaired. Repeated resize or move events therefore block the GUI thread on X-server round trips, making the window stutter.
Avoid a synchronous attributes round trip for every configure event, for example by tracking repaired windows or using an asynchronous query.
Prompt for AI agents
In `x11keymaskfixer.cpp` at line 87:
**Window resizing blocks on X server**
When a visible top-level window generates repeated configure events, such as during interactive resizing, `nativeEventFilter` calls `fixWindow` for every matching configure event, and `fixWindow` synchronously waits for `xcb_get_window_attributes_reply` even after the keyboard masks have already been repaired. Repeated resize or move events therefore block the GUI thread on X-server round trips, making the window stutter.
Avoid a synchronous attributes round trip for every configure event, for example by tracking repaired windows or using an asynchronous query.
修复dde-shell搜索框不能输文子的问题
Summary by Sourcery
Fix text input in X11 popup windows by restoring the event masks required for Qt to receive keyboard events.
Bug Fixes:
Build: