Skip to content

refactor: move XWayland decoration handling into waylib - #1440

Merged
wineee merged 1 commit into
linuxdeepin:masterfrom
zzxyb:dconfig
Sep 23, 2026
Merged

wineee merged 1 commit into
linuxdeepin:masterfrom
zzxyb:dconfig

Conversation

@zzxyb

@zzxyb zzxyb commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Add WXWayland::windowProperty to centralize XCB window property reads and handle property offsets in the required 32-bit units.

Add WXWaylandSurface::effectiveDecorationsFlags to combine the override-redirect state, decoration flags, and the optional no-titlebar property. Simplify Helper to resolve the session atom and apply the effective decoration state.

Log: move XWayland decoration handling into waylib
PMS: TASK-393779
Influence: Compatible change

Summary by Sourcery

Centralize XWayland window-property and decoration handling in waylib.

Bug Fixes:

  • Correct XCB window-property reads to handle property offsets in 32-bit units.

Enhancements:

  • Move XWayland decoration resolution into waylib and centralize effective decoration handling for bypass-manager state, decoration flags, and optional no-titlebar properties.
  • Simplify Helper decoration updates by consuming the effective decoration state exposed by WXWaylandSurface.

@zzxyb
zzxyb requested review from Groveer and wineee September 23, 2026 06:25
@zzxyb zzxyb added the enhancement New feature or request label Sep 23, 2026
@sourcery-ai

sourcery-ai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Moves XWayland property reads and effective decoration policy into waylib, including correct 32-bit XCB property offsets, while reducing Helper to session-atom resolution and applying the resulting decoration flags.

Sequence diagram for centralized XWayland decoration resolution

sequenceDiagram
    participant Helper
    participant SessionManager
    participant WXWaylandSurface
    participant WXWayland
    participant XCB
    participant SurfaceWrapper

    Helper->>SessionManager: sessionForXWayland(xwayland)
    SessionManager-->>Helper: Session
    Helper->>WXWaylandSurface: effectiveDecorationsFlags(noTitlebarAtom)
    alt bypass manager
        WXWaylandSurface-->>Helper: DecorationsNoBorder | DecorationsNoTitle
    else managed surface
        WXWaylandSurface->>WXWayland: windowProperty(window_id, noTitlebarAtom, XCB_ATOM_CARDINAL)
        WXWayland->>XCB: xcb_get_property(..., offset)
        XCB-->>WXWayland: property reply
        WXWayland-->>WXWaylandSurface: QByteArray
        WXWaylandSurface-->>Helper: effective decoration flags
    end
    Helper->>SurfaceWrapper: setNoTitleBar(flags & DecorationsNoTitle)
    Helper->>SurfaceWrapper: setNoDecoration(flags & DecorationsNoBorder)
Loading

File-Level Changes

Change Details Files
Centralize XCB window-property retrieval in WXWayland with correct property-offset handling.
  • Add a reusable windowProperty API that validates the connection and atom, reads multi-part replies, and advances offsets in 32-bit units.
  • Remove the duplicate property-reading helper from seat code.
waylib/src/server/protocols/wxwayland.cpp
waylib/src/server/protocols/wxwayland.h
src/seat/helper.cpp
Move effective XWayland decoration resolution into WXWaylandSurface.
  • Combine bypass-manager behavior, X11 decoration flags, and the optional no-titlebar CARDINAL property.
  • Expose the effective decoration calculation through the surface API.
waylib/src/server/protocols/wxwaylandsurface.cpp
waylib/src/server/protocols/wxwaylandsurface.h
Simplify Helper decoration updates by consuming the waylib decoration API.
  • Resolve the XWayland session atom once in the update callback.
  • Apply the returned effective flags to title-bar and border state.
src/seat/helper.cpp

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="waylib/src/server/protocols/wxwaylandsurface.cpp" line_range="548-549" />
<code_context>
+
+    auto flags = decorationsFlags();
+    if (noTitlebarAtom != XCB_ATOM_NONE
+        && !xwayland()->windowProperty(handle()->window_id,
+                                       noTitlebarAtom,
+                                       XCB_ATOM_CARDINAL)
+                .isEmpty()) {
</code_context>
<issue_to_address>
**issue (bug_risk):** effectiveDecorationsFlags dereferences xwayland() whenever noTitlebarAtom is non-NONE, so calling it on a WXWaylandSurface constructed with a null WXWayland pointer crashes.

**Triggers:** When a surface is created without an owning WXWayland instance and the caller supplies a no-titlebar atom.

**Suggested fix:** Check that xwayland() is non-null before calling windowProperty, and leave the decoration flags unchanged when it is null.

```suggestion
        && xwayland()
        && !xwayland()->windowProperty(handle()->window_id,
                                       noTitlebarAtom,
```
</issue_to_address>

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

Comment thread waylib/src/server/protocols/wxwaylandsurface.cpp
Add WXWayland::windowProperty to centralize XCB window property
reads and handle property offsets in the required 32-bit units.

Add WXWaylandSurface::effectiveDecorationsFlags to combine the
override-redirect state, decoration flags, and the optional no-titlebar
property. Simplify Helper to resolve the session atom and apply the
effective decoration state.

Log: move XWayland decoration handling into waylib
PMS: TASK-393779
Influence: Compatible change
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wineee, zzxyb

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

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.

Copilot review overview

🟡 Changes recommended

WXWayland::windowProperty uses byte offsets instead of 32-bit units, potentially truncating multi-reply properties.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Refactors XWayland property and decoration handling into waylib, simplifying Helper.

Changes:

  • Adds centralized XCB window-property access.
  • Adds effective decoration flag resolution.
  • Updates Helper to consume the new decoration state.
File Summary
waylib/​src/​server/​protocols/​wxwaylandsurface.h Declares effective decoration resolution.
waylib/​src/​server/​protocols/​wxwaylandsurface.cpp Computes effective decoration flags.
waylib/​src/​server/​protocols/​wxwayland.h Declares centralized property access.
waylib/​src/​server/​protocols/​wxwayland.cpp Implements XCB property retrieval.
src/​seat/​helper.cpp Uses the effective decoration state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const int length = xcb_get_property_value_length(reply);
data.append(static_cast<const char *>(xcb_get_property_value(reply)), length);
remaining = reply->bytes_after;
offset += length;
@wineee
wineee merged commit f4da734 into linuxdeepin:master Sep 23, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants