Skip to content

feat: add ext-background-effect-v1 protocol support - #1412

Draft
deepin-wm wants to merge 3 commits into
linuxdeepin:masterfrom
deepin-wm:agent/developer/dddab10db858
Draft

deepin-wm wants to merge 3 commits into
linuxdeepin:masterfrom
deepin-wm:agent/developer/dddab10db858

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add ext-background-effect-v1 (blur) protocol server-side support for treeland.

Changes

Vendored wlroots C implementation (waylib/src/server/wlroots_extra/)

  • wlr_ext_background_effect_v1.h / .c — Based on wlroots MR 5304, using wlr_surface_synced + wlr_addon pattern (same as wlr_alpha_modifier_v1)
  • Placed in waylib/src/server/wlroots_extra/ per user request (not in 3rdparty/wlroots)

Protocol code generation

  • waylib/src/server/protocols/ext-background-effect-v1.xml — Protocol XML
  • ws_generate in CMake generates ext-background-effect-v1-protocol.h/.c

Qt wrapper (waylib/src/server/protocols/)

  • WBackgroundEffectManagerV1 — Wraps wlr_ext_background_effect_manager_v1, creates the global with blur capability

Build integration

  • waylib/src/server/CMakeLists.txt — Added ws_generate, sources, headers, include dirs
  • waylib/src/server/kernel/wlr_all.h — Added include
  • waylib/src/server/kernel/wlr_fwd.h — Added forward declarations

Treeland integration

  • src/seat/helper.h — Added include and member m_backgroundEffectManagerV1
  • src/seat/helper.cpp — Register manager in initShell(); hook blur state into SurfaceWrapper via setBlur() on surface commit

Build verification

All 1668 targets compiled successfully.

Summary by Sourcery

Enable ext-background-effect-v1 blur regions throughout the compositor, surface rendering pipeline, examples, and protocol tests.

New Features:

  • Add server-side ext-background-effect-v1 support with blur capability advertisement and per-surface blur-region handling.
  • Expose committed protocol blur regions to Treeland surfaces and render region-scoped blur effects in QML.
  • Add blur protocol example and end-to-end protocol coverage for capability binding, state transitions, and duplicate associations.

Bug Fixes:

  • Prevent xdg-output handling from aborting when an output has not yet been registered in the output layout.

Enhancements:

  • Integrate protocol blur state with existing surface blur behavior while excluding unsupported XWayland surfaces.

Build:

  • Generate and compile ext-background-effect-v1 protocol sources and include the vendored wlroots implementation in the server build.

Documentation:

  • Document ext-background-effect-v1 protocol test coverage and expected server-side state transitions.

Tests:

  • Add protocol tests covering blur capability negotiation, region commits, double-buffer persistence, removal, re-enabling, destruction, and duplicate-object errors.
  • Add a Qt-level test for attaching the background-effect manager and querying surface blur state.

Chores:

  • Vendor the wlroots background-effect implementation and add its licensing metadata.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-wm

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 Sep 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds server-side ext-background-effect-v1 blur support by vendoring a wlroots-style implementation, generating and wrapping the Wayland protocol, integrating its manager into Treeland, and updating build/kernel interfaces; the PR reports successful compilation of all 1668 targets.

Sequence diagram for the background blur protocol flow

sequenceDiagram
    participant Client
    participant Manager as WBackgroundEffectManagerV1
    participant Surface as wl_surface
    participant Effect as ext_background_effect_surface_v1
    participant Helper
    participant Wrapper as SurfaceWrapper

    Client->>Manager: get_background_effect(id, surface)
    Manager-->>Client: capabilities(blur)
    Client->>Effect: set_blur_region(region)
    Client->>Surface: commit()
    Surface->>Effect: apply pending blur state
    Helper->>Effect: wlr_ext_background_effect_v1_get_surface_state(surface)
    Helper->>Wrapper: setBlur(hasBlur)
Loading

File-Level Changes

Change Details Files
Adds a vendored wlroots implementation of the ext-background-effect-v1 server protocol using synchronized surface state and per-surface addons.
  • Implements manager and surface resources, including capability advertisement and duplicate-object validation.
  • Tracks double-buffered blur regions across wl_surface commits and exposes committed state to compositor code.
  • Cleans up protocol state when surfaces, addons, displays, or protocol resources are destroyed.
waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.c
waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.h
Defines and wraps the Wayland protocol for Qt/server integration.
  • Adds the ext-background-effect-v1 XML with manager capabilities and surface blur-region requests.
  • Adds a WBackgroundEffectManagerV1 wrapper that creates the global with blur capability enabled.
  • Generates and exports protocol sources, headers, and wrapper build artifacts.
waylib/src/server/protocols/ext-background-effect-v1.xml
waylib/src/server/protocols/wbackgroundeffectmanagerv1.cpp
waylib/src/server/protocols/wbackgroundeffectmanagerv1.h
waylib/src/server/protocols/WBackgroundEffectManagerV1
waylib/src/server/CMakeLists.txt
Registers the background-effect manager and applies committed blur state to Treeland surfaces.
  • Attaches the manager during shell initialization.
  • Checks each surface's committed blur region initially and on every surface commit.
  • Maps a non-empty blur region to SurfaceWrapper::setBlur().
src/seat/helper.cpp
src/seat/helper.h
Makes the new wlroots extension visible through the server kernel interfaces.
  • Adds the extension include and forward declarations to shared wlroots headers.
waylib/src/server/kernel/wlr_all.h
waylib/src/server/kernel/wlr_fwd.h

Possibly linked issues

  • #[Feature]: Window background blur: The PR directly adds blur protocol support, advertises blur capability, and applies client-provided blur regions to surfaces.

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="src/seat/helper.cpp" line_range="1707" />
<code_context>
+        auto updateBackgroundBlur = [wrapper, wlrSurface] {
+            const auto *state = wlr_ext_background_effect_v1_get_surface_state(wlrSurface);
+            bool hasBlur = state && pixman_region32_not_empty(&state->blur_region);
+            wrapper->setBlur(hasBlur);
+        };
+        updateBackgroundBlur();
</code_context>
<issue_to_address>
**issue (broader_impact):** The new integration unconditionally calls `wrapper->setBlur(false)` when a surface has no ext-background-effect blur region, overwriting the existing blur state set by `Personalization::backgroundTypeChanged`. Existing windows that use the personalization blur path therefore lose their blur immediately when the wrapper is added, and again on every surface commit.

**Triggers:** When an XDG toplevel or layer surface uses the existing personalization blur feature but does not use ext-background-effect-v1.

**Suggested fix:** Combine the protocol state with the existing blur source, or only update the wrapper's blur state from this callback when the protocol actually owns the surface's blur state.
</issue_to_address>

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

Comment thread src/seat/helper.cpp Outdated
auto updateBackgroundBlur = [wrapper, wlrSurface] {
const auto *state = wlr_ext_background_effect_v1_get_surface_state(wlrSurface);
bool hasBlur = state && pixman_region32_not_empty(&state->blur_region);
wrapper->setBlur(hasBlur);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (broader_impact): The new integration unconditionally calls wrapper->setBlur(false) when a surface has no ext-background-effect blur region, overwriting the existing blur state set by Personalization::backgroundTypeChanged. Existing windows that use the personalization blur path therefore lose their blur immediately when the wrapper is added, and again on every surface commit.

Triggers: When an XDG toplevel or layer surface uses the existing personalization blur feature but does not use ext-background-effect-v1.

Suggested fix: Combine the protocol state with the existing blur source, or only update the wrapper's blur state from this callback when the protocol actually owns the surface's blur state.

@wineee
wineee marked this pull request as draft September 16, 2026 08:18
@wineee
wineee force-pushed the agent/developer/dddab10db858 branch from 6eae61d to b8aaa92 Compare September 17, 2026 02:57
@wineee
wineee requested a lite review from Copilot September 17, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved production integration, lifecycle, build reproducibility, and example issues must be addressed.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds end-to-end ext-background-effect-v1 blur support to Treeland.

Changes:

  • Adds wlroots protocol implementation and build generation.
  • Integrates the Waylib manager with Treeland surface blur state.
  • Adds a blur client example and replaces the background example.
File summaries
File Reviewed change
waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.h Native protocol declarations
waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.c Native protocol implementation
waylib/src/server/protocols/wbackgroundeffectmanagerv1.h Waylib manager interface
waylib/src/server/protocols/wbackgroundeffectmanagerv1.cpp Manager implementation
waylib/src/server/protocols/WBackgroundEffectManagerV1 Public forwarding header
waylib/src/server/kernel/wlr_fwd.h Forward declarations
waylib/src/server/kernel/wlr_all.h wlroots header integration
waylib/src/server/CMakeLists.txt Protocol generation and build integration
src/seat/helper.h Manager member declaration
src/seat/helper.cpp Protocol registration and blur integration
examples/test_window_blur/main.cpp Blur client example
examples/test_window_blur/CMakeLists.txt Blur example build target
examples/test_window_bg/main.cpp Replaced background example
examples/CMakeLists.txt Example registration changes
Review details

Suppressed comments (3)

examples/test_window_blur/main.cpp:135

  • createEffectSurface() gives up when the manager is not active, but no signal retries it later. Qt registry activation is asynchronous and the other client examples wait for activeChanged; if activation arrives after showEvent/SurfaceCreated, this demo never creates m_effect and can never blur. Connect activeChanged and retry once the window surface exists, or defer window creation until the manager is ready.

当 manager 尚未 active 时,createEffectSurface() 会直接放弃,但没有信号在之后重试。Qt registry 的激活是异步的,其他客户端示例都会等待 activeChanged;如果激活发生在 showEvent/SurfaceCreated 之后,此示例将永远不会创建 m_effect,也无法启用模糊。请连接 activeChanged 并在 surface 就绪后重试,或延迟创建窗口直到 manager 准备完成。

        if (!m_manager->blurAvailable()) {
            qWarning() << "ext-background-effect-v1 blur is not supported by the compositor";
            return;

examples/test_window_blur/main.cpp:73

  • m_manager is allocated with new but is never deleted; the destructor only documents m_effect cleanup. This leaks the client extension object and its manager proxy whenever the example window is destroyed. Destroy the effect and manager explicitly in the window destructor (the window is created after QApplication, so the display is still valid).

m_manager 通过 new 分配后从未释放,析构函数只处理了 m_effect 的说明。示例窗口销毁时会泄漏 client extension 对象及其 manager proxy。请在窗口析构函数中显式销毁 effect 和 manager(该窗口在 QApplication 之后创建,因此此时 display 仍然有效)。

    ~BlurWindow() override
    {
        // m_effect is destroyed in eventFilter() on SurfaceAboutToBeDestroyed,
        // which Qt delivers before the underlying wl_surface goes away.
    }

waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.c:135

  • This protocol error is exposed to clients, but “a ext_background_effect_surface_v1 object” is grammatically incorrect. Use “an” so the diagnostic is clear. 该协议错误消息会返回给客户端,当前 “a ext_background_effect_surface_v1 object” 语法不正确,请改为 “an”。
			"The wl_surface object already has a ext_background_effect_surface_v1 object");
  • Files reviewed: 14/14 changed files
  • Comments generated: 10
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/seat/helper.cpp Outdated
Comment on lines +1707 to +1709
const auto *state = wlr_ext_background_effect_v1_get_surface_state(wlrSurface);
bool hasBlur = state && pixman_region32_not_empty(&state->blur_region);
wrapper->setBlur(hasBlur);
Comment thread src/seat/helper.cpp Outdated
auto *wlrSurface = wrapper->surface()->handle();
auto updateBackgroundBlur = [wrapper, wlrSurface] {
const auto *state = wlr_ext_background_effect_v1_get_surface_state(wlrSurface);
bool hasBlur = state && pixman_region32_not_empty(&state->blur_region);
Comment thread src/seat/helper.cpp Outdated
wrapper->setBlur(hasBlur);
};
updateBackgroundBlur();
connect(wrapper->surface(), &WSurface::commit, this, updateBackgroundBlur);
Comment thread src/seat/helper.cpp Outdated
wrapper->setBlur(hasBlur);
};
updateBackgroundBlur();
connect(wrapper->surface(), &WSurface::commit, this, updateBackgroundBlur);
Comment thread waylib/src/server/CMakeLists.txt
Comment thread examples/test_window_blur/main.cpp
Comment thread src/seat/helper.cpp Outdated
Comment on lines +1707 to +1709
const auto *state = wlr_ext_background_effect_v1_get_surface_state(wlrSurface);
bool hasBlur = state && pixman_region32_not_empty(&state->blur_region);
wrapper->setBlur(hasBlur);
Comment thread waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.c
Comment thread waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.h
Comment thread waylib/src/server/wlroots_extra/wlr_ext_background_effect_v1.h
@wineee
wineee force-pushed the agent/developer/dddab10db858 branch 2 times, most recently from 2859f51 to ef6ffd6 Compare September 20, 2026 07:52
wineee and others added 2 commits September 24, 2026 11:09
Add ext-background-effect-v1 (blur) protocol server-side support:

- Vendored wlroots C implementation in waylib/src/server/wlroots_extra/
  based on wlroots MR 5304 (wlr_surface_synced + wlr_addon pattern)
- Qt wrapper WBackgroundEffectManagerV1 in waylib/src/server/protocols/
- Integration in Helper: register manager, hook blur state into
  SurfaceWrapper via setBlur() on surface commit
- Delete the obsolete test_window_bg example and add test_window_blur

PMS: TASK-395091
Complete the ext-background-effect-v1 data path from protocol state to
the actual blur rendering:

- waylib: add WBackgroundEffectManagerV1::surfaceBlurRegion(WSurface *)
  returning the committed blur region as a QRegion (pixman conversion
  via the existing WTools::fromPixmanRegion)
- SurfaceWrapper: add QRegion blurRegion property (+ QML-friendly
  blurRegionRects); blur() is now true when either the personalization
  path or a non-empty protocol region requests it; drop
  syncBackgroundEffectBlur which reached into the wlroots C API and
  degraded the region to a bool
- Helper: sync blur region from the waylib API on surface commit
- QML: Blur effect supports the protocol region; the blurred layer is
  re-drawn clipped to each region rect, and rects touching a window
  edge inherit the window corner radius (region ∩ rounded shape)
- tests: end-to-end protocol test (capabilities, double-buffered
  region set/keep/NULL/re-enable/destroy, background_effect_exists)
  and a server-side functional test
- waylib: serve an inert xdg_output instead of asserting when
  get_xdg_output races an output that is not yet registered in the
  output layout (aborts the whole compositor otherwise)

PMS: TASK-395091
@deepin-wm
deepin-wm force-pushed the agent/developer/dddab10db858 branch from ef6ffd6 to bd102e1 Compare September 24, 2026 04:53
The SPDX Year Range Checker requires modified files to carry the
current year in their copyright range.
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