Skip to content

fix: fullscreen window size reduced by titlebar height#853

Open
glyvut wants to merge 1 commit into
linuxdeepin:masterfrom
glyvut:master
Open

fix: fullscreen window size reduced by titlebar height#853
glyvut wants to merge 1 commit into
linuxdeepin:masterfrom
glyvut:master

Conversation

@glyvut
Copy link
Copy Markdown

@glyvut glyvut commented Apr 30, 2026

Temporarily set the target state before resize() so that
updateTitleBar() updates topPadding correctly (zero for fullscreen).
Restore the original state afterwards so doSetSurfaceState() can
properly track the state transition (e.g. issuing setFullScreen(false)
when exiting fullscreen).

在全屏状态切换时,resize()先于updateTitleBar()执行,导致
resizeSurface()使用了带有标题栏高度的topPadding计算configure
尺寸,客户端收到的全屏尺寸比实际小了标题栏高度。修复方案是在
resize前临时设置目标状态以更新padding,随后恢复原始状态。

Log: 修复全屏窗口尺寸被标题栏高度缩减的bug
PMS: BUG-359605
Issue: Fixes #744
Influence: 全屏窗口现在能正确覆盖整个屏幕,退出全屏时客户端也能正确收到状态变更。

Summary by Sourcery

Bug Fixes:

  • Fix fullscreen windows being resized smaller than the screen by the titlebar height during state transitions.

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut

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

@deepin-ci-robot
Copy link
Copy Markdown

Hi @glyvut. Thanks for your PR. 😃

@deepin-ci-robot
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 30, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts fullscreen state handling during animation readiness so the title bar padding is updated for the target state before resizing, preventing fullscreen windows from being reduced by the title bar height and restoring state/titlebar correctly on failure.

Sequence diagram for SurfaceWrapper onAnimationReady fullscreen padding handling

sequenceDiagram
    participant SurfaceWrapper
    participant SurfaceState
    participant TitleBar
    participant GeometryAnimation

    SurfaceWrapper->>SurfaceWrapper: onAnimationReady()
    SurfaceWrapper->>SurfaceWrapper: Q_ASSERT(m_pendingState != m_surfaceState)
    SurfaceWrapper->>SurfaceWrapper: Q_ASSERT(m_pendingGeometry.isValid())

    SurfaceWrapper->>SurfaceState: originalState = m_surfaceState.value()
    SurfaceWrapper->>SurfaceState: setValueBypassingBindings(m_pendingState)
    SurfaceWrapper->>TitleBar: updateTitleBar()
    SurfaceWrapper->>SurfaceState: setValueBypassingBindings(originalState)

    SurfaceWrapper->>SurfaceWrapper: resize(m_pendingGeometry.size())
    alt resize failed
        SurfaceWrapper->>TitleBar: updateTitleBar()
        SurfaceWrapper->>GeometryAnimation: disconnect(this)
        SurfaceWrapper->>GeometryAnimation: deleteLater()
        SurfaceWrapper->>SurfaceWrapper: m_geometryAnimation = nullptr
    else resize succeeded
        SurfaceWrapper->>SurfaceWrapper: proceed with state transition handling
    end
Loading

Flow diagram for onAnimationReady padding and resize logic

flowchart TD
    A[onAnimationReady called] --> B[Assert m_pendingState != m_surfaceState]
    B --> C[Assert m_pendingGeometry.isValid]
    C --> D[Store originalState = m_surfaceState.value]
    D --> E[Temporarily set m_surfaceState to m_pendingState via setValueBypassingBindings]
    E --> F[updateTitleBar with target state padding]
    F --> G[Restore m_surfaceState to originalState via setValueBypassingBindings]
    G --> H{"resize(m_pendingGeometry.size) succeeds?"}
    H -- No --> I[updateTitleBar to restore titlebar]
    I --> J[disconnect m_geometryAnimation]
    J --> K[deleteLater on m_geometryAnimation]
    K --> L[set m_geometryAnimation to nullptr]
    H -- Yes --> M[Continue normal state transition handling]
Loading

File-Level Changes

Change Details Files
Ensure title bar padding reflects the target fullscreen state before resize so fullscreen geometry is computed without title bar height, and restore state/titlebar correctly if resize fails.
  • Temporarily assign the pending surface state to the current state before resize to let updateTitleBar() recompute top padding for the target state (e.g., fullscreen).
  • Call updateTitleBar() under the temporary target state, then restore the original surface state to keep state transition tracking logic intact.
  • On resize failure, call updateTitleBar() again to restore the title bar appearance consistent with the original state before cleaning up the geometry animation.
src/surface/surfacewrapper.cpp

Assessment against linked issues

Issue Objective Addressed Explanation
#744 Ensure that when launching foot in fullscreen mode (e.g., via foot -F on DRM backend), the window truly covers the entire screen without a bottom gap equal to the titlebar height.

Possibly linked issues


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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Temporarily mutating m_surfaceState around updateTitleBar() is subtle; consider wrapping the state change in a small RAII/scope-guard helper to guarantee restoration even if early returns or additional error paths are added later.
  • Given that updateTitleBar() may emit signals or trigger bindings, it would be helpful to explicitly document that observers must tolerate the brief discrepancy between m_surfaceState and the actual compositor state when this function is called.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Temporarily mutating `m_surfaceState` around `updateTitleBar()` is subtle; consider wrapping the state change in a small RAII/scope-guard helper to guarantee restoration even if early returns or additional error paths are added later.
- Given that `updateTitleBar()` may emit signals or trigger bindings, it would be helpful to explicitly document that observers must tolerate the brief discrepancy between `m_surfaceState` and the actual compositor state when this function is called.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/surface/surfacewrapper.cpp Outdated
Q_ASSERT(m_pendingState != m_surfaceState);
Q_ASSERT(m_pendingGeometry.isValid());

// Temporarily set the target state so that updateTitleBar() can set the
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.

这样解决有些脏了,应该能有更好的解决方案,比如在实际configure size能识别到这种情况

@glyvut glyvut force-pushed the master branch 3 times, most recently from ec9181c to c1515e4 Compare May 6, 2026 09:10
Comment thread src/surface/surfacewrapper.cpp Outdated
Comment on lines +1337 to +1338
}
else if (m_surfaceState == State::Fullscreen) {
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.

合成一行

Comment thread src/surface/surfacewrapper.cpp Outdated
Comment on lines +1327 to +1330
m_recoverPadding = QMarginsF(m_surfaceItem->leftPadding(),
m_surfaceItem->topPadding(),
m_surfaceItem->rightPadding(),
m_surfaceItem->bottomPadding());
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.

只需要在转变为全屏状态的时候存这个值。

Comment on lines +1333 to +1336
m_surfaceItem->setTopPadding(0);
m_surfaceItem->setLeftPadding(0);
m_surfaceItem->setRightPadding(0);
m_surfaceItem->setBottomPadding(0);
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.

可以提取一个匿名函数

Save and clear paddings before resizing to fullscreen state to
ensure the configure size matches the fullscreen geometry. Recover
paddings on resize failure or when exiting fullscreen.

在进入全屏前保存并清除padding,确保配置尺寸与全屏几何匹配。
resize失败或退出全屏时恢复padding。

Log: 修复全屏窗口配置尺寸被标题栏高度缩减的问题
PMS: BUG-359605
Issue: Fixes linuxdeepin#744
Influence: 全屏窗口获得正确的配置尺寸。

if (m_surfaceItem) {
if (m_pendingState == State::Fullscreen) {
m_recoverPadding = QMarginsF(m_surfaceItem->leftPadding(),
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.

不需要保存吧,用 m_normalGeometry

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 9, 2026

TAG Bot

New tag: 0.8.6
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #859

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.

[Bug]: foot全屏启动后窗口底部存在间隙

5 participants