Skip to content

fix: use focused shutdown-menu actions for right-click menu items - #1844

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:agent/bugfix/381309
Nov 24, 2026
Merged

18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:agent/bugfix/381309

Conversation

@18202781743

@18202781743 18202781743 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

In the Treeland Wayland session, right-clicking the shutdown icon on the taskbar and selecting "Restart", "Shutdown", "Suspend", "Hibernate", or "Logout" always opens the generic shutdown menu (no focus preference) instead of directly focusing the matching action button. The root cause is in ShutdownApplet::requestShutdown() (applets/dde-shutdown/shutdownapplet.cpp:43-61): the Wayland branch maps Shutdown/Restart/Suspend/Hibernate/Logout/UpdateAndShutdown/UpdateAndReboot all to m_lockscreen->shutdown() which triggers action_shutdown_menu (enum 24, generic menu), instead of the focused variants (enum 26-30). The TreeLandLockScreen class only implemented lock(), shutdown(), and switchUser() — the five focused action methods were never added when treeland-protocols was upgraded to 0.7.0 in commit 801e9981.

Fix Approach

Added five new methods (powerOff(), reboot(), suspend(), hibernate(), logout()) to TreeLandLockScreen, each calling trigger() with the corresponding protocol enum (26-30). Updated requestShutdown() Wayland branch to map each type string to its corresponding new method instead of falling through to shutdown(). This matches the analysis report section 10 fix recommendation with no deviation.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Only new methods are added; existing lock(), shutdown(), switchUser() methods are unchanged
  • New methods follow the same pattern as existing ones (isActive() guard + trigger(enum) call); X11 branch is not affected

Business Impact Scope

  • Affected: Wayland session right-click shutdown menu — selecting Restart/Shutdown/Suspend/Hibernate/Logout now directly focuses the corresponding action button instead of showing the generic menu
  • Not affected: X11 session shutdown behavior, left-click shutdown icon (still shows generic menu), Lock and SwitchUser operations

Verification Suggestion

Test right-clicking the shutdown icon in a Treeland Wayland session and selecting each menu item (Restart/Shutdown/Suspend/Hibernate/Logout) — verify the corresponding button is focused. Verify left-click still shows the generic menu and X11 session behavior is unchanged.


根因分析

在 Treeland Wayland 会话下,右键任务栏关机图标后选择"重启""关机""待机""休眠""注销"时,系统总是弹出通用关机界面(无焦点偏好),而非直接聚焦到对应操作按钮。根因在 ShutdownApplet::requestShutdown()(applets/dde-shutdown/shutdownapplet.cpp:43-61):Wayland 分支将 Shutdown/Restart/Suspend/Hibernate/Logout/UpdateAndShutdown/UpdateAndReboot 全部映射到 m_lockscreen->shutdown(),触发 action_shutdown_menu(枚举 24,通用菜单),而非对应的 focused 变体(枚举 26-30)。TreeLandLockScreen 类只实现了 lock()、shutdown()、switchUser() 三个方法,在 commit 801e9981 升级 treeland-protocols 到 0.7.0 时未同步新增五个 focused action 方法。

修复方案

在 TreeLandLockScreen 中新增 powerOff()、reboot()、suspend()、hibernate()、logout() 五个方法,分别调用 trigger() 传入对应协议枚举值(26-30)。在 requestShutdown() Wayland 分支中将每种 type 字符串映射到对应新方法,而非全部 fall through 到 shutdown()。与分析报告第十节方案一致,无偏离。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 仅新增方法,不修改现有 lock()、shutdown()、switchUser() 方法
  • 新增方法与现有方法同构(isActive() 守卫 + trigger(enum) 调用),X11 分支不受影响

业务影响范围

  • 受影响: Wayland 会话右键关机菜单 — 选择重启/关机/待机/休眠/注销时直接聚焦到对应操作按钮,而非弹出通用界面
  • 不受影响: X11 会话关机行为、左键单击关机图标(仍弹出通用菜单)、锁定和切换用户操作

验证建议

在 Treeland Wayland 会话下右键关机图标,依次选择各菜单项(重启/关机/待机/休眠/注销),验证对应按钮被聚焦。验证左键单击仍弹出通用菜单,X11 会话关机行为无变化。

PMS: BUG-381309

Summary by Sourcery

Route Treeland Wayland shutdown-menu actions to the matching focused lock-screen controls.

Bug Fixes:

  • Route Treeland Wayland shutdown-menu selections to their corresponding focused actions instead of the generic shutdown menu.

Enhancements:

  • Add focused power-off, reboot, suspend, hibernate, and logout actions to the Treeland lock-screen integration.

@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Declare the focused Treeland actions that the applet can call.

  • applets/dde-shutdown/treelandlockscreen.h L25-29

Uses of the API

Route each Wayland shutdown-menu selection to its matching focused action while keeping the generic menu for other cases.

  • applets/dde-shutdown/shutdownapplet.cpp L1, L51, L56-65

Implementation

Implement the focused Treeland actions using their corresponding protocol triggers.

  • applets/dde-shutdown/treelandlockscreen.cpp L43-76

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 1 issue

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

## Individual Comments

### Comment 1
<location path="applets/dde-shutdown/shutdownapplet.cpp" line_range="56-57" />
<code_context>
-            type == QStringLiteral("Restart") || type == QStringLiteral("Logout")) {
-            // TODO: implement these types
-            m_lockscreen->shutdown();
+        } else if (type == QStringLiteral("Restart") || type == QStringLiteral("UpdateAndReboot")) {
+            m_lockscreen->reboot();
+        } else if (type == QStringLiteral("Suspend")) {
+            m_lockscreen->suspend();
</code_context>
<issue_to_address>
**Update choices focus ordinary actions**

When a Treeland caller requests UpdateAndReboot or UpdateAndShutdown, `requestShutdown()` routes `UpdateAndReboot` to `m_lockscreen->reboot()` and `UpdateAndShutdown` to `powerOff()`, losing the update intent, so users see the ordinary reboot or power-off action focused.

Preserve the update intent in the Treeland request instead of mapping these types to the ordinary reboot and power-off actions.

Also at `applets/dde-shutdown/shutdownapplet.cpp:65-66`.
</issue_to_address>

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

Comment thread applets/dde-shutdown/shutdownapplet.cpp Resolved
@deepin-ci-robot

deepin-ci-robot commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ OBS CI 构建警告日志 (Commit: 671c81c2)

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

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

1. Root cause: ShutdownApplet::requestShutdown Wayland branch mapped
   Shutdown/Restart/Suspend/Hibernate/Logout types all to shutdown()
   (action_shutdown_menu=24), always showing the generic menu instead of
   focusing the matching button via the focused variants (26-30)
2. Fix: add powerOff/reboot/suspend/hibernate/logout methods to
   TreeLandLockScreen calling trigger with enum 26-30, map each type
   to its corresponding method in requestShutdown
3. Impact: right-click menu items now directly focus the matching
   action button; left-click and X11 branch unaffected

Influence:
1. Test right-click shutdown icon and select each menu item
2. Verify focused button matches the selected action
3. Test left-click still shows generic shutdown menu
4. Verify X11 session shutdown behavior unchanged

fix: 右键关机菜单项直接触发对应操作而非总弹通用界面

1. 根因:ShutdownApplet::requestShutdown 的 Wayland 分支将
   Shutdown/Restart/Suspend/Hibernate/Logout 全部映射到 shutdown()
   (action_shutdown_menu=24),总是弹出通用菜单而非通过 focused
   变体(26-30)聚焦到对应按钮
2. 方案:在 TreeLandLockScreen 中新增 powerOff/reboot/suspend/
   hibernate/logout 五个方法分别调用 trigger 枚举 26-30,在
   requestShutdown 中将每种 type 映射到对应方法
3. 影响:右键菜单项现在直接聚焦到对应操作按钮;左键单击和
   X11 分支不受影响

Influence:
1. 测试右键关机图标后选择各菜单项
2. 验证聚焦按钮与选择的操作一致
3. 测试左键单击仍弹出通用关机菜单
4. 验证 X11 会话关机行为无变化

Log: Right-click shutdown menu items now directly trigger focused
 actions
PMS: BUG-381309
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, wjyrich

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

@18202781743
18202781743 merged commit c44850b into linuxdeepin:master Nov 24, 2026
10 of 13 checks passed
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.

4 participants