Skip to content

fix(surface): set maximized on initial surface commit - #1281

Open
zzxyb wants to merge 1 commit into
linuxdeepin:masterfrom
zzxyb:fix
Open

fix(surface): set maximized on initial surface commit#1281
zzxyb wants to merge 1 commit into
linuxdeepin:masterfrom
zzxyb:fix

Conversation

@zzxyb

@zzxyb zzxyb commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Move initial commit handling from WXdgToplevelSurfaceItem to SurfaceWrapper to properly configure window geometry when the client requests maximized or fullscreen state at first commit.

Log: set maximized/fullscreen geometry on initial surface commit PMS: BUG-366199
Influence:

Summary by Sourcery

Handle initial requested fullscreen/maximized state for xdg-toplevel and XWayland surfaces directly in SurfaceWrapper so window geometry and state are correctly set on first commit.

Bug Fixes:

  • Ensure xdg-toplevel windows that request fullscreen or maximized before mapping start in the correct state on initial commit.
  • Fix prelaunch / unmapped surfaces so maximize/fullscreen state transitions are applied consistently before the surface is mapped.
  • Avoid sending an initial xdg_toplevel configure from the surface item when the client has already requested maximized or fullscreen state.

Enhancements:

  • Unify fullscreen and maximized prelaunch handling for XWayland and xdg-toplevel surfaces via shared helpers in SurfaceWrapper.

Move initial commit handling from WXdgToplevelSurfaceItem to
SurfaceWrapper to properly configure window geometry when the
client requests maximized or fullscreen state at first commit.

Log: set maximized/fullscreen geometry on initial surface commit
PMS: BUG-366199
Influence:
@zzxyb
zzxyb requested a review from zccrs August 14, 2026 03:02

@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 @zzxyb, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@sourcery-ai

sourcery-ai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Moves initial xdg-toplevel state handling (maximized/fullscreen) into SurfaceWrapper and ShellHandler so geometry and state are correctly set on the first commit, and generalizes prelaunch/maximize/fullscreen handling for both XWayland and XdgToplevel surfaces while avoiding double-configure on initial commit.

Sequence diagram for initial xdg_toplevel commit state handling

sequenceDiagram
    actor Client
    participant WXdgToplevelSurface as WXdgToplevelSurface
    participant ShellHandler as ShellHandler
    participant SurfaceWrapper as SurfaceWrapper
    participant WSurface as WSurface

    Client->>WXdgToplevelSurface: set requested.maximized/fullscreen
    WXdgToplevelSurface->>ShellHandler: ensureXdgWrapper(surface, title)
    ShellHandler->>SurfaceWrapper: ensureXdgWrapper creates wrapper
    SurfaceWrapper->>SurfaceWrapper: setup()
    SurfaceWrapper->>WSurface: connect surface().commit

    alt surface.isInitialized
        ShellHandler->>SurfaceWrapper: setSurfaceStateDirectly(initialState)
    end

    Client->>WSurface: commit
    WSurface-->>SurfaceWrapper: commit signal

    alt requested.fullscreen
        SurfaceWrapper->>SurfaceWrapper: setSurfaceStateDirectly(Fullscreen)
    else requested.maximized and isMaximizable()
        SurfaceWrapper->>SurfaceWrapper: setSurfaceStateDirectly(Maximized)
    else existing state is Maximized/Fullscreen
        SurfaceWrapper->>SurfaceWrapper: setSurfaceStateDirectly(Normal)
    end
Loading

File-Level Changes

Change Details Files
Handle initial maximized/fullscreen state for xdg-toplevel surfaces inside SurfaceWrapper, including reacting to the first commit before the surface is mapped.
  • Include WXdgToplevelSurface in SurfaceWrapper to allow querying xdg-toplevel requested state.
  • Connect WSurface::commit for XdgToplevel surfaces and, on first commit while unmapped, set fullscreen or maximized via setSurfaceStateDirectly based on requested state.
  • Reset state back to Normal on initial commit if a maximized/fullscreen state was previously applied but the client no longer requests it.
src/surface/surfacewrapper.cpp
Unify and extend prelaunch mapped-state synchronization so both XWayland and XdgToplevel surfaces respect requested fullscreen/maximized state before mapping.
  • Introduce helper lambdas to compute fullscreenRequested and maximizeRequested from either WXWaylandSurface or WXdgToplevelSurface handles.
  • Apply fullscreen/maximized state via setSurfaceStateDirectly for both XWayland and XdgToplevel types when prelaunch mapping is synchronized, guarding with isMaximizable for maximization.
src/surface/surfacewrapper.cpp
Allow maximize/fullscreen transitions on unmapped xdg-toplevel surfaces to set the target state directly instead of going through normal state-change paths.
  • In maximize(), if the surface is an unmapped XdgToplevel and initialized, directly set state to Maximized and return early.
  • In unmaximize(), if the surface is an unmapped XdgToplevel and initialized, directly set state to Normal and return.
  • In enterFullscreen()/leaveFullscreen(), for unmapped initialized XdgToplevel, directly set state to Fullscreen or previous state and return.
src/surface/surfacewrapper.cpp
Apply initial requested fullscreen/maximized state to newly created xdg-toplevel wrappers in ShellHandler so geometry/state are correct even before mapping.
  • When ensuring an Xdg wrapper and the surface is initialized, derive an initial SurfaceWrapper::State from requested.fullscreen and requested.maximized.
  • If the initial state is not Normal, call wrapper->setSurfaceStateDirectly(initialState) before setting up the window menu.
src/core/shellhandler.cpp
Prevent duplicate configure on xdg-toplevel initial commit when the client has already requested maximized or fullscreen.
  • In WXdgToplevelSurfaceItem::onSurfaceCommit(), gate the initial-commit configure path on the xdg_toplevel not having requested.maximized or requested.fullscreen.
  • Leave the existing configure behavior for non-maximized/non-fullscreen initial commits unchanged.
waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.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

@zzxyb
zzxyb requested a review from wineee August 14, 2026 03:20
QObject::connect(m_shellSurface->surface(), &WSurface::mappedChanged,
this,
&SurfaceWrapper::onMappedChanged);
if (m_type == Type::XdgToplevel) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

为什么这次你放 setup 里了, 之前 xwayland 没有?

this,
&SurfaceWrapper::onMappedChanged);
if (m_type == Type::XdgToplevel) {
QObject::connect(m_shellSurface->surface(), &WSurface::commit, this, [this] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

每次commit都要检查一次吗,初始化一次后是不是一个断连?

@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

@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

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.

3 participants