Repository navigation
fix: add skip switcher hint for X11 layer shell - #1828
Conversation
1. Add setSkipSwitcher() helper to append _KDE_NET_WM_STATE_SKIP_SWITCHER to the _NET_WM_STATE property of the window 2. Resolve the _NET_WM_STATE and _KDE_NET_WM_STATE_SKIP_SWITCHER atoms via xcb 3. Read existing _NET_WM_STATE to avoid duplicating the atom, and check the append request for X11 errors 4. Connect to QWindow::visibleChanged to restore the hint on each show, since KWin clears _NET_WM_STATE on withdrawal and Qt emits visibleChanged before mapping the window 5. Call setSkipSwitcher() once at construction time so already-visible windows get the hint This prevents the layer shell window from appearing in the task switcher (Alt+Tab), keeping emulated layer-shell windows consistent with their intended behavior. Influence: 1. Verify the layer shell window does not appear in the alt-tab switcher 2. Check the window still maps and displays correctly after the hint is applied 3. Test hide/show cycles and confirm the skip-switcher hint is restored each time 4. Verify no errors or warnings are logged on non-X11 or early call paths 5. Confirm the property atom is not duplicated when the window is shown repeatedly 6. Test with multiple layer shell windows to ensure no interference fix: 为 X11 layer shell 添加跳过切换器提示 1. 新增 setSkipSwitcher() 辅助函数,向窗口的 _NET_WM_STATE 属性追加 _KDE_NET_WM_STATE_SKIP_SWITCHER 2. 通过 xcb 解析 _NET_WM_STATE 和 _KDE_NET_WM_STATE_SKIP_SWITCHER 原子 3. 读取现有 _NET_WM_STATE 以避免重复添加该原子,并检查追加请求的 X11 错误 4. 连接 QWindow::visibleChanged,在每次显示时恢复该提示,因为 KWin 在窗 口撤回时会清除 _NET_WM_STATE,而 Qt 在映射窗口前就会发出 visibleChanged 5. 在构造时调用一次 setSkipSwitcher(),使已可见的窗口也能获得该提示 这样可以避免 layer shell 窗口出现在任务切换器(Alt+Tab)中,使模拟的 layer-shell 窗口行为保持一致。 Influence: 1. 验证 layer shell 窗口不会出现在 alt-tab 切换器中 2. 检查应用提示后窗口仍能正确映射和显示 3. 测试隐藏/显示循环,确认每次都会恢复跳过切换器提示 4. 验证在非 X11 或过早调用路径下不会记录错误或警告 5. 确认窗口反复显示时该属性原子不会被重复添加 6. 使用多个 layer shell 窗口测试,确保互不干扰 Log: Added skip-switcher hint for X11 layer shell windows to keep them out of the task switcher PMS: BUG-382313
Reviewer's GuideImplementationAdd the X11 helper that resolves the relevant atoms, avoids duplicate state entries, and checks the property update for errors.
Restore the skip-switcher hint on visibility changes and apply it immediately to windows already visible at construction.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="61-62" />
<code_context>
+ }
+ if (state->type == XCB_ATOM_ATOM && state->format == 32) {
+ const auto *atoms = static_cast<const xcb_atom_t *>(xcb_get_property_value(state.get()));
+ if (std::find(atoms, atoms + state->value_len, skipSwitcher->atom) != atoms + state->value_len) {
+ return;
+ }
+ }
</code_context>
<issue_to_address>
**Remapped windows reappear in task switcher**
When the window is hidden and shown again before KWin processes its withdrawal, `setSkipSwitcher` returns when `std::find` sees the old atom, then KWin processes the pending withdrawal and clears `_NET_WM_STATE`, leaving the remapped window in the task switcher until another show cycle.
Ensure the skip-switcher hint is reapplied after KWin processes the withdrawal instead of returning based on the stale atom.
Also at `frame/layershell/x11dlayershellemulation.cpp:130-131`.
</issue_to_address>
### Comment 2
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="66" />
<code_context>
+ }
+ }
+
+ const auto appendCookie = xcb_change_property_checked(connection, XCB_PROP_MODE_APPEND, windowId, wmState->atom, XCB_ATOM_ATOM, 32, 1, &skipSwitcher->atom);
+ const std::unique_ptr<xcb_generic_error_t, decltype(&std::free)> error(xcb_request_check(connection, appendCookie), &std::free);
+ if (error) {
</code_context>
<issue_to_address>
**Mapped windows remain switchable**
When `DLayerShellWindow` is attached after the X11 window has already been mapped, the helper changes `_NET_WM_STATE` directly without sending the EWMH state-change request; KWin can ignore or replace that client-side update, leaving the already-mapped window in Alt+Tab.
For mapped windows, request the state change with an EWMH `_NET_WM_STATE` ClientMessage; keep setting the initial property before mapping.
</issue_to_address>
### Comment 3
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="45-68" />
<code_context>
+ const std::unique_ptr<xcb_intern_atom_reply_t, decltype(&std::free)> wmState(xcb_intern_atom_reply(connection, wmStateCookie, nullptr), &std::free);
</code_context>
<issue_to_address>
**Slow X server delays window showing**
When the X server is slow or stops replying during a show, `xcb_intern_atom_reply`, `xcb_get_property_reply`, and `xcb_request_check` synchronously wait for the X server on the GUI thread each time the window is shown. On a slow or unresponsive X server, these round trips delay showing the window or leave the GUI blocked.
Avoid repeated synchronous X11 round trips on the GUI thread, for example by caching atoms and handling the property update asynchronously.
</issue_to_address>| if (std::find(atoms, atoms + state->value_len, skipSwitcher->atom) != atoms + state->value_len) { | ||
| return; |
There was a problem hiding this comment.
🟡 Medium · Remapped windows reappear in task switcher
When the window is hidden and shown again before KWin processes its withdrawal, setSkipSwitcher returns when std::find sees the old atom, then KWin processes the pending withdrawal and clears _NET_WM_STATE, leaving the remapped window in the task switcher until another show cycle.
Ensure the skip-switcher hint is reapplied after KWin processes the withdrawal instead of returning based on the stale atom.
Also at frame/layershell/x11dlayershellemulation.cpp:130-131.
Prompt for AI agents
In `frame/layershell/x11dlayershellemulation.cpp` at lines 61-62:
**Remapped windows reappear in task switcher**
When the window is hidden and shown again before KWin processes its withdrawal, `setSkipSwitcher` returns when `std::find` sees the old atom, then KWin processes the pending withdrawal and clears `_NET_WM_STATE`, leaving the remapped window in the task switcher until another show cycle.
Ensure the skip-switcher hint is reapplied after KWin processes the withdrawal instead of returning based on the stale atom.
Also at `frame/layershell/x11dlayershellemulation.cpp:130-131`.| } | ||
| } | ||
|
|
||
| const auto appendCookie = xcb_change_property_checked(connection, XCB_PROP_MODE_APPEND, windowId, wmState->atom, XCB_ATOM_ATOM, 32, 1, &skipSwitcher->atom); |
There was a problem hiding this comment.
🟡 Medium · Mapped windows remain switchable
When DLayerShellWindow is attached after the X11 window has already been mapped, the helper changes _NET_WM_STATE directly without sending the EWMH state-change request; KWin can ignore or replace that client-side update, leaving the already-mapped window in Alt+Tab.
For mapped windows, request the state change with an EWMH _NET_WM_STATE ClientMessage; keep setting the initial property before mapping.
Prompt for AI agents
In `frame/layershell/x11dlayershellemulation.cpp` at line 66:
**Mapped windows remain switchable**
When `DLayerShellWindow` is attached after the X11 window has already been mapped, the helper changes `_NET_WM_STATE` directly without sending the EWMH state-change request; KWin can ignore or replace that client-side update, leaving the already-mapped window in Alt+Tab.
For mapped windows, request the state change with an EWMH `_NET_WM_STATE` ClientMessage; keep setting the initial property before mapping.| const std::unique_ptr<xcb_intern_atom_reply_t, decltype(&std::free)> wmState(xcb_intern_atom_reply(connection, wmStateCookie, nullptr), &std::free); | ||
| const std::unique_ptr<xcb_intern_atom_reply_t, decltype(&std::free)> skipSwitcher(xcb_intern_atom_reply(connection, skipSwitcherCookie, nullptr), | ||
| &std::free); | ||
| if (!wmState || !skipSwitcher) { | ||
| qCWarning(layershell) << "Failed to resolve SkipSwitcher atoms for window" << windowId; | ||
| return; | ||
| } | ||
|
|
||
| const auto stateCookie = xcb_get_property(connection, false, windowId, wmState->atom, XCB_ATOM_ATOM, 0, 1024); | ||
| const std::unique_ptr<xcb_get_property_reply_t, decltype(&std::free)> state(xcb_get_property_reply(connection, stateCookie, nullptr), &std::free); | ||
| if (!state) { | ||
| qCWarning(layershell) << "Failed to read _NET_WM_STATE for window" << windowId; | ||
| return; | ||
| } | ||
| if (state->type == XCB_ATOM_ATOM && state->format == 32) { | ||
| const auto *atoms = static_cast<const xcb_atom_t *>(xcb_get_property_value(state.get())); | ||
| if (std::find(atoms, atoms + state->value_len, skipSwitcher->atom) != atoms + state->value_len) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const auto appendCookie = xcb_change_property_checked(connection, XCB_PROP_MODE_APPEND, windowId, wmState->atom, XCB_ATOM_ATOM, 32, 1, &skipSwitcher->atom); | ||
| const std::unique_ptr<xcb_generic_error_t, decltype(&std::free)> error(xcb_request_check(connection, appendCookie), &std::free); | ||
| if (error) { |
There was a problem hiding this comment.
🟡 Medium · Slow X server delays window showing
When the X server is slow or stops replying during a show, xcb_intern_atom_reply, xcb_get_property_reply, and xcb_request_check synchronously wait for the X server on the GUI thread each time the window is shown. On a slow or unresponsive X server, these round trips delay showing the window or leave the GUI blocked.
Avoid repeated synchronous X11 round trips on the GUI thread, for example by caching atoms and handling the property update asynchronously.
Prompt for AI agents
In `frame/layershell/x11dlayershellemulation.cpp` at lines 45-68:
**Slow X server delays window showing**
When the X server is slow or stops replying during a show, `xcb_intern_atom_reply`, `xcb_get_property_reply`, and `xcb_request_check` synchronously wait for the X server on the GUI thread each time the window is shown. On a slow or unresponsive X server, these round trips delay showing the window or leave the GUI blocked.
Avoid repeated synchronous X11 round trips on the GUI thread, for example by caching atoms and handling the property update asynchronously.
_KDE_NET_WM_STATE_SKIP_SWITCHER to the _NET_WM_STATE property of the
window
via xcb
the append request for X11 errors
show, since KWin clears _NET_WM_STATE on withdrawal and Qt emits
visibleChanged before mapping the window
windows get the hint
This prevents the layer shell window from appearing in the task switcher
(Alt+Tab), keeping emulated layer-shell windows consistent with their
intended behavior.
Influence:
is applied
each time
paths
repeatedly
fix: 为 X11 layer shell 添加跳过切换器提示
_KDE_NET_WM_STATE_SKIP_SWITCHER
错误
口撤回时会清除 _NET_WM_STATE,而 Qt 在映射窗口前就会发出 visibleChanged
这样可以避免 layer shell 窗口出现在任务切换器(Alt+Tab)中,使模拟的
layer-shell 窗口行为保持一致。
Influence:
Log: Added skip-switcher hint for X11 layer shell windows to keep them
out of the task switcher
PMS: BUG-382313
Summary by Sourcery
Prevent emulated X11 layer-shell windows from appearing in the task switcher while preserving the hint across window visibility changes.
Bug Fixes:
Enhancements: