Skip to content

feat(dock): approve a window for mirror mode from its preview - #1851

Draft
justforlxz wants to merge 1 commit into
linuxdeepin:masterfrom
justforlxz:feat/dock-mirror-mode-approve
Draft

justforlxz wants to merge 1 commit into
linuxdeepin:masterfrom
justforlxz:feat/dock-mirror-mode-approve

Conversation

@justforlxz

@justforlxz justforlxz commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

The mirror mode switch decides whether the other outputs show the desktop, and KWin lets the user override that decision per window. The dock now offers it where the window itself is: the preview that pops up when the task icon is hovered carries a lock button next to the close button of every approvable window.

The approval is read and written through KWin's D-Bus interface, and the button reflects the state KWin publishes, so the same window shows the same state in every preview and in every panel. The button belongs to the item it is drawn on: it carries the window id it writes, so a click can never be applied to another window, and it is refreshed from the window lists and the mode property rather than from the click, which keeps a slow or refused write from leaving a state the user did not ask for.

The policy that maps the mode and the listed flag to an approval is a pure function in mirrormodepolicy.h, covered by a unit test, because KWin and the dock have to agree on it: what the button shows is what the window does.

PMS: TASK-394957

Summary by Sourcery

Add window-level mirror-mode approval controls to task previews and keep their state synchronized with KWin.

New Features:

  • Add per-window mirror-mode approval controls to X11 task previews, allowing users to toggle whether an approvable window appears on mirrored outputs.

Enhancements:

  • Synchronize preview controls with KWin’s published mirror-mode policy and window lists, including asynchronous updates and safe handling of failed or stale requests.

Tests:

  • Add unit coverage for mirror-mode policy mapping, approval behavior, and listed-flag round trips.

The mirror mode switch decides whether the other outputs show the desktop, and
KWin lets the user override that decision per window.  The dock now offers it
where the window itself is: the preview that pops up when the task icon is
hovered carries a lock button next to the close button of every approvable
window.

The approval is read and written through KWin's D-Bus interface, and the button
reflects the state KWin publishes, so the same window shows the same state in
every preview and in every panel.  The button belongs to the item it is drawn
on: it carries the window id it writes, so a click can never be applied to
another window, and it is refreshed from the window lists and the mode property
rather than from the click, which keeps a slow or refused write from leaving a
state the user did not ask for.

The policy that maps the mode and the listed flag to an approval is a pure
function in mirrormodepolicy.h, covered by a unit test, because KWin and the
dock have to agree on it: what the button shows is what the window does.

PMS: TASK-394957
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: justforlxz

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@justforlxz
justforlxz marked this pull request as draft November 24, 2026 11:45
@deepin-ci-robot

deepin-ci-robot commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ OBS CI 构建警告日志 (Commit: 9b28b98a)

提示:以下为 OBS CI 构建中 Lintian 检测到的警告信息,默认折叠,点击展开查看详情。完整日志请参阅对应构建状态链接。

deepin_develop / aarch64 (Lintian 警告: 15 条)
[  515s] W: dde-shell: desktop-command-not-in-package bin/false [usr/share/applications/org.deepin.dde-shell.desktop]
[  515s] N: 
[  515s] N:   The desktop entry specifies a Command that does not match any of the
[  515s] N:   executables shipped in the package.
[  515s] N:   
[  515s] N:   This condition is often caused by a typo, or the desktop file was not
[  515s] N:   updated after the installed path of the executable was modified.
[  515s] N:   
[  515s] N:   Packages should ship executables that are used as commands in desktop
[  515s] N:   files.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: menu-format
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell: link-to-shared-library-in-wrong-package usr/lib/aarch64-linux-gnu/libds-notification-shared.so.2.0.61 [usr/lib/aarch64-linux-gnu/libds-notification-shared.so]
[  515s] N: 
[  515s] N:   Although this package is not a "-dev" package, it installs a
[  515s] N:   "libsomething.so" symbolic link referencing the corresponding shared
[  515s] N:   library. When the link doesn't include the version number, it is used by
[  515s] N:   the linker when other programs are built against this shared library.
[  515s] N:   
[  515s] N:   Shared libraries are supposed to place such symbolic links in their
[  515s] N:   respective "-dev" packages, so it is a bug to include it with the main
[  515s] N:   library package.
[  515s] N:   
[  515s] N:   However, if this is a small package which includes the runtime and the
[  515s] N:   development libraries, this is not a bug. In the latter case, please
[  515s] N:   override this warning.
[  515s] N: 
[  515s] N:   Please refer to Development files (Section 8.4) in the Debian Policy
[  515s] N:   Manual for details.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: libraries/shared/links
[  515s] N:   Renamed from: non-dev-pkg-with-shlib-symlink
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell: no-manual-page [usr/bin/dde-shell]
[  515s] N: 
[  515s] N:   Each binary in /usr/bin, /usr/sbin, /bin, /sbin or /usr/games should have
[  515s] N:   a manual page
[  515s] N:   
[  515s] N:   Note that though the man program has the capability to check for several
[  515s] N:   program names in the NAMES section, each of these programs should have its
[  515s] N:   own manual page (a symbolic link to the appropriate manual page is
[  515s] N:   sufficient) because other manual page viewers such as xman or tkman don't
[  515s] N:   support this.
[  515s] N:   
[  515s] N:   If the name of the manual page differs from the binary by case, man may be
[  515s] N:   able to find it anyway; however, it is still best practice to match the
[  515s] N:   exact capitalization of the executable in the manual page.
[  515s] N:   
[  515s] N:   If the manual pages are provided by another package on which this package
[  515s] N:   depends, Lintian may not be able to determine that manual pages are
[  515s] N:   available. In this case, after confirming that all binaries do have manual
[  515s] N:   pages after this package and its dependencies are installed, please add a
[  515s] N:   Lintian override.
[  515s] N: 
[  515s] N:   Please refer to Manual pages (Section 12.1) in the Debian Policy Manual
[  515s] N:   for details.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: documentation/manual
[  515s] N:   Renamed from: binary-without-manpage
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell source: no-nmu-in-changelog [debian/changelog:1]
[  515s] N: 
[  515s] N:   When you NMU a package, that fact should be mentioned on the first line in
[  515s] N:   the changelog entry. Use the words "NMU" or "Non-maintainer upload" (case
[  515s] N:   insensitive).
[  515s] N:   
[  515s] N:   Maybe you didn't intend this upload to be a NMU, in that case, please
[  515s] N:   double-check that the most recent entry in the changelog is byte-for-byte
[  515s] N:   identical to the maintainer or one of the uploaders. If this is a local
[  515s] N:   package (not intended for Debian), you can suppress this warning by
[  515s] N:   putting "local" in the version number or "local package" on the first line
[  515s] N:   of the changelog entry.
[  515s] N: 
[  515s] N:   Please refer to Using the DELAYED/ queue (Section 5.11.3) in the Debian
[  515s] N:   Developer's Reference for details.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: nmu
[  515s] N:   Renamed from: changelog-should-mention-nmu
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell: package-name-doesnt-match-sonames libds-notification-shared2
[  515s] N: 
[  515s] N:   The package name of a library package should usually reflect the soname of
[  515s] N:   the included library. The package name can determined from the library
[  515s] N:   file name with the following code snippet:
[  515s] N:   
[  515s] N:    $ objdump -p /path/to/libfoo-bar.so.1.2.3 | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | \
[  515s] N:        sed -r -e's/([0-9])\.so\./\1-/; s/\.so(\.|$)//; y/_/-/; s/(.*)/\L&/'
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: libraries/shared/soname
[  515s] N: 
[  515s] N:
[  515s] W: libdde-shell: package-name-doesnt-match-sonames libdde-shell1
[  515s] N:
[  515s] W: libdde-shell-dock: package-name-doesnt-match-sonames libdde-shell-dock1
[  515s] N:
[  515s] W: dde-shell source: source-nmu-has-incorrect-version-number 2.0.61+u036 [debian/changelog:1]
[  515s] N: 
[  515s] N:   A source NMU should have a Debian revision of "-x.x" (or "+nmuX" for a
[  515s] N:   native package). This is to prevent stealing version numbers from the
[  515s] N:   maintainer.
[  515s] N:   
[  515s] N:   Maybe you didn't intend this upload to be a NMU, in that case, please
[  515s] N:   double-check that the most recent entry in the changelog is byte-for-byte
[  515s] N:   identical to the maintainer or one of the uploaders. If this is a local
[  515s] N:   package (not intended for Debian), you can suppress this warning by
[  515s] N:   putting "local" in the version number or "local package" on the first line
[  515s] N:   of the changelog entry.
[  515s] N: 
[  515s] N:   Please refer to NMUs and debian/changelog (Section 5.11.2) in the Debian
[  515s] N:   Developer's Reference for details.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: nmu
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell: unknown-section DDE
[  515s] N: 
[  515s] N:   The "Section:" field in this package's control file is not one of the
[  515s] N:   sections in use on the ftp archive. Valid sections are currently admin,
[  515s] N:   comm, cli-mono, database, debug, devel, doc, editors, electronics,
[  515s] N:   embedded, fonts, games, gnome, gnu-r, gnustep, graphics, hamradio,
[  515s] N:   haskell, httpd, interpreters, java, javascript, kde, libdevel, libs, lisp,
[  515s] N:   localization, kernel, mail, math, misc, net, news, ocaml, oldlibs,
[  515s] N:   otherosfs, perl, php, python, ruby, rust, science, shells, sound, tex,
[  515s] N:   text, utils, vcs, video, web, x11, xfce, zope.
[  515s] N:   
[  515s] N:   The section name should be preceded by either "contrib/", "non-free/" or
[  515s] N:   "non-free-firmware/" if the package is in the according archive area.
[  515s] N: 
[  515s] N:   Please refer to Sections (Section 2.4) in the Debian Policy Manual for
[  515s] N:   details.
[  515s] N: 
[  515s] N:   Visibility: warning
[  515s] N:   Show-Always: no
[  515s] N:   Check: fields/section
[  515s] N: 
[  515s] N:
[  515s] W: dde-shell-example: unknown-section DDE
[  515s] N:
[  515s] W: libdde-shell: unknown-section DDE
[  515s] N:
[  515s] W: libdde-shell-dev: unknown-section DDE
[  515s] N:
[  515s] W: libdde-shell-dock: unknown-section DDE
[  515s] N:
[  515s] W: libdde-shell-dock-dev: unknown-section DDE
[  516s] Warning: mkbaselibs missing in build root, skipping baselibs
deepin_develop / x86_64 (Lintian 警告: 15 条)
[  315s] W: dde-shell: desktop-command-not-in-package bin/false [usr/share/applications/org.deepin.dde-shell.desktop]
[  315s] N: 
[  315s] N:   The desktop entry specifies a Command that does not match any of the
[  315s] N:   executables shipped in the package.
[  315s] N:   
[  315s] N:   This condition is often caused by a typo, or the desktop file was not
[  315s] N:   updated after the installed path of the executable was modified.
[  315s] N:   
[  315s] N:   Packages should ship executables that are used as commands in desktop
[  315s] N:   files.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: menu-format
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell: link-to-shared-library-in-wrong-package usr/lib/x86_64-linux-gnu/libds-notification-shared.so.2.0.61 [usr/lib/x86_64-linux-gnu/libds-notification-shared.so]
[  315s] N: 
[  315s] N:   Although this package is not a "-dev" package, it installs a
[  315s] N:   "libsomething.so" symbolic link referencing the corresponding shared
[  315s] N:   library. When the link doesn't include the version number, it is used by
[  315s] N:   the linker when other programs are built against this shared library.
[  315s] N:   
[  315s] N:   Shared libraries are supposed to place such symbolic links in their
[  315s] N:   respective "-dev" packages, so it is a bug to include it with the main
[  315s] N:   library package.
[  315s] N:   
[  315s] N:   However, if this is a small package which includes the runtime and the
[  315s] N:   development libraries, this is not a bug. In the latter case, please
[  315s] N:   override this warning.
[  315s] N: 
[  315s] N:   Please refer to Development files (Section 8.4) in the Debian Policy
[  315s] N:   Manual for details.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: libraries/shared/links
[  315s] N:   Renamed from: non-dev-pkg-with-shlib-symlink
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell: no-manual-page [usr/bin/dde-shell]
[  315s] N: 
[  315s] N:   Each binary in /usr/bin, /usr/sbin, /bin, /sbin or /usr/games should have
[  315s] N:   a manual page
[  315s] N:   
[  315s] N:   Note that though the man program has the capability to check for several
[  315s] N:   program names in the NAMES section, each of these programs should have its
[  315s] N:   own manual page (a symbolic link to the appropriate manual page is
[  315s] N:   sufficient) because other manual page viewers such as xman or tkman don't
[  315s] N:   support this.
[  315s] N:   
[  315s] N:   If the name of the manual page differs from the binary by case, man may be
[  315s] N:   able to find it anyway; however, it is still best practice to match the
[  315s] N:   exact capitalization of the executable in the manual page.
[  315s] N:   
[  315s] N:   If the manual pages are provided by another package on which this package
[  315s] N:   depends, Lintian may not be able to determine that manual pages are
[  315s] N:   available. In this case, after confirming that all binaries do have manual
[  315s] N:   pages after this package and its dependencies are installed, please add a
[  315s] N:   Lintian override.
[  315s] N: 
[  315s] N:   Please refer to Manual pages (Section 12.1) in the Debian Policy Manual
[  315s] N:   for details.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: documentation/manual
[  315s] N:   Renamed from: binary-without-manpage
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell source: no-nmu-in-changelog [debian/changelog:1]
[  315s] N: 
[  315s] N:   When you NMU a package, that fact should be mentioned on the first line in
[  315s] N:   the changelog entry. Use the words "NMU" or "Non-maintainer upload" (case
[  315s] N:   insensitive).
[  315s] N:   
[  315s] N:   Maybe you didn't intend this upload to be a NMU, in that case, please
[  315s] N:   double-check that the most recent entry in the changelog is byte-for-byte
[  315s] N:   identical to the maintainer or one of the uploaders. If this is a local
[  315s] N:   package (not intended for Debian), you can suppress this warning by
[  315s] N:   putting "local" in the version number or "local package" on the first line
[  315s] N:   of the changelog entry.
[  315s] N: 
[  315s] N:   Please refer to Using the DELAYED/ queue (Section 5.11.3) in the Debian
[  315s] N:   Developer's Reference for details.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: nmu
[  315s] N:   Renamed from: changelog-should-mention-nmu
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell: package-name-doesnt-match-sonames libds-notification-shared2
[  315s] N: 
[  315s] N:   The package name of a library package should usually reflect the soname of
[  315s] N:   the included library. The package name can determined from the library
[  315s] N:   file name with the following code snippet:
[  315s] N:   
[  315s] N:    $ objdump -p /path/to/libfoo-bar.so.1.2.3 | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | \
[  315s] N:        sed -r -e's/([0-9])\.so\./\1-/; s/\.so(\.|$)//; y/_/-/; s/(.*)/\L&/'
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: libraries/shared/soname
[  315s] N: 
[  315s] N:
[  315s] W: libdde-shell: package-name-doesnt-match-sonames libdde-shell1
[  315s] N:
[  315s] W: libdde-shell-dock: package-name-doesnt-match-sonames libdde-shell-dock1
[  315s] N:
[  315s] W: dde-shell source: source-nmu-has-incorrect-version-number 2.0.61+u036 [debian/changelog:1]
[  315s] N: 
[  315s] N:   A source NMU should have a Debian revision of "-x.x" (or "+nmuX" for a
[  315s] N:   native package). This is to prevent stealing version numbers from the
[  315s] N:   maintainer.
[  315s] N:   
[  315s] N:   Maybe you didn't intend this upload to be a NMU, in that case, please
[  315s] N:   double-check that the most recent entry in the changelog is byte-for-byte
[  315s] N:   identical to the maintainer or one of the uploaders. If this is a local
[  315s] N:   package (not intended for Debian), you can suppress this warning by
[  315s] N:   putting "local" in the version number or "local package" on the first line
[  315s] N:   of the changelog entry.
[  315s] N: 
[  315s] N:   Please refer to NMUs and debian/changelog (Section 5.11.2) in the Debian
[  315s] N:   Developer's Reference for details.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: nmu
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell: unknown-section DDE
[  315s] N: 
[  315s] N:   The "Section:" field in this package's control file is not one of the
[  315s] N:   sections in use on the ftp archive. Valid sections are currently admin,
[  315s] N:   comm, cli-mono, database, debug, devel, doc, editors, electronics,
[  315s] N:   embedded, fonts, games, gnome, gnu-r, gnustep, graphics, hamradio,
[  315s] N:   haskell, httpd, interpreters, java, javascript, kde, libdevel, libs, lisp,
[  315s] N:   localization, kernel, mail, math, misc, net, news, ocaml, oldlibs,
[  315s] N:   otherosfs, perl, php, python, ruby, rust, science, shells, sound, tex,
[  315s] N:   text, utils, vcs, video, web, x11, xfce, zope.
[  315s] N:   
[  315s] N:   The section name should be preceded by either "contrib/", "non-free/" or
[  315s] N:   "non-free-firmware/" if the package is in the according archive area.
[  315s] N: 
[  315s] N:   Please refer to Sections (Section 2.4) in the Debian Policy Manual for
[  315s] N:   details.
[  315s] N: 
[  315s] N:   Visibility: warning
[  315s] N:   Show-Always: no
[  315s] N:   Check: fields/section
[  315s] N: 
[  315s] N:
[  315s] W: dde-shell-example: unknown-section DDE
[  315s] N:
[  315s] W: libdde-shell: unknown-section DDE
[  315s] N:
[  315s] W: libdde-shell-dev: unknown-section DDE
[  315s] N:
[  315s] W: libdde-shell-dock: unknown-section DDE
[  315s] N:
[  315s] W: libdde-shell-dock-dev: unknown-section DDE
[  315s] Warning: mkbaselibs missing in build root, skipping baselibs

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Define the mirror-mode policy values and pure helpers that map KWin’s listed flag to approval state.

  • panels/dock/taskmanager/mirrormodepolicy.h L1-70

API

Add the asynchronous KWin mirror-mode client that reads the published policy and window lists and requests per-window approval changes.

  • panels/dock/taskmanager/mirrormodeclient.cpp L1-197
  • panels/dock/taskmanager/mirrormodeclient.h L1-77

Uses of the API

Wire the mirror-mode client into the X11 preview container and refresh its state as window lists or the mode property change.

  • panels/dock/taskmanager/x11preview.cpp L506-516, L653-665, L791-796 (+3 small edits)
  • panels/dock/taskmanager/x11preview.h L75-78 (+3 small edits)

UI

Add a per-preview lock button that reflects policy-derived approval and toggles the listed flag for the preview’s window.

  • panels/dock/taskmanager/x11preview.cpp L67-108, L335-341, L397-444 (+2 small edits)

Configuration

Include the mirror-mode client and policy files in the X11 task manager build.

  • panels/dock/taskmanager/CMakeLists.txt L121-123

Tests

Test the root-property mapping, approvable policies, approval semantics, and listed-flag round trips.

  • tests/panels/dock/taskmanager/CMakeLists.txt L62-70
  • tests/panels/dock/taskmanager/mirrormodepolicytests.cpp L1-63

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 7 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="44" />
<code_context>
+
+    const xcb_get_property_cookie_t cookie =
+        xcb_get_property(connection, false, utils->getRootWindow(), atom, XCB_ATOM_CARDINAL, 0, 1);
+    std::unique_ptr<xcb_get_property_reply_t> reply(xcb_get_property_reply(connection, cookie, nullptr));
+    if (!reply || reply->type == XCB_ATOM_NONE || reply->format != 32
+        || xcb_get_property_value_length(reply.get()) < static_cast<int>(sizeof(uint32_t))) {
</code_context>
<issue_to_address>
**Preview refresh mismatches allocator**

When `fetchPolicy()` receives a non-null XCB reply, `std::unique_ptr` uses its default `delete` deleter for the reply returned by XCB, which must be released with `free`; destroying the reply therefore invokes mismatched deallocation and undefined behavior during policy refreshes, potentially corrupting the heap or crashing the dock.

Give the `unique_ptr` a deleter that calls `free`, or use an equivalent XCB-aware RAII wrapper.
</issue_to_address>

### Comment 2
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="42-44" />
<code_context>
+        return MirrorModePolicy::Off;
+    }
+
+    const xcb_get_property_cookie_t cookie =
+        xcb_get_property(connection, false, utils->getRootWindow(), atom, XCB_ATOM_CARDINAL, 0, 1);
+    std::unique_ptr<xcb_get_property_reply_t> reply(xcb_get_property_reply(connection, cookie, nullptr));
+    if (!reply || reply->type == XCB_ATOM_NONE || reply->format != 32
+        || xcb_get_property_value_length(reply.get()) < static_cast<int>(sizeof(uint32_t))) {
</code_context>
<issue_to_address>
**Dock freezes on X replies**

When the X server is slow or stops responding to the property query, `refresh()` calls `fetchPolicy()` on the UI thread, where `xcb_get_property_reply()` waits for the server response and stalls painting and input until it responds or the connection fails.

Make the property query nonblocking on the UI thread and handle its reply asynchronously.
</issue_to_address>

### Comment 3
<location path="panels/dock/taskmanager/x11preview.cpp" line_range="409-410" />
<code_context>
+        mirrorButton->setPalette(palette);
+        mirrorButton->setIconSize(QSize(16, 16));
+        mirrorButton->setFixedSize(PREVIEW_TITLE_HEIGHT, PREVIEW_TITLE_HEIGHT);
+        mirrorButton->move(option.rect.topRight()
+                           - QPoint(PREVIEW_TITLE_HEIGHT * 2 + MIRROR_BUTTON_INSET * 2, -5));
+        updateMirrorButton(mirrorButton, m_parent->mirrorModeClient());
+
</code_context>
<issue_to_address>
**Approval button targets wrong row**

When preview rows are inserted, removed, or otherwise move while the preview is open, `QListView` repositions the persistent `closeButton` editor but not the sibling `mirrorButton`, which is positioned only once and retains its original window ID; the lock appears beside a different row and toggles the wrong window.

Keep the mirror button positioned with its row whenever the view updates the persistent editor’s geometry.
</issue_to_address>

### Comment 4
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="79-86" />
<code_context>
+
+void MirrorModeClient::refresh()
+{
+    m_policy = fetchPolicy();
+
+    // Supersede whatever is still on the wire: only this generation's answers are
+    // applied, and changed() is emitted when both lists are in.
+    const quint64 generation = ++m_generation;
+    m_pendingLists = 0;
+    requestWindowList(QStringLiteral("primaryWindows"), generation);
+    requestWindowList(QStringLiteral("mirrorWindows"), generation);
+}
+
</code_context>
<issue_to_address>
**Clicks combine new policy with old lists**

When the mirror-mode policy changes and the user clicks before both list reads complete, `refresh()` publishes the new policy while retaining the old lists and button state, so the click handler combines the new policy with the old listed flag and submits the action opposite to the state the button shows.

Publish the policy and refreshed lists together, or prevent approval clicks until the lists are refreshed.

Also at `panels/dock/taskmanager/x11preview.cpp:436-442`.
</issue_to_address>

### Comment 5
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="109-110" />
<code_context>
+                const QDBusMessage reply = call->reply();
+                if (reply.type() != QDBusMessage::ReplyMessage || reply.arguments().isEmpty()) {
+                    // Keep the lists read last time: a failed read must not look like
+                    // "KWin publishes no windows".
+                    qCWarning(mirrorModeLog) << "failed to read" << name << ":" << reply.errorMessage();
+                } else {
+                    applyWindowList(name, reply.arguments().constFirst().value<QDBusVariant>().variant().toStringList());
</code_context>
<issue_to_address>
**Failed reads leave stale approval**

When a window-list read fails while the other list succeeds or KWin’s lists have changed, `requestWindowList()` preserves the failed read’s previous value, then emits `changed()` after the reads complete; the preview uses a mixed or stale snapshot for approval controls, and no retry occurs to correct it until another refresh trigger.

Do not expose approval controls from a mixed snapshot; invalidate the failed list and retry or refresh it before publishing the state.
</issue_to_address>

### Comment 6
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="174" />
<code_context>
+                                                         QString::fromLatin1(kInterface),
+                                                         listed ? QStringLiteral("approveWindow")
+                                                                : QStringLiteral("removeWindow"));
+    message << QVariant::fromValue<qulonglong>(winId);
+
+    m_pendingWrites.insert(winId);
</code_context>
<issue_to_address>
**Approval calls use the wrong integer width**

When KWin exports `approveWindow` and `removeWindow` with a 32-bit window-ID argument, the call marshals `winId` as a 64-bit D-Bus integer, so KWin rejects it with an argument-signature error when `approveWindow` and `removeWindow` take the 32-bit X11 window ID; every approval click then fails.

Send the window ID using the exact integer type declared by KWin's D-Bus interface.
</issue_to_address>

### Comment 7
<location path="panels/dock/taskmanager/mirrormodeclient.cpp" line_range="45-46" />
<code_context>
+    const xcb_get_property_cookie_t cookie =
+        xcb_get_property(connection, false, utils->getRootWindow(), atom, XCB_ATOM_CARDINAL, 0, 1);
+    std::unique_ptr<xcb_get_property_reply_t> reply(xcb_get_property_reply(connection, cookie, nullptr));
+    if (!reply || reply->type == XCB_ATOM_NONE || reply->format != 32
+        || xcb_get_property_value_length(reply.get()) < static_cast<int>(sizeof(uint32_t))) {
+        return MirrorModePolicy::Off;
+    }
</code_context>
<issue_to_address>
**Wrong property types enable controls**

When the root property has a 32-bit non-`CARDINAL` type and its value is 1, 2, or 3, the 32-bit value is interpreted as a mirror policy even though its X property type is not `CARDINAL`; a mismatched property containing a recognized value can expose approval controls with the wrong policy and make the button report or write the wrong state.

Require `reply->type == XCB_ATOM_CARDINAL` before interpreting the property value.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨


const xcb_get_property_cookie_t cookie =
xcb_get_property(connection, false, utils->getRootWindow(), atom, XCB_ATOM_CARDINAL, 0, 1);
std::unique_ptr<xcb_get_property_reply_t> reply(xcb_get_property_reply(connection, cookie, nullptr));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Preview refresh mismatches allocator

When fetchPolicy() receives a non-null XCB reply, std::unique_ptr uses its default delete deleter for the reply returned by XCB, which must be released with free; destroying the reply therefore invokes mismatched deallocation and undefined behavior during policy refreshes, potentially corrupting the heap or crashing the dock.

Give the unique_ptr a deleter that calls free, or use an equivalent XCB-aware RAII wrapper.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at line 44:

**Preview refresh mismatches allocator**

When `fetchPolicy()` receives a non-null XCB reply, `std::unique_ptr` uses its default `delete` deleter for the reply returned by XCB, which must be released with `free`; destroying the reply therefore invokes mismatched deallocation and undefined behavior during policy refreshes, potentially corrupting the heap or crashing the dock.

Give the `unique_ptr` a deleter that calls `free`, or use an equivalent XCB-aware RAII wrapper.

Comment on lines +42 to +44
const xcb_get_property_cookie_t cookie =
xcb_get_property(connection, false, utils->getRootWindow(), atom, XCB_ATOM_CARDINAL, 0, 1);
std::unique_ptr<xcb_get_property_reply_t> reply(xcb_get_property_reply(connection, cookie, nullptr));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Dock freezes on X replies

When the X server is slow or stops responding to the property query, refresh() calls fetchPolicy() on the UI thread, where xcb_get_property_reply() waits for the server response and stalls painting and input until it responds or the connection fails.

Make the property query nonblocking on the UI thread and handle its reply asynchronously.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at lines 42-44:

**Dock freezes on X replies**

When the X server is slow or stops responding to the property query, `refresh()` calls `fetchPolicy()` on the UI thread, where `xcb_get_property_reply()` waits for the server response and stalls painting and input until it responds or the connection fails.

Make the property query nonblocking on the UI thread and handle its reply asynchronously.

Comment on lines +409 to +410
mirrorButton->move(option.rect.topRight()
- QPoint(PREVIEW_TITLE_HEIGHT * 2 + MIRROR_BUTTON_INSET * 2, -5));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Approval button targets wrong row

When preview rows are inserted, removed, or otherwise move while the preview is open, QListView repositions the persistent closeButton editor but not the sibling mirrorButton, which is positioned only once and retains its original window ID; the lock appears beside a different row and toggles the wrong window.

Keep the mirror button positioned with its row whenever the view updates the persistent editor’s geometry.

Prompt for AI agents
In `panels/dock/taskmanager/x11preview.cpp` at lines 409-410:

**Approval button targets wrong row**

When preview rows are inserted, removed, or otherwise move while the preview is open, `QListView` repositions the persistent `closeButton` editor but not the sibling `mirrorButton`, which is positioned only once and retains its original window ID; the lock appears beside a different row and toggles the wrong window.

Keep the mirror button positioned with its row whenever the view updates the persistent editor’s geometry.

Comment on lines +79 to +86
m_policy = fetchPolicy();

// Supersede whatever is still on the wire: only this generation's answers are
// applied, and changed() is emitted when both lists are in.
const quint64 generation = ++m_generation;
m_pendingLists = 0;
requestWindowList(QStringLiteral("primaryWindows"), generation);
requestWindowList(QStringLiteral("mirrorWindows"), generation);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Clicks combine new policy with old lists

When the mirror-mode policy changes and the user clicks before both list reads complete, refresh() publishes the new policy while retaining the old lists and button state, so the click handler combines the new policy with the old listed flag and submits the action opposite to the state the button shows.

Publish the policy and refreshed lists together, or prevent approval clicks until the lists are refreshed.

Also at panels/dock/taskmanager/x11preview.cpp:436-442.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at lines 79-86:

**Clicks combine new policy with old lists**

When the mirror-mode policy changes and the user clicks before both list reads complete, `refresh()` publishes the new policy while retaining the old lists and button state, so the click handler combines the new policy with the old listed flag and submits the action opposite to the state the button shows.

Publish the policy and refreshed lists together, or prevent approval clicks until the lists are refreshed.

Also at `panels/dock/taskmanager/x11preview.cpp:436-442`.

Comment on lines +109 to +110
// "KWin publishes no windows".
qCWarning(mirrorModeLog) << "failed to read" << name << ":" << reply.errorMessage();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Failed reads leave stale approval

When a window-list read fails while the other list succeeds or KWin’s lists have changed, requestWindowList() preserves the failed read’s previous value, then emits changed() after the reads complete; the preview uses a mixed or stale snapshot for approval controls, and no retry occurs to correct it until another refresh trigger.

Do not expose approval controls from a mixed snapshot; invalidate the failed list and retry or refresh it before publishing the state.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at lines 109-110:

**Failed reads leave stale approval**

When a window-list read fails while the other list succeeds or KWin’s lists have changed, `requestWindowList()` preserves the failed read’s previous value, then emits `changed()` after the reads complete; the preview uses a mixed or stale snapshot for approval controls, and no retry occurs to correct it until another refresh trigger.

Do not expose approval controls from a mixed snapshot; invalidate the failed list and retry or refresh it before publishing the state.

QString::fromLatin1(kInterface),
listed ? QStringLiteral("approveWindow")
: QStringLiteral("removeWindow"));
message << QVariant::fromValue<qulonglong>(winId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Approval calls use the wrong integer width

When KWin exports approveWindow and removeWindow with a 32-bit window-ID argument, the call marshals winId as a 64-bit D-Bus integer, so KWin rejects it with an argument-signature error when approveWindow and removeWindow take the 32-bit X11 window ID; every approval click then fails.

Send the window ID using the exact integer type declared by KWin's D-Bus interface.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at line 174:

**Approval calls use the wrong integer width**

When KWin exports `approveWindow` and `removeWindow` with a 32-bit window-ID argument, the call marshals `winId` as a 64-bit D-Bus integer, so KWin rejects it with an argument-signature error when `approveWindow` and `removeWindow` take the 32-bit X11 window ID; every approval click then fails.

Send the window ID using the exact integer type declared by KWin's D-Bus interface.

Comment on lines +45 to +46
if (!reply || reply->type == XCB_ATOM_NONE || reply->format != 32
|| xcb_get_property_value_length(reply.get()) < static_cast<int>(sizeof(uint32_t))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Wrong property types enable controls

When the root property has a 32-bit non-CARDINAL type and its value is 1, 2, or 3, the 32-bit value is interpreted as a mirror policy even though its X property type is not CARDINAL; a mismatched property containing a recognized value can expose approval controls with the wrong policy and make the button report or write the wrong state.

Require reply->type == XCB_ATOM_CARDINAL before interpreting the property value.

Prompt for AI agents
In `panels/dock/taskmanager/mirrormodeclient.cpp` at lines 45-46:

**Wrong property types enable controls**

When the root property has a 32-bit non-`CARDINAL` type and its value is 1, 2, or 3, the 32-bit value is interpreted as a mirror policy even though its X property type is not `CARDINAL`; a mismatched property containing a recognized value can expose approval controls with the wrong policy and make the button report or write the wrong state.

Require `reply->type == XCB_ATOM_CARDINAL` before interpreting the property value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants