diff --git a/src/libkwineffects/kwinoffscreenquickview.cpp b/src/libkwineffects/kwinoffscreenquickview.cpp index db084297fb..bea0f3f0e1 100644 --- a/src/libkwineffects/kwinoffscreenquickview.cpp +++ b/src/libkwineffects/kwinoffscreenquickview.cpp @@ -12,12 +12,14 @@ #include "kwinglutils.h" #include "logging_p.h" +#include #include #include #include #include #include #include +#include #include #include @@ -74,6 +76,9 @@ public: Qt::TouchPointStates touchState; QTouchDevice *touchDevice; + ulong lastMousePressTime = 0; + Qt::MouseButton lastMousePressButton = Qt::NoButton; + void releaseResources(); void updateTouchState(Qt::TouchPointState state, qint32 id, const QPointF& pos); @@ -270,13 +275,25 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e) case QEvent::MouseMove: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: { QMouseEvent *me = static_cast(e); const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos()); QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers()); QCoreApplication::sendEvent(d->m_view, &cloneEvent); e->setAccepted(cloneEvent.isAccepted()); + + if (e->type() == QEvent::MouseButtonPress) { + const ulong doubleClickInterval = static_cast(QGuiApplication::styleHints()->mouseDoubleClickInterval()); + const bool doubleClick = (me->timestamp() - d->lastMousePressTime < doubleClickInterval) && me->button() == d->lastMousePressButton; + d->lastMousePressTime = me->timestamp(); + d->lastMousePressButton = me->button(); + if (doubleClick) { + d->lastMousePressButton = Qt::NoButton; + QMouseEvent doubleClickEvent(QEvent::MouseButtonDblClick, me->localPos(), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QCoreApplication::sendEvent(d->m_view, &doubleClickEvent); + } + } + return; } case QEvent::HoverEnter: diff --git a/src/plugins/kdecorations/aurorae/src/aurorae.cpp b/src/plugins/kdecorations/aurorae/src/aurorae.cpp index 152735608d..23426ae2cb 100644 --- a/src/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/src/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -517,13 +516,6 @@ void Decoration::mousePressEvent(QMouseEvent *event) { if (m_view) { m_view->forwardMouseEvent(event); - if (event->button() == Qt::LeftButton) { - if (!m_doubleClickTimer.hasExpired(QGuiApplication::styleHints()->mouseDoubleClickInterval())) { - QMouseEvent dc(QEvent::MouseButtonDblClick, event->localPos(), event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); - m_view->forwardMouseEvent(&dc); - } - } - m_doubleClickTimer.invalidate(); } KDecoration2::Decoration::mousePressEvent(event); } @@ -532,9 +524,6 @@ void Decoration::mouseReleaseEvent(QMouseEvent *event) { if (m_view) { m_view->forwardMouseEvent(event); - if (event->isAccepted() && event->button() == Qt::LeftButton) { - m_doubleClickTimer.start(); - } } KDecoration2::Decoration::mouseReleaseEvent(event); } diff --git a/src/plugins/kdecorations/aurorae/src/aurorae.h b/src/plugins/kdecorations/aurorae/src/aurorae.h index fba4f8614c..5feb7c4aec 100644 --- a/src/plugins/kdecorations/aurorae/src/aurorae.h +++ b/src/plugins/kdecorations/aurorae/src/aurorae.h @@ -77,7 +77,6 @@ private: QString m_themeName; KWin::OffscreenQuickView *m_view; - QElapsedTimer m_doubleClickTimer; }; class ThemeProvider : public KDecoration2::DecorationThemeProvider