fix: 修复任务栏各种无法唤醒和显示错位问题

任务栏无法唤醒基本都是因为监听的屏幕区域没有在屏幕大小和坐标发生变化的时候及时更新信息,
显示错位是因为动画完成后内部有些变量未更新导致的,

Log: 修复任务栏隐藏后切换位置或者调整屏幕无法唤起和显示到屏幕外部的问题
Bug: https://pms.uniontech.com/zentao/bug-view-34468.html
Bug: https://pms.uniontech.com/zentao/bug-view-34467.html
Bug: https://pms.uniontech.com/zentao/bug-view-34458.html
Bug: https://pms.uniontech.com/zentao/bug-view-34454.html
Bug: https://pms.uniontech.com/zentao/bug-view-34444.html
Bug: https://pms.uniontech.com/zentao/bug-view-34437.html
Bug: https://pms.uniontech.com/zentao/bug-view-34340.html
Bug: https://pms.uniontech.com/zentao/bug-view-33718.html
Bug: https://pms.uniontech.com/zentao/bug-view-33693.html
Bug: https://pms.uniontech.com/zentao/bug-view-32854.html
Bug: https://pms.uniontech.com/zentao/bug-view-32849.html
Bug: https://pms.uniontech.com/zentao/bug-view-32830.html
This commit is contained in:
范朋程 2020-06-21 17:51:23 +08:00
parent 5cb2778bdb
commit ea67db4aa6
3 changed files with 134 additions and 104 deletions

View File

@ -691,6 +691,9 @@ void DockSettings::monitorAdded(const QString &path)
connect(inter, &MonitorInter::YChanged, mon, &Monitor::setY);
connect(inter, &MonitorInter::WidthChanged, mon, &Monitor::setW);
connect(inter, &MonitorInter::HeightChanged, mon, &Monitor::setH);
// 当屏幕的大小或者坐标信息发生变化后,需要更新一下监听区域.防止无法唤醒任务栏
connect(inter, &MonitorInter::XChanged, this, &DockSettings::requestUpdateRegionWatch);
connect(inter, &MonitorInter::YChanged, this, &DockSettings::requestUpdateRegionWatch);
connect(inter, &MonitorInter::WidthChanged, this, &DockSettings::requestUpdateRegionWatch);
connect(inter, &MonitorInter::HeightChanged, this, &DockSettings::requestUpdateRegionWatch);
connect(inter, &MonitorInter::MmWidthChanged, mon, &Monitor::setMmWidth);
@ -843,9 +846,7 @@ void DockSettings::calculateRelativePos(Monitor *s1, Monitor *s2)
s1->dockPosition().rightDock = false;
s2->dockPosition().leftDock = false;
} else {
if (!s1->isPrimary())
s1->dockPosition().rightDock = false;
if (!s2->isPrimary())
s2->dockPosition().leftDock = false;
}
}
@ -857,9 +858,7 @@ void DockSettings::calculateRelativePos(Monitor *s1, Monitor *s2)
s1->dockPosition().leftDock = false;
s2->dockPosition().rightDock = false;
} else {
if (!s1->isPrimary())
s1->dockPosition().leftDock = false;
if (!s2->isPrimary())
s2->dockPosition().rightDock = false;
}
}
@ -874,9 +873,7 @@ void DockSettings::calculateRelativePos(Monitor *s1, Monitor *s2)
s1->dockPosition().bottomDock = false;
s2->dockPosition().topDock = false;
} else {
if (!s1->isPrimary())
s1->dockPosition().bottomDock = false;
if (!s2->isPrimary())
s2->dockPosition().topDock = false;
}
}
@ -888,9 +885,7 @@ void DockSettings::calculateRelativePos(Monitor *s1, Monitor *s2)
s1->dockPosition().topDock = false;
s2->dockPosition().bottomDock = false;
} else {
if (!s1->isPrimary())
s1->dockPosition().topDock = false;
if (!s2->isPrimary())
s2->dockPosition().bottomDock = false;
}
}

View File

@ -32,6 +32,20 @@ namespace Utils {
return nullptr;
}
// 判断坐标是否位于屏幕边缘
inline bool onScreenEdge(const QPoint &point) {
for (QScreen *screen : qApp->screens()) {
const QRect r { screen->geometry() };
QRect rect { r.topLeft(), r.size() * screen->devicePixelRatio() };
if ( point.y() == screen->geometry().y()+screen->geometry().height()
|| point.x() == screen->geometry().x()+screen->geometry().width()) {
return true;
}
}
return false;
}
inline QScreen * screenAtByScaled(const QPoint &point) {
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(point)) {

41
frame/window/mainwindow.cpp Executable file → Normal file
View File

@ -187,8 +187,6 @@ MainWindow::MainWindow(QWidget *parent)
}
connect(m_panelShowAni, &QVariantAnimation::valueChanged, [ this ](const QVariant & value) {
qDebug() << m_mainPanel->width();
if (m_panelShowAni->state() != QPropertyAnimation::Running)
return;
// dock的宽度或高度值
@ -213,7 +211,7 @@ MainWindow::MainWindow(QWidget *parent)
m_mainPanel->move(0, 0);
QWidget::move(windowRect.right() - val, windowRect.top());
break;
default: break;
Q_UNREACHABLE();
}
if (m_dockPosition == Dock::Top || m_dockPosition == Dock::Bottom) {
@ -224,7 +222,6 @@ MainWindow::MainWindow(QWidget *parent)
});
connect(m_panelHideAni, &QVariantAnimation::valueChanged, [ this ](const QVariant & value) {
if (m_panelHideAni->state() != QPropertyAnimation::Running)
return;
@ -299,6 +296,8 @@ void MainWindow::launch()
setVisible(true);
updatePanelVisible();
resetPanelEnvironment();
// 用于更新界面的布局方向
m_shadowMaskOptimizeTimer->start();
});
}
@ -441,7 +440,8 @@ void MainWindow::compositeChanged()
const int duration = 0;
#endif
m_panelHideAni->setDuration(duration);
//TODO 隐藏动画暂时不设置时间了,后面动画相关的代码需要进行重构,目前的逻辑太复杂,不容易分析和定位问题
m_panelHideAni->setDuration(0);
m_panelShowAni->setDuration(duration);
m_shadowMaskOptimizeTimer->start();
@ -733,7 +733,7 @@ void MainWindow::expand()
return;
}
if (startValue >= endValue)
if (startValue > endValue)
return;
m_panelShowAni->setStartValue(startValue);
@ -897,7 +897,7 @@ void MainWindow::resizeMainPanelWindow()
case Dock::Right:
m_dragWidget->setGeometry(0, 0, DRAG_AREA_SIZE, height());
break;
default: break;
Q_UNREACHABLE();
}
}
@ -974,10 +974,22 @@ void MainWindow::onRegionMonitorChanged(int x, int y, const QString &key)
if (m_registerKey != key)
return;
// 同一个坐标,只响应一次
static QPoint lastPos(0, 0);
if (lastPos == QPoint(x, y)) {
return;
}
lastPos = QPoint(x, y);
QScreen *screen = Utils::screenAt(QPoint(x, y));
if (!screen)
return;
if (Utils::onScreenEdge(QPoint(x, y))) {
qDebug() << "screen not changed";
return;
}
if (screen->name() == m_settings->currentDockScreen()) {
if (m_settings->hideMode() == KeepShowing)
return;
@ -997,12 +1009,22 @@ void MainWindow::onRegionMonitorChanged(int x, int y, const QString &key)
int screenHeight = screen->size().height();
switch (m_dockPosition) {
case Dock::Top:
case Dock::Bottom:
case Dock::Bottom: {
// 特殊处理arm机器上setFixedSize响应有点慢能看到明显的界面从短变长的过程
const int height = this->height();
setFixedHeight(0);
setFixedWidth(screenWidth);
setFixedHeight(height);
}
break;
case Dock::Left:
case Dock::Right:
case Dock::Right: {
// 同上
const int width = this->width();
setFixedWidth(0);
setFixedHeight(screenHeight);
setFixedWidth(width);
}
break;
}
expand();
@ -1024,7 +1046,6 @@ void MainWindow::updateRegionMonitorWatch()
QList<QRect> screensRect = m_settings->monitorsRect();
QList<MonitRect> monitorAreas;
const qreal scale = devicePixelRatioF();
int val = 3;
int x, y, w, h;