summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2009-10-12 13:27:29 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2009-10-12 13:27:29 (GMT)
commit09a75f3dd9a005b648111af6373660c0f48e772f (patch)
tree2ac728dfe06493d2a63467374faf16720e910627
parent7a078ab4f9abf814766c310ab41575d89bb622ce (diff)
downloadQt-09a75f3dd9a005b648111af6373660c0f48e772f.zip
Qt-09a75f3dd9a005b648111af6373660c0f48e772f.tar.gz
Qt-09a75f3dd9a005b648111af6373660c0f48e772f.tar.bz2
Implement mouse double clicks for testlite.
-rw-r--r--src/plugins/graphicssystems/testlite/x11util.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp
index e4d3e89..fc442a2 100644
--- a/src/plugins/graphicssystems/testlite/x11util.cpp
+++ b/src/plugins/graphicssystems/testlite/x11util.cpp
@@ -44,6 +44,7 @@
#include <qdebug.h>
#include <QTimer>
+#include <QApplication>
#include "x11util.h"
#include "qwindowsurface_testlite.h"
@@ -385,8 +386,6 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h)
wmProtocolsAtom,
XA_ATOM, 32, PropModeAppend,
(unsigned char *) &wmDeleteWindowAtom, 1);
-
-
}
MyWindow::~MyWindow()
@@ -466,7 +465,25 @@ void MyWindow::setGeometry(int x, int y, int w, int h)
void MyWindow::mousePressEvent(XButtonEvent *e)
{
- windowSurface->handleMouseEvent(QEvent::MouseButtonPress, e);
+ static long prevTime = 0;
+ static Window prevWindow;
+ static int prevX = -999;
+ static int prevY = -999;
+
+ QEvent::Type type = QEvent::MouseButtonPress;
+
+ if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval()
+ && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) {
+ type = QEvent::MouseButtonDblClick;
+ prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time
+ } else {
+ prevTime = e->time;
+ }
+ prevWindow = e->window;
+ prevX = e->x;
+ prevY = e->y;
+
+ windowSurface->handleMouseEvent(type, e);
}
void MyWindow::mouseReleaseEvent(XButtonEvent *e)