#include <QDragEnterEvent>
#include <QPainter>
#include <QScrollBar>
+#include <QTimer>
#include <boost/bind.hpp>
#include <boost/current_function.hpp>
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;
}
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()));
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);
}
/// 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
* emits an 'int' action.
*/
void adjustViewWithScrollBar(int action = 0);
- ///
+ /// timer to limit triple clicks
void doubleClickTimeout();
private: