feat: recalculate dock window rect on screen geometry change#1591
Merged
wjyrich merged 1 commit intolinuxdeepin:masterfrom May 8, 2026
Merged
feat: recalculate dock window rect on screen geometry change#1591wjyrich merged 1 commit intolinuxdeepin:masterfrom
wjyrich merged 1 commit intolinuxdeepin:masterfrom
Conversation
Connect to screen geometry change signals to ensure the dock panel recalculates its window rectangle when the primary screen position changes. Previously, the dock window geometry would not update when the screen moved, causing display issues. Log: Fixed dock panel not updating position when screen geometry changes Influence: 1. Test dock panel position after changing primary display settings 2. Verify dock window updates when monitor arrangement is modified 3. Test dock behavior with multi-monitor configurations feat: 屏幕几何变化时重新计算停靠栏窗口区域 连接屏幕几何变化信号,确保当主屏位置发生变化时停靠栏能重新计算窗口矩形。 之前屏幕移动时停靠栏窗口几何不会更新,导致显示异常。 Log: 修复屏幕几何变化时停靠栏位置不更新的问题 Influence: 1. 测试更改主显示器设置后停靠栏的位置更新 2. 验证修改显示器排列时停靠栏窗口的响应 3. 测试多显示器配置下停靠栏的行为表现 PMS: TASK-389279
deepin pr auto review这段代码主要是在 1. 语法逻辑审查现状: 潜在问题:
2. 代码质量审查改进建议:
3. 代码性能审查现状:
改进建议:
4. 代码安全审查潜在风险:
5. 改进后的代码建议为了解决上述问题,建议将屏幕监听逻辑封装或完善,处理屏幕切换的情况。以下是改进后的代码示例: // 在头文件 DockPanel.h 中声明槽函数
// private slots:
// void handleScreenChanged(QScreen *screen);
// void onWindowGeometryChanged();
// 在 DockPanel.cpp 中实现
bool DockPanel::init()
{
// ... 其他初始化代码 ...
if (window()) {
// 1. 处理初始屏幕
handleScreenChanged(window()->screen());
// 2. 监听窗口屏幕变化信号
// 注意:使用 UniqueConnection 防止重复连接(如果 init 可能被多次调用)
connect(window(), &QWindow::screenChanged, this, &DockPanel::handleScreenChanged, Qt::UniqueConnection);
rootObject()->installEventFilter(this);
Q_EMIT devicePixelRatioChanged(window()->devicePixelRatio());
}
return true;
}
void DockPanel::handleScreenChanged(QScreen *screen)
{
// 1. 断开旧屏幕的连接(如果有)
// 我们需要存储旧的 QScreen 指针,或者通过某种方式找到它。
// 这里假设我们无法直接获取旧指针,通常的做法是在类成员中保存当前 m_currentScreen。
if (m_currentScreen) {
disconnect(m_currentScreen, &QScreen::geometryChanged, this, &DockPanel::onWindowGeometryChanged);
}
// 2. 更新当前屏幕指针
m_currentScreen = screen;
// 3. 连接新屏幕的信号
if (m_currentScreen) {
connect(m_currentScreen, &QScreen::geometryChanged, this, &DockPanel::onWindowGeometryChanged);
// 4. 屏幕切换后,立即触发一次几何更新,确保状态同步
// 假设 onWindowGeometryChanged 会读取当前 geometry 并更新
QMetaObject::invokeMethod(this, "onWindowGeometryChanged", Qt::QueuedConnection);
}
}6. 总结原代码在简单的场景下可以工作,但在处理多显示器、热插拔显示器或窗口跨屏移动时存在逻辑缺陷(未断开旧连接)。
|
BLumia
approved these changes
May 8, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich 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.
Connect to screen geometry change signals to ensure the dock panel recalculates its window rectangle when the primary screen position changes. Previously, the dock window geometry would not update when the screen moved, causing display issues.
Log: Fixed dock panel not updating position when screen geometry changes
Influence:
feat: 屏幕几何变化时重新计算停靠栏窗口区域
连接屏幕几何变化信号,确保当主屏位置发生变化时停靠栏能重新计算窗口矩形。
之前屏幕移动时停靠栏窗口几何不会更新,导致显示异常。
Log: 修复屏幕几何变化时停靠栏位置不更新的问题
Influence:
PMS: TASK-389279