Skip to content

fix(xwayland): sync active prelaunch stacking on handoff - #1216

Open
LFRon wants to merge 1 commit into
linuxdeepin:masterfrom
LFRon:fix/xwayland-stack-order
Open

fix(xwayland): sync active prelaunch stacking on handoff#1216
LFRon wants to merge 1 commit into
linuxdeepin:masterfrom
LFRon:fix/xwayland-stack-order

Conversation

@LFRon

@LFRon LFRon commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Prelaunch wrappers can already be active when their managed XWayland surface is attached. Because the activated wrapper does not change, the normal activation path does not raise the new native X11 window. Treeland then reports the app as active while X11 input can remain stacked behind another window.

Before exposing the real surface, raise both the Treeland item and native X11 window. Limit this to active managed surfaces so inactive and override-redirect windows are unaffected.

Log: 修复XWayland预启动窗口切换后点击穿透的问题

Influence: XWayland预启动Splash切换到真实窗口时的堆叠顺序

Summary by Sourcery

Synchronize stacking for active prelaunch XWayland surfaces when handing off from the prelaunch wrapper to the mapped native window.

Bug Fixes:

  • Fix active prelaunch XWayland windows remaining behind other windows when their real X11 surface is mapped.
  • Ensure active managed XWayland surfaces raise both the Treeland and native X11 stacking orders during splash-to-surface handoff.

Enhancements:

  • Track X11 map and unmap state and defer stacking synchronization until wlroots completes map handling, while excluding inactive and override-redirect surfaces.

@LFRon
LFRon marked this pull request as ready for review July 29, 2026 03:09
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LFRon

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 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.

Sorry @LFRon, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Synchronizes stacking between Treeland’s prelaunch wrapper and the native XWayland window when the real surface takes over, ensuring active managed XWayland windows are raised correctly during splash transition.

Sequence diagram for synchronized XWayland prelaunch stacking on splash transition

sequenceDiagram
    participant SurfaceWrapper
    participant WXWaylandSurface
    participant TreelandItem as Treeland_surfaceItem
    participant X11 as Native_X11_stack

    SurfaceWrapper->>SurfaceWrapper: completeSplashTransition(targetImplicitSize)
    SurfaceWrapper->>TreelandItem: m_decoration->stackBefore(m_surfaceItem)
    alt [m_isActivated && m_type == Type::XWayland]
        SurfaceWrapper->>WXWaylandSurface: qobject_cast<WXWaylandSurface *>(m_shellSurface)
        alt [xwaylandSurface && !xwaylandSurface->isBypassManager()]
            SurfaceWrapper->>SurfaceWrapper: stackToLast()
            SurfaceWrapper->>WXWaylandSurface: restack(nullptr, XCB_STACK_MODE_ABOVE)
            WXWaylandSurface->>X11: apply restack above
        end
    end
    SurfaceWrapper->>TreelandItem: m_surfaceItem->setVisible(true)
    SurfaceWrapper->>TreelandItem: m_prelaunchSplash->setVisible(false)
Loading

File-Level Changes

Change Details Files
Synchronize stacking of active managed XWayland windows with their prelaunch wrappers during splash-to-real-surface transition so the native X11 window is raised correctly.
  • Add activation and type guard to only affect active XWayland surfaces during splash transition completion.
  • Cast shell surface to WXWaylandSurface and skip processing for bypass-manager (override-redirect) windows.
  • Invoke wrapper stackToLast() to raise the Treeland item when the real surface attaches.
  • Call WXWaylandSurface::restack with XCB_STACK_MODE_ABOVE to raise the native X11 window in the X11 stack.
  • Log a debug message when active prelaunch XWayland stacking is synchronized.
src/surface/surfacewrapper.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

@deepin-ci-robot

Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@LFRon

LFRon commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@zzxyb 大佬, 我那个Xwayland修复分支的两个提交其实是互相独立的, 没有一定的commit顺序就是(

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from 76fa5ee to e4cab5c Compare July 29, 2026 08:50
@zzxyb
zzxyb requested review from wineee and zzxyb July 29, 2026 09:50

@zzxyb zzxyb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@LFRon

LFRon commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

我看看着这段逻辑和 https://github.com/linuxdeepin/treeland/blob/master/src/seat/helper.cpp#L2715 有重合

我没backport全, 我明天完整backport一下

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from e4cab5c to 566a47f Compare July 29, 2026 15:36
@LFRon
LFRon marked this pull request as draft July 29, 2026 15:36
@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch 2 times, most recently from cb3218e to 21a1e78 Compare July 30, 2026 07:34
@LFRon
LFRon marked this pull request as ready for review July 30, 2026 07:35

@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.

Sorry @LFRon, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from 21a1e78 to c2063fb Compare July 30, 2026 07:46
@deepin-bot

deepin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.17
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1229

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from c2063fb to c6ae5a5 Compare July 31, 2026 05:59
@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch 2 times, most recently from 356ad2b to 684ca76 Compare August 13, 2026 12:56
@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.18
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1286

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch 4 times, most recently from 1941335 to 5990fa8 Compare August 20, 2026 15:03
@deepin-bot

deepin-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.9.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1312

@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from 5990fa8 to 3e15e3c Compare August 21, 2026 14:18
A prelaunch wrapper may already be active when its managed XWayland surface is attached. Waylib's user event handler runs before wlroots handles MapNotify, and wlroots initially restacks the managed X11 window below. Raising it during the Splash handoff can therefore be overwritten, leaving Treeland's active window visually on top while X11 input targets an older window underneath.

Track X11 MapNotify and UnmapNotify state in WXWaylandSurface, then emit a queued completion signal after wlroots has handled the map. Defer the active prelaunch wrapper's one-shot Treeland and native X11 stack synchronization until that point, preserve stale work across temporary deactivation, retry it when the wrapper is reactivated, cancel it on lifecycle changes, and exclude proxy and override-redirect surfaces.

Log: 修复XWayland预启动窗口切换后点击穿透的问题

Influence: XWayland预启动Splash切换到真实窗口时的堆叠顺序
@LFRon
LFRon force-pushed the fix/xwayland-stack-order branch from 3e15e3c to 7fc6992 Compare August 22, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants