From 2f5ceb15e4f51d00e0c7f9a04ae34826e9544a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 26 Jul 2013 17:16:19 +0200 Subject: [PATCH] exit cube on doubleclick more natural than (preserved) rmb exit and also for single touch devices REVIEW: 111730 --- effects/cube/cube.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 5e4a8421b7..df01d7c5bb 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include +#include #include #include #include @@ -1948,6 +1949,8 @@ void CubeEffect::windowInputMouseEvent(QEvent* e) return; static QPoint oldpos; + static QElapsedTimer dblClckTime; + static int dblClckCounter(0); if (mouse->type() == QEvent::MouseMove && mouse->buttons().testFlag(Qt::LeftButton)) { const QPoint pos = mouse->pos(); QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); @@ -1991,11 +1994,22 @@ void CubeEffect::windowInputMouseEvent(QEvent* e) else if (mouse->type() == QEvent::MouseButtonPress && mouse->button() == Qt::LeftButton) { oldpos = mouse->pos(); + if (dblClckTime.elapsed() > QApplication::doubleClickInterval()) + dblClckCounter = 0; + if (!dblClckCounter) + dblClckTime.start(); } else if (mouse->type() == QEvent::MouseButtonRelease) { effects->defineCursor(Qt::OpenHandCursor); - if (mouse->button() == Qt::XButton1) { + if (mouse->button() == Qt::LeftButton && ++dblClckCounter == 2) { + dblClckCounter = 0; + if (dblClckTime.elapsed() < QApplication::doubleClickInterval()) { + setActive(false); + return; + } + } + else if (mouse->button() == Qt::XButton1) { if (!rotating && !start) { rotating = true; if (invertMouse)