Skip to content

fix: Window size not correctly restored after maximisation#3169

Merged
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
JWWTSL:master
Apr 16, 2026
Merged

fix: Window size not correctly restored after maximisation#3169
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
JWWTSL:master

Conversation

@JWWTSL
Copy link
Copy Markdown
Contributor

@JWWTSL JWWTSL commented Apr 10, 2026

Log: During window maximisation, when saveSize() is triggered by the widthChanged/heightChanged signals, the screen dimensions override the previously saved normal window dimensions; furthermore, width()/height() use a ‘strictly greater than’ condition, causing the minimum boundary values to be incorrectly judged as invalid.

pms: bug-353601

Summary by Sourcery

Ensure the control center window restores to its correct normal size instead of screen size after maximisation and hiding, and accept minimum configured sizes as valid.

Bug Fixes:

  • Prevent maximised or fullscreen window dimensions from overwriting the saved normal window size when size change signals fire.
  • Avoid saving window dimensions when the window is hidden or its state is being reset, ensuring only visible, non-maximised sizes are persisted.
  • Treat configured width and height at the minimum thresholds as valid values when restoring the window size.

Log: During window maximisation, when `saveSize()` is triggered by the `widthChanged`/`heightChanged` signals, the screen dimensions override the previously saved normal window dimensions; furthermore, `width()`/`height()` use a ‘strictly greater than’ condition, causing the minimum boundary values to be incorrectly judged as invalid.

pms: bug-353601
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures the control center window only persists its normal, visible size (not maximized/fullscreen or hidden states) and correctly treats configured minimum width/height as valid values, improving restoration of window size after maximization.

Sequence diagram for saving window size during maximize and restore

sequenceDiagram
  actor User
  participant QWindow
  participant DccManager
  participant DConfig

  User->>QWindow: maximize()
  QWindow-->>DccManager: widthChanged
  QWindow-->>DccManager: heightChanged
  DccManager->>DccManager: saveSize()
  DccManager->>QWindow: windowStates()
  DccManager->>QWindow: isVisible()
  DccManager-->>DConfig: return (do not save) when maximized or hidden

  QWindow-->>DccManager: windowStateChanged
  DccManager->>DccManager: saveSize()
  DccManager->>QWindow: windowStates()
  DccManager->>QWindow: isVisible()
  DccManager-->>DConfig: return (still maximized)

  User->>QWindow: showNormal()
  QWindow-->>DccManager: windowStateChanged
  DccManager->>DccManager: saveSize()
  DccManager->>QWindow: windowStates()
  DccManager->>QWindow: isVisible()
  DccManager->>QWindow: width()
  DccManager->>QWindow: height()
  DccManager->>DConfig: setValue(WidthConfig, width)
  DccManager->>DConfig: setValue(HeightConfig, height)

  User->>DccManager: show()
  DccManager->>DConfig: value(WidthConfig), value(HeightConfig)
  DccManager-->>QWindow: apply restored normal size
Loading

Updated class diagram for DccManager window sizing logic

classDiagram
  class DConfig {
    + bool isValid() const
    + QVariant value(QString key) const
    + void setValue(QString key, QVariant value)
  }

  class QWindow {
    + void show()
    + void showNormal()
    + bool isVisible() const
    + Qt_WindowStates windowStates() const
    + int width() const
    + int height() const
    + void installEventFilter(QObject* filter)
  }

  class DccManager {
    - QWindow* m_window
    - DConfig* m_dconfig
    + void setMainWindow(QWindow* window)
    + void loadModules(bool async, QStringList dirs)
    + int width() const
    + int height() const
    + int sidebarWidth() const
    + void show()
    + bool isIndicatorShown(QString cmd) const
    + void saveSize()
    + void handleScreenAdded(QScreen* screen)
  }

  DccManager --> QWindow : manages
  DccManager --> DConfig : persists_size_and_state
Loading

File-Level Changes

Change Details Files
Persist window size only when the window is visible and in a normal (non-maximized, non-fullscreen) state, and ensure state changes also trigger size persistence.
  • Connect QWindow::windowStateChanged to DccManager::saveSize so that state transitions can affect when size is saved.
  • In saveSize(), early-return if the config backend is invalid before reading or writing any values.
  • In saveSize(), compute window maximized/fullscreen state and visibility up front, and skip saving when the window is hidden or maximized/fullscreen to avoid persisting screen-sized dimensions.
  • Remove redundant isValid() guard around config writes now that validation is performed earlier, and always write width/height when conditions permit.
src/dde-control-center/dccmanager.cpp
Adjust logic for restoring persisted window size so that configured minimum boundary values are accepted as valid sizes.
  • Update width() to treat a stored width equal to the minimum (520) as valid by using a >= comparison instead of >.
  • Update height() to treat a stored height equal to the minimum (400) as valid by using a >= comparison instead of >.
src/dde-control-center/dccmanager.cpp
Minor behavior/readability tweak in show() around window visibility handling.
  • Insert a blank line between the null-check and the visibility/state logic in show() for clearer separation of concerns; runtime behavior is unchanged.
src/dde-control-center/dccmanager.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

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 reviewed your changes and they look great!


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.

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL, mhduiy

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

@JWWTSL
Copy link
Copy Markdown
Contributor Author

JWWTSL commented Apr 16, 2026

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot bot commented Apr 16, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 965e1e5 into linuxdeepin:master Apr 16, 2026
16 of 19 checks passed
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