mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
optimize global mouse area event
Change-Id: I06dfd555daf8d9a433028baacd204459daf99d7e
This commit is contained in:
parent
bb3068904d
commit
314015a175
Notes:
Deepin Code Review
2016-08-26 09:46:32 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Fri, 26 Aug 2016 09:46:32 +0000 Reviewed-on: https://cr.deepin.io/15593 Project: dde/dde-dock Branch: refs/heads/master
@ -16,7 +16,6 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
|
||||
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||
|
||||
connect(m_acceptDelayTimer, &QTimer::timeout, this, &DockPopupWindow::accept);
|
||||
connect(m_mouseInter, &DBusXMouseArea::ButtonRelease, this, &DockPopupWindow::globalMouseRelease);
|
||||
}
|
||||
|
||||
DockPopupWindow::~DockPopupWindow()
|
||||
@ -48,22 +47,16 @@ void DockPopupWindow::show(const QPoint &pos, const bool model)
|
||||
DArrowRectangle::show(pos.x(), pos.y());
|
||||
|
||||
if (!model && !m_mouseAreaKey.isEmpty())
|
||||
{
|
||||
m_mouseInter->UnregisterArea(m_mouseAreaKey);
|
||||
m_mouseAreaKey.clear();
|
||||
}
|
||||
unRegisterMouseEvent();
|
||||
|
||||
if (model && m_mouseAreaKey.isEmpty())
|
||||
m_mouseAreaKey = m_mouseInter->RegisterFullScreen();
|
||||
registerMouseEvent();
|
||||
}
|
||||
|
||||
void DockPopupWindow::hide()
|
||||
{
|
||||
if (!m_mouseAreaKey.isEmpty())
|
||||
{
|
||||
m_mouseInter->UnregisterArea(m_mouseAreaKey);
|
||||
m_mouseAreaKey.clear();
|
||||
}
|
||||
unRegisterMouseEvent();
|
||||
|
||||
DArrowRectangle::hide();
|
||||
}
|
||||
@ -104,6 +97,22 @@ void DockPopupWindow::globalMouseRelease(int button, int x, int y, const QString
|
||||
|
||||
emit accept();
|
||||
|
||||
unRegisterMouseEvent();
|
||||
}
|
||||
|
||||
void DockPopupWindow::registerMouseEvent()
|
||||
{
|
||||
m_mouseAreaKey = m_mouseInter->RegisterFullScreen();
|
||||
connect(m_mouseInter, &DBusXMouseArea::ButtonRelease, this, &DockPopupWindow::globalMouseRelease, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void DockPopupWindow::unRegisterMouseEvent()
|
||||
{
|
||||
if (m_mouseAreaKey.isEmpty())
|
||||
return;
|
||||
|
||||
disconnect(m_mouseInter, &DBusXMouseArea::ButtonRelease, this, &DockPopupWindow::globalMouseRelease);
|
||||
|
||||
m_mouseInter->UnregisterArea(m_mouseAreaKey);
|
||||
m_mouseAreaKey.clear();
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ protected:
|
||||
|
||||
private slots:
|
||||
void globalMouseRelease(int button, int x, int y, const QString &id);
|
||||
void registerMouseEvent();
|
||||
void unRegisterMouseEvent();
|
||||
|
||||
private:
|
||||
using Dtk::Widget::DArrowRectangle::show;
|
||||
|
Loading…
x
Reference in New Issue
Block a user