mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复点击图标不显示弹窗的问题
现象:在ZHAOXIN设备上出现点击音量、网络插件大概率不出现弹窗。 原因:DRegionMonitor::buttonRelease和Qt的MouseRelease事件顺序不可控,会导致在显示了弹窗之后又把它隐藏了。 处理方案:在显示弹窗后添加一个10ms的延时,不处理buttonRelease事件。 Log: Bug: https://pms.uniontech.com/zentao/bug-view-109423.html Influence: 鼠标左键点击托盘插件的场景,观察弹窗的显示和隐藏。 Change-Id: I7266d64699da51f2f453bbce5b2b71be555132fd
This commit is contained in:
parent
2ee4b0c25d
commit
5a00e46e1a
@ -36,7 +36,8 @@ DWIDGET_USE_NAMESPACE
|
|||||||
DockPopupWindow::DockPopupWindow(QWidget *parent)
|
DockPopupWindow::DockPopupWindow(QWidget *parent)
|
||||||
: DArrowRectangle(ArrowBottom, parent),
|
: DArrowRectangle(ArrowBottom, parent),
|
||||||
m_model(false),
|
m_model(false),
|
||||||
m_regionInter(new DRegionMonitor(this))
|
m_regionInter(new DRegionMonitor(this)),
|
||||||
|
m_enableMouseRelease(true)
|
||||||
{
|
{
|
||||||
setMargin(0);
|
setMargin(0);
|
||||||
m_wmHelper = DWindowManagerHelper::instance();
|
m_wmHelper = DWindowManagerHelper::instance();
|
||||||
@ -94,15 +95,26 @@ void DockPopupWindow::show(const QPoint &pos, const bool model)
|
|||||||
if (m_model) {
|
if (m_model) {
|
||||||
m_regionInter->registerRegion();
|
m_regionInter->registerRegion();
|
||||||
}
|
}
|
||||||
|
blockButtonRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockPopupWindow::show(const int x, const int y)
|
void DockPopupWindow::show(const int x, const int y)
|
||||||
{
|
{
|
||||||
m_lastPoint = QPoint(x, y);
|
m_lastPoint = QPoint(x, y);
|
||||||
|
blockButtonRelease();
|
||||||
|
|
||||||
DArrowRectangle::show(x, y);
|
DArrowRectangle::show(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockPopupWindow::blockButtonRelease()
|
||||||
|
{
|
||||||
|
// 短暂的不处理鼠标release事件,防止出现刚显示又被隐藏的情况
|
||||||
|
m_enableMouseRelease = false;
|
||||||
|
QTimer::singleShot(10, this, [this] {
|
||||||
|
m_enableMouseRelease = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void DockPopupWindow::hide()
|
void DockPopupWindow::hide()
|
||||||
{
|
{
|
||||||
if (m_regionInter->registered())
|
if (m_regionInter->registered())
|
||||||
@ -153,6 +165,9 @@ void DockPopupWindow::onGlobMouseRelease(const QPoint &mousePos, const int flag)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(m_model);
|
Q_ASSERT(m_model);
|
||||||
|
|
||||||
|
if (!m_enableMouseRelease)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!((flag == DRegionMonitor::WatchedFlags::Button_Left) ||
|
if (!((flag == DRegionMonitor::WatchedFlags::Button_Left) ||
|
||||||
(flag == DRegionMonitor::WatchedFlags::Button_Right))) {
|
(flag == DRegionMonitor::WatchedFlags::Button_Right))) {
|
||||||
return;
|
return;
|
||||||
|
@ -58,6 +58,7 @@ protected:
|
|||||||
void showEvent(QShowEvent *e);
|
void showEvent(QShowEvent *e);
|
||||||
void enterEvent(QEvent *e);
|
void enterEvent(QEvent *e);
|
||||||
bool eventFilter(QObject *o, QEvent *e);
|
bool eventFilter(QObject *o, QEvent *e);
|
||||||
|
void blockButtonRelease();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onGlobMouseRelease(const QPoint &mousePos, const int flag);
|
void onGlobMouseRelease(const QPoint &mousePos, const int flag);
|
||||||
@ -70,6 +71,7 @@ private:
|
|||||||
|
|
||||||
DRegionMonitor *m_regionInter;
|
DRegionMonitor *m_regionInter;
|
||||||
DWindowManagerHelper *m_wmHelper;
|
DWindowManagerHelper *m_wmHelper;
|
||||||
|
bool m_enableMouseRelease;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOCKPOPUPWINDOW_H
|
#endif // DOCKPOPUPWINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user