fix(window): preserve maximized state when reactivating minimized window - #612
Merged
pengfeixx merged 1 commit intoApr 28, 2026
Merged
Conversation
Save window state before activation and skip saveWindowSize/moveToCenter for maximized windows, restore showMaximized in fallback path. 保存窗口状态再激活,最大化窗口跳过 saveWindowSize 和 moveToCenter, fallback 分支恢复 showMaximized。 Log: 修复最小化后再次打开丢失最大化状态的问题 PMS: BUG-355967 Influence: 修复最大化后最小化再打开窗口状态变为普通窗口的问题。
pengfeixx
force-pushed
the
fix/window-state-maximized
branch
from
April 28, 2026 07:22
ea8d131 to
590818e
Compare
deepin pr auto review这段代码主要对 1. 语法逻辑审查当前逻辑分析:
潜在逻辑问题:
改进建议: 2. 代码质量审查优点:
改进建议:
3. 代码性能审查
4. 代码安全审查
综合改进后的代码示例针对上述提到的“闪烁”问题,建议对 路径 B 的逻辑做微调: void WindowManager::activeOrInitWindow()
{
QMutexLocker locker(&_mutex);
if (window != nullptr) {
// 记录窗口当前是否处于最大化状态
bool wasMaximized = window->windowState() & Qt::WindowMaximized;
// 优先尝试通过 Dock 接口激活
if (Q_LIKELY(Utils::activeWindow(window->winId()))) {
qCDebug(app) << "Window activated via Utils::activeWindow, winId:" << window->winId();
if (!wasMaximized) {
window->saveWindowSize();
Dtk::Widget::moveToCenter(window);
} else {
qCDebug(app) << "Window was maximized, skipping saveWindowSize and moveToCenter";
}
} else {
// 备用激活方案
qCDebug(app) << "Fallback activation method for winId:" << window->winId();
// 根据状态选择显示方式,避免 show() 和 showMaximized() 同时调用导致的闪烁
if (wasMaximized) {
window->showMaximized();
} else {
setWindow(window); // 假设 setWindow 仅在非最大化时需要设置特定属性
window->show();
}
window->raise();
window->activateWindow();
qCDebug(app) << "Window shown and activated, wasMaximized:" << wasMaximized;
}
window->openjsPage(curr_app_name_, curr_title_name_);
qCDebug(app) << "openjsPage end";
}
}总结这段 diff 的修改方向是正确的,有效地解决了最大化窗口在激活时可能出现的布局问题。主要建议集中在优化备用激活路径中的显示逻辑,以消除潜在的界面闪烁,并更新相关注释以反映代码的最新意图。 |
lzwind
approved these changes
Apr 28, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Save window state before activation and skip saveWindowSize/moveToCenter for maximized windows, restore showMaximized in fallback path.
保存窗口状态再激活,最大化窗口跳过 saveWindowSize 和 moveToCenter,
fallback 分支恢复 showMaximized。
Log: 修复最小化后再次打开丢失最大化状态的问题
PMS: BUG-355967
Influence: 修复最大化后最小化再打开窗口状态变为普通窗口的问题。