diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 326f6c8236..766f2189df 100755 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -44,6 +44,7 @@ along with this program. If not, see . #include #include #include +#include #include #include @@ -1946,7 +1947,7 @@ void PresentWindowsEffect::screenCountChanged() ************************************************/ CloseWindowView::CloseWindowView(QWindow *parent) : QQuickView(parent) - , m_armTimer(new QTimer(this)) + , m_armTimer(new QElapsedTimer()) { setFlags(Qt::X11BypassWindowManagerHint); setColor(Qt::transparent); @@ -1956,16 +1957,15 @@ CloseWindowView::CloseWindowView(QWindow *parent) connect(item, SIGNAL(clicked()), SIGNAL(requestClose())); } - // setup the timer - attempt to prevent accidental clicks - m_armTimer->setSingleShot(true); - m_armTimer->setInterval(350); // 50ms until the window is elevated (seen!) and 300ms more to be "realized" by the user. + m_armTimer->restart(); } void CloseWindowView::windowInputMouseEvent(QMouseEvent *e) { if (e->type() == QEvent::MouseMove) { mouseMoveEvent(e); - } else if (m_armTimer->isActive()) { + } else if (!m_armTimer->hasExpired(350)) { + // 50ms until the window is elevated (seen!) and 300ms more to be "realized" by the user. return; } else if (e->type() == QEvent::MouseButtonPress) { mousePressEvent(e); @@ -1978,7 +1978,7 @@ void CloseWindowView::windowInputMouseEvent(QMouseEvent *e) void CloseWindowView::disarm() { - m_armTimer->start(); + m_armTimer->restart(); } void CloseWindowView::hideEvent(QHideEvent *event) diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index 32f0cf37be..a4cb7881eb 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -27,7 +27,7 @@ along with this program. If not, see . #include #include -class QTimer; +class QElapsedTimer; namespace KWin { @@ -46,7 +46,7 @@ protected: void hideEvent(QHideEvent *event); private: - QTimer* m_armTimer; + QScopedPointer m_armTimer; }; /**