-
Notifications
You must be signed in to change notification settings - Fork 58
fix: prevent dock screen switch if any popup is showing #1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
41dd695 to
c902e01
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark 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 |
c902e01 to
38f7150
Compare
include minisize luancher, tray plugin popup and tray menu fix: prevent dock screen switch if any popup is showing Pms: BUG-288701
38f7150 to
0f7ca3d
Compare
deepin pr auto review这段代码主要是为了在 Dock(任务栏)切换屏幕时,检查是否存在弹窗或临时的子窗口(Transient Child Window)。如果存在,则阻止屏幕切换,并强制显示 Dock。 以下是对这段代码的审查意见,涵盖语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码建议结合以上建议,代码可以优化如下: // 定义常量
static constexpr int kScreenSwitchDelayMs = 200;
void DockHelper::enterScreen(QScreen *screen)
{
if (!screen) {
return;
}
// Do not switch screen if any popup/transient child window is showing
// 使用 std::any_of 或范围 for 循环,保持逻辑清晰
bool hasActivePopup = false;
for (auto isVisible : m_transientChildShows) {
if (isVisible) {
hasActivePopup = true;
break;
}
}
if (hasActivePopup) {
// 安全检查 parent
if (auto p = qobject_cast<DockParentType*>(parent())) { // 替换 DockParentType 为实际父类类型
p->setHideState(Show);
}
return;
}
// 使用 weak_ptr 或者在回调中再次验证 screen 有效性(如果 QScreen 支持的话)
// 这里假设 QScreen 生命周期由系统管理,相对安全
QTimer::singleShot(kScreenSwitchDelayMs, [this, screen]() {
// 再次检查 screen 是否依然有效(可选,视具体业务逻辑而定)
if (!screen) return;
if (auto p = qobject_cast<DockParentType*>(parent())) {
p->setDockScreen(screen);
p->setHideState(Show);
}
});
}总结这段代码逻辑基本正确,能够解决“弹窗存在时不切换屏幕”的需求。主要改进点在于:
|
include minisize luancher, tray plugin popup and tray menu
fix: prevent dock screen switch if any popup is showing
Pms: BUG-288701