diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index 65d6d27191..520cb5a50f 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -292,8 +293,8 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e) if (dc_event_.active && dc_event_ == *e) { dc_event_.active = false; FuncRequest cmd(LFUN_MOUSE_TRIPLE, - dc_event_.x, dc_event_.y, - q_button_state(dc_event_.state)); + e->x(), e->y(), + q_button_state(e->button())); dispatch(cmd); return; } @@ -317,6 +318,8 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e) void GuiWorkArea::mouseMoveEvent(QMouseEvent * e) { + //we kill the triple click if we move + doubleClickTimeout(); FuncRequest cmd(LFUN_MOUSE_MOTION, e->x(), e->y(), q_motion_state(e->buttons())); @@ -420,28 +423,18 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e) processKeySym(sym, q_key_state(e->modifiers())); } - -void GuiWorkArea::doubleClickTimeout() -{ - if (!dc_event_.active) - return; - +void GuiWorkArea::doubleClickTimeout() { dc_event_.active = false; - - FuncRequest cmd(LFUN_MOUSE_DOUBLE, - dc_event_.x, dc_event_.y, - q_button_state(dc_event_.state)); - dispatch(cmd); } - void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e) { dc_event_ = double_click(e); - - // doubleClickInterval() is just too long. - QTimer::singleShot(int(QApplication::doubleClickInterval() / 1.5), - this, SLOT(doubleClickTimeout())); + QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(doubleClickTimeout())); + FuncRequest cmd(LFUN_MOUSE_DOUBLE, + e->x(), e->y(), + q_button_state(e->button())); + dispatch(cmd); } diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 1c126dd825..6f2832a5d8 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -42,22 +42,18 @@ class QLPainter; /// for emulating triple click class double_click { public: - int x; - int y; Qt::MouseButton state; bool active; bool operator==(QMouseEvent const & e) { - return x == e.x() && y == e.y() - && state == e.button(); + return state == e.button(); } double_click() - : x(0), y(0), state(Qt::NoButton), active(false) {} + : state(Qt::NoButton), active(false) {} double_click(QMouseEvent * e) - : x(e->x()), y(e->y()), - state(e->button()), active(true) {} + : state(e->button()), active(true) {} }; /** Qt only emits mouse events when the mouse is being moved, but @@ -155,7 +151,7 @@ public Q_SLOTS: * emits an 'int' action. */ void adjustViewWithScrollBar(int action = 0); - /// + /// timer to limit triple clicks void doubleClickTimeout(); private: