Skip to content

feat(lowpower): support wayland overlay on each screen - #484

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-294681
Open

wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-294681

Conversation

@wjyrich

@wjyrich wjyrich commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
  1. Replace the CMake source glob with an explicit source list and add Qt6 WaylandClient and wayland-protocols dependencies.
  2. Generate xdg-toplevel-tag, xdg-shell and keyboard-shortcuts-inhibit protocol bindings for the client.
  3. Create a fullscreen overlay window per QScreen on Wayland, tracked through screen added/removed signals.
  4. Add WaylandOverlay to tag the toplevel as a privileged overlay and to force fullscreen on the target output.
  5. Add ShortcutInhibition to block compositor shortcuts while the overlay is active.
  6. Generalize LowPowerAdaptor to act on all visible top-level windows and skip mouse/keyboard grabs on Wayland.
  7. Add wayland build dependencies to debian/control.

Log: Implement per-screen fullscreen low-power overlays for Wayland sessions
Influence: Low battery warning now covers every screen correctly under Wayland

feat(lowpower): 支持 Wayland 下多屏低电量覆盖窗口

  1. 用显式源文件列表替换 CMake 的源文件通配,并增加 Qt6 WaylandClient 与 wayland-protocols 依赖。
  2. 为客户端生成 xdg-toplevel-tag、xdg-shell 和键盘快捷键抑制协议绑定。
  3. 在 Wayland 下为每个 QScreen 创建全屏覆盖窗口,并跟踪屏幕增删信号。
  4. 新增 WaylandOverlay,将顶层窗口标记为特权覆盖层并强制在目标输出上 全屏。
  5. 新增 ShortcutInhibition,在覆盖窗口激活时屏蔽合成器快捷键。
  6. 将 LowPowerAdaptor 泛化为作用于所有可见顶层窗口,并在 Wayland 下跳过 鼠标键盘抓取。
  7. 在 debian/control 中增加 Wayland 构建依赖。

Log: 实现 Wayland 会话下按屏幕显示的全屏低电量覆盖窗口
Influence: Wayland 下低电量提示可正确覆盖所有屏幕
PMS: BUG-294681

Summary by Sourcery

Display and manage fullscreen low-power warning overlays on every screen in Wayland sessions.

New Features:

  • Show the low-battery warning as a fullscreen overlay on every screen in Wayland sessions, including screens added while the app is running.
  • Mark Wayland warning windows as privileged overlays and inhibit compositor shortcuts while they are active.

Bug Fixes:

  • Ensure the warning covers each display correctly in Wayland sessions.

Enhancements:

  • Raise all visible low-power windows through the D-Bus interface and avoid mouse and keyboard grabs on Wayland.

Build:

  • Replace the lowpower source glob with an explicit source list and add Qt Wayland Client and wayland-protocols build requirements.

Chores:

  • Add the Wayland build dependencies to the Debian package control metadata.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Uses of the API

Create and remove one Wayland overlay per screen, and connect them to the existing low-power D-Bus adaptor.

  • dde-lowpower/src/main.cpp L67-90 (+5 small edits)

Adapt low-power windows for per-screen fullscreen display and make the D-Bus Raise operation handle all visible windows without Wayland input grabs.

  • dde-lowpower/src/window.cpp L27-36, L46-59, L131-145 (+3 small edits)
  • dde-lowpower/src/window.h L1-41 (4 small edits)

Implementation

Implement per-screen Wayland overlay lifecycle, privileged toplevel tagging, output targeting, and shortcut inhibition.

  • dde-lowpower/src/shortcutinhibition.cpp L1-62
  • dde-lowpower/src/shortcutinhibition.h L1-31
  • dde-lowpower/src/waylandoverlay.cpp L1-129
  • dde-lowpower/src/waylandoverlay.h L1-39

Configuration

Use an explicit source list and configure Qt WaylandClient protocol generation and package build dependencies.

  • dde-lowpower/CMakeLists.txt L5-7, L10 (removed lines)
  • dde-lowpower/src/CMakeLists.txt L7-26, L35-36
  • debian/control L10-11

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

1. Replace the CMake source glob with an explicit source list and add
Qt6 WaylandClient and wayland-protocols dependencies.
2. Generate xdg-toplevel-tag, xdg-shell and keyboard-shortcuts-inhibit
protocol bindings for the client.
3. Create a fullscreen overlay window per QScreen on Wayland, tracked
through screen added/removed signals.
4. Add WaylandOverlay to tag the toplevel as a privileged overlay and to
force fullscreen on the target output.
5. Add ShortcutInhibition to block compositor shortcuts while the
overlay is active.
6. Generalize LowPowerAdaptor to act on all visible top-level windows
and skip mouse/keyboard grabs on Wayland.
7. Add wayland build dependencies to debian/control.

Log: Implement per-screen fullscreen low-power overlays for Wayland
sessions
Influence: Low battery warning now covers every screen correctly under
Wayland

feat(lowpower): 支持 Wayland 下多屏低电量覆盖窗口

1. 用显式源文件列表替换 CMake 的源文件通配,并增加 Qt6 WaylandClient 与
wayland-protocols 依赖。
2. 为客户端生成 xdg-toplevel-tag、xdg-shell 和键盘快捷键抑制协议绑定。
3. 在 Wayland 下为每个 QScreen 创建全屏覆盖窗口,并跟踪屏幕增删信号。
4. 新增 WaylandOverlay,将顶层窗口标记为特权覆盖层并强制在目标输出上
全屏。
5. 新增 ShortcutInhibition,在覆盖窗口激活时屏蔽合成器快捷键。
6. 将 LowPowerAdaptor 泛化为作用于所有可见顶层窗口,并在 Wayland 下跳过
鼠标键盘抓取。
7. 在 debian/control 中增加 Wayland 构建依赖。

Log: 实现 Wayland 会话下按屏幕显示的全屏低电量覆盖窗口
Influence: Wayland 下低电量提示可正确覆盖所有屏幕
PMS: BUG-294681

@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 4 issues

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

## Individual Comments

### Comment 1
<location path="dde-lowpower/src/main.cpp" line_range="79" />
<code_context>
+
+                it->second = std::make_unique<Window>(screen);
+                auto &overlay = *it->second;
+                overlay.winId();
+                new WaylandOverlay(overlay.windowHandle(), screen);
+                overlay.showFullScreen();
</code_context>
<issue_to_address>
**Compositor shortcuts remain available**

When qt creates the surface role while handling `overlay.winId()`, `WaylandOverlay` connects to `surfaceRoleCreated` after `overlay.winId()` creates the native window, so the signal is missed and `ShortcutInhibition::setSurface()` is never called; compositor shortcuts remain available over the warning.

Connect to surface-role creation before calling `overlay.winId()`, or otherwise handle a role that already exists.

Also at `dde-lowpower/src/waylandoverlay.cpp:37`.
</issue_to_address>

### Comment 2
<location path="dde-lowpower/src/shortcutinhibition.cpp" line_range="46" />
<code_context>
+
+void ShortcutInhibition::inhibitShortcuts()
+{
+    if (!isActive() || !m_surface || m_inhibitor) {
+        return;
+    }
</code_context>
<issue_to_address>
**Shortcuts stop being inhibited**

When the compositor removes and replaces its Wayland seat while an overlay inhibitor exists, `m_inhibitor` remains bound to the old seat, so the guard prevents `inhibitShortcuts()` from creating an inhibitor for the replacement seat and compositor shortcuts are no longer blocked for the overlay.

Track seat changes and clear and recreate the inhibitor for the current seat.
</issue_to_address>

### Comment 3
<location path="dde-lowpower/src/main.cpp" line_range="69" />
<code_context>
             return 0;
+        }
+
+        if (a.platformName().startsWith(QLatin1String("wayland"))) {
+            a.setQuitOnLastWindowClosed(false);
+            const auto showOverlay = [&overlays](QScreen *screen) {
</code_context>
<issue_to_address>
**Legacy window covers the overlays**

When the lock front emits `Visible(true)` after startup, `HideShowToRaise()` schedules `show()` for the hidden legacy window without checking its visibility, so it appears and raises over the per-screen overlays, covering or duplicating the warning.

Prevent the legacy window’s lock-front `Visible` handler from showing or raising it during a Wayland session.
</issue_to_address>

### Comment 4
<location path="dde-lowpower/src/main.cpp" line_range="69" />
<code_context>
             return 0;
+        }
+
+        if (a.platformName().startsWith(QLatin1String("wayland"))) {
+            a.setQuitOnLastWindowClosed(false);
+            const auto showOverlay = [&overlays](QScreen *screen) {
</code_context>
<issue_to_address>
**Hidden fallback window reappears**

When a `LockFront1.Visible(true)` signal arrives while the Wayland low-battery warning is running, `w` still has the `LockFront1.Visible` handler installed by its constructor, so a `Visible(true)` signal makes the hidden legacy window show alongside the per-screen overlays; users see an extra, non-fullscreen warning window.

Disable the lock-front show handler on the unused Wayland fallback window, or avoid constructing that window for Wayland sessions.
</issue_to_address>

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

Comment thread dde-lowpower/src/main.cpp

it->second = std::make_unique<Window>(screen);
auto &overlay = *it->second;
overlay.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.

🟡 Medium · Compositor shortcuts remain available

When qt creates the surface role while handling overlay.winId(), WaylandOverlay connects to surfaceRoleCreated after overlay.winId() creates the native window, so the signal is missed and ShortcutInhibition::setSurface() is never called; compositor shortcuts remain available over the warning.

Connect to surface-role creation before calling overlay.winId(), or otherwise handle a role that already exists.

Also at dde-lowpower/src/waylandoverlay.cpp:37.

Prompt for AI agents
In `dde-lowpower/src/main.cpp` at line 79:

**Compositor shortcuts remain available**

When qt creates the surface role while handling `overlay.winId()`, `WaylandOverlay` connects to `surfaceRoleCreated` after `overlay.winId()` creates the native window, so the signal is missed and `ShortcutInhibition::setSurface()` is never called; compositor shortcuts remain available over the warning.

Connect to surface-role creation before calling `overlay.winId()`, or otherwise handle a role that already exists.

Also at `dde-lowpower/src/waylandoverlay.cpp:37`.


void ShortcutInhibition::inhibitShortcuts()
{
if (!isActive() || !m_surface || m_inhibitor) {

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 · Shortcuts stop being inhibited

When the compositor removes and replaces its Wayland seat while an overlay inhibitor exists, m_inhibitor remains bound to the old seat, so the guard prevents inhibitShortcuts() from creating an inhibitor for the replacement seat and compositor shortcuts are no longer blocked for the overlay.

Track seat changes and clear and recreate the inhibitor for the current seat.

Prompt for AI agents
In `dde-lowpower/src/shortcutinhibition.cpp` at line 46:

**Shortcuts stop being inhibited**

When the compositor removes and replaces its Wayland seat while an overlay inhibitor exists, `m_inhibitor` remains bound to the old seat, so the guard prevents `inhibitShortcuts()` from creating an inhibitor for the replacement seat and compositor shortcuts are no longer blocked for the overlay.

Track seat changes and clear and recreate the inhibitor for the current seat.

Comment thread dde-lowpower/src/main.cpp
return 0;
}

if (a.platformName().startsWith(QLatin1String("wayland"))) {

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 · Legacy window covers the overlays

When the lock front emits Visible(true) after startup, HideShowToRaise() schedules show() for the hidden legacy window without checking its visibility, so it appears and raises over the per-screen overlays, covering or duplicating the warning.

Prevent the legacy window’s lock-front Visible handler from showing or raising it during a Wayland session.

Prompt for AI agents
In `dde-lowpower/src/main.cpp` at line 69:

**Legacy window covers the overlays**

When the lock front emits `Visible(true)` after startup, `HideShowToRaise()` schedules `show()` for the hidden legacy window without checking its visibility, so it appears and raises over the per-screen overlays, covering or duplicating the warning.

Prevent the legacy window’s lock-front `Visible` handler from showing or raising it during a Wayland session.

Comment thread dde-lowpower/src/main.cpp
return 0;
}

if (a.platformName().startsWith(QLatin1String("wayland"))) {

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 · Hidden fallback window reappears

When a LockFront1.Visible(true) signal arrives while the Wayland low-battery warning is running, w still has the LockFront1.Visible handler installed by its constructor, so a Visible(true) signal makes the hidden legacy window show alongside the per-screen overlays; users see an extra, non-fullscreen warning window.

Disable the lock-front show handler on the unused Wayland fallback window, or avoid constructing that window for Wayland sessions.

Prompt for AI agents
In `dde-lowpower/src/main.cpp` at line 69:

**Hidden fallback window reappears**

When a `LockFront1.Visible(true)` signal arrives while the Wayland low-battery warning is running, `w` still has the `LockFront1.Visible` handler installed by its constructor, so a `Visible(true)` signal makes the hidden legacy window show alongside the per-screen overlays; users see an extra, non-fullscreen warning window.

Disable the lock-front show handler on the unused Wayland fallback window, or avoid constructing that window for Wayland sessions.

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