Skip to content

fix: disable maximize button to prevent flicker - #831

Open
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/agent/aa43b9fb513e
Open

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/agent/aa43b9fb513e

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

dde-cooperation's main window uses setFixedSize(500, 630) to lock its size, but this does not prevent the window manager from maximizing the window — the DTitlebar maximize button remained enabled. When the user maximizes and then restores, the window jumps through multiple sizes (500×630 → fullscreen → 500×630), producing multiple paint events at different sizes that the compositor shows frame-by-frame as flicker. The codebase has no changeEvent/QWindowStateChangeEvent handler to intercept the state transition (confirmed by repo-wide search returning zero hits).

Fix

Disable the maximize button by clearing Qt::WindowMaximizeButtonHint in initTitleBar(), right after obtaining the titlebar and before the isOnlyTransfer branch, so it applies to all modes. This prevents the fixed-size window from being maximized at all, eliminating the size jump at its source. The implementation follows the exact same pattern already used in the isOnlyTransfer branch for disabling the minimize button.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The change adds a single line (setWindowFlags & ~Qt::WindowMaximizeButtonHint) following the established pattern already present in the same function for the minimize button
  • Target area is not a product of a historical bug fix (confirmed via git blame); no existing fix is reverted
  • Zero external callers affected (References=0 in change-safety gather)

Business Impact Scope

  • Main window UI: The maximize button on the dde-cooperation main window title bar will no longer be visible/clickable on Linux
  • onlyTransfer mode: Unchanged — minimize button is still disabled within its branch; maximize button is now also disabled (consistent behavior)
  • Windows platform: Unaffected — has a separate titlebar implementation (mainwindow_p_win.cpp)
  • All other titlebar functionality (menu, refresh button, icon) remains unchanged

Verification Suggestion

Open dde-cooperation and confirm the maximize button is gone from the title bar; verify minimize/close buttons and the settings menu still work normally; verify the window cannot be maximized via double-click on title bar or keyboard shortcuts.


根因分析

dde-cooperation 主窗口使用 setFixedSize(500, 630) 锁定尺寸,但这不能阻止窗口管理器最大化窗口——DTitlebar 最大化按钮仍可点击。用户最大化后还原时,窗口在多个尺寸间跳变(500×630 → 全屏 → 500×630),产生多次不同尺寸的 paint 事件,组合器逐帧展示即闪屏。代码中无 changeEvent/QWindowStateChangeEvent 处理来拦截状态转换(全仓搜索零命中确认)。

修复方案

在 initTitleBar() 中获取 titlebar 后、isOnlyTransfer 分支前,清除 Qt::WindowMaximizeButtonHint 禁用最大化按钮,对所有模式生效。这使固定尺寸窗口无法被最大化,从根源消除尺寸跳变。实现方式与同函数中 isOnlyTransfer 分支已有的禁用最小化按钮模式完全一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 本次改动仅新增一行(setWindowFlags & ~Qt::WindowMaximizeButtonHint),遵循同函数中已有的禁用最小化按钮模式
  • 目标区域非历史 bug 修复产物(git blame 确认),不撤销任何已有修复
  • 无外部调用者受影响(改动安全评估中 References=0)

业务影响范围

  • 主窗口 UI:dde-cooperation 主窗口标题栏最大化按钮在 Linux 平台不再显示/不可点击
  • onlyTransfer 模式:不受影响——最小化按钮在其分支内单独禁用;最大化按钮现已一并禁用(行为一致)
  • Windows 平台:不受影响——有独立的 titlebar 实现(mainwindow_p_win.cpp)
  • 其他标题栏功能(菜单、刷新按钮、图标)保持不变

验证建议

打开 dde-cooperation 确认标题栏最大化按钮已消失;验证最小化/关闭按钮和设置菜单正常工作;验证窗口无法通过双击标题栏或键盘快捷键最大化。

Summary by Sourcery

Prevent the fixed-size Linux main window from being maximized to eliminate resize flicker.

Bug Fixes:

  • Prevent flicker caused by the Linux main window being maximized and restored despite its fixed size.

Enhancements:

  • Disable the Linux main window maximize control while preserving other titlebar actions.

Chores:

  • Update the Linux main window source copyright year range.

@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, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 0.8.9
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pppanghu77

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

1. Root cause: setFixedSize(500,630) does not prevent WM from
   maximizing the window; DTitlebar maximize button remained enabled
2. Fix: disable Qt::WindowMaximizeButtonHint in initTitleBar() so
   the fixed-size window cannot be maximized, eliminating size jumps
3. Impact: maximize button is no longer clickable; minimize button
   behavior unchanged; Windows platform unaffected (separate impl)

Log: Disabled maximize button on fixed-size window to prevent flicker

Influence:
1. Verify maximize button is disabled on Linux main window
2. Verify window still functions normally (settings, refresh, menu)
3. Verify onlyTransfer mode still disables minimize button correctly

fix: 禁用最大化按钮防止固定尺寸窗口闪屏

1. 根因:setFixedSize(500,630) 不能阻止窗口管理器最大化窗口,
   DTitlebar 最大化按钮仍可用
2. 方案:在 initTitleBar() 中禁用 Qt::WindowMaximizeButtonHint,
   使固定尺寸窗口无法被最大化,消除尺寸跳变
3. 影响:最大化按钮不可点击;最小化按钮行为不变;
   Windows 平台不受影响(独立实现)

Log: 禁用固定尺寸窗口的最大化按钮以防止闪屏

Influence:
1. 验证 Linux 主窗口最大化按钮已被禁用
2. 验证窗口其他功能正常(设置、刷新、菜单)
3. 验证 onlyTransfer 模式仍正常禁用最小化按钮

Bug: https://pms.uniontech.com/bug-view-329609.html
@pppanghu77
pppanghu77 force-pushed the agent/agent/aa43b9fb513e branch from 86deee1 to 62d1c8a Compare October 28, 2026 18:17
@pppanghu77
pppanghu77 changed the base branch from master to release/v20 October 28, 2026 18:18
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 98 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交通过在 MainWindowPrivate::initTitleBar() 中调用 setWindowFlags 禁用最大化按钮来修复窗口闪烁问题,并更新了版权年份。代码变更极小且目标明确, 语法正确、逻辑清晰,无安全漏洞,无性能影响。仅建议为新增的 setWindowFlags 调用补充行内注释说明禁用原因,便于后续维护。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改。


2. 代码质量 ✅

评价: 代码结构清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 建议在 setWindowFlags 调用上方添加注释,如: // 禁用最大化按钮,避免窗口闪烁 q->setWindowFlags(q->windowFlags() & ~Qt::WindowMaximizeButtonHint);


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需优化。


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无需安全加固。


💡 改进建议代码示例

// 建议补充行内注释,提升可维护性 void MainWindowPrivate::initTitleBar() {
    bool isOnlyTransfer = qApp->property("onlyTransfer").toBool();
    auto titleBar = q->titlebar();
    // 禁用最大化按钮,避免窗口闪烁
    q->setWindowFlags(q->windowFlags() & ~Qt::WindowMaximizeButtonHint);
    if (!isOnlyTransfer) {
        titleBar->setIcon(QIcon::fromTheme("dde-cooperation"));
    }
}

本报告由 AI 代码审查工具自动生成

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.

2 participants