Also at bugzilla....

The problem seems to have arisen from some changes made during the port
to QT4. I've re-instated some of what was removed---basically, a
timer---and cleaned up a few things as well. In particular, it seems to
me it's not work tracking the location of the original double click.
Rather, I trip the timer if the mouse moves. That allows some
simplification, and it also encouraged me to make the dispatch code more
uniform across the LFUNs.

This is still a little iffy, at least on my system. The triple click
doesn't always seem to take. But it usually does.

Richard

-- 
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto
Index: src/frontends/qt4/GuiWorkArea.C
===================================================================
--- src/frontends/qt4/GuiWorkArea.C	(revision 17581)
+++ src/frontends/qt4/GuiWorkArea.C	(working copy)
@@ -43,6 +43,7 @@
 #include <QDragEnterEvent>
 #include <QPainter>
 #include <QScrollBar>
+#include <QTimer>
 
 #include <boost/bind.hpp>
 #include <boost/current_function.hpp>
@@ -292,8 +293,8 @@
 	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::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,19 +423,21 @@
 	processKeySym(sym, q_key_state(e->modifiers()));
 }
 
+void GuiWorkArea::doubleClickTimeout() {
+	dc_event_.active = false;
+}
 
 void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
 {
 	dc_event_ = double_click(e);
+	//It would really be better if this were made part of
+	//the double click class itself, so that it was set up
+	//by the constructor.
+	QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(doubleClickTimeout()));
 
-	if (!dc_event_.active)
-		return;
-
-	dc_event_.active = false;
-
 	FuncRequest cmd(LFUN_MOUSE_DOUBLE,
-		dc_event_.x, dc_event_.y,
-		q_button_state(dc_event_.state));
+		e->x(), e->y(),	
+		q_button_state(e->button()));
 	dispatch(cmd);
 }
 
Index: src/frontends/qt4/GuiWorkArea.h
===================================================================
--- src/frontends/qt4/GuiWorkArea.h	(revision 17581)
+++ src/frontends/qt4/GuiWorkArea.h	(working copy)
@@ -42,22 +42,18 @@
 /// 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,9 @@
 	* emits an 'int' action.
 	*/
 	void adjustViewWithScrollBar(int action = 0);
-
+	/// timer to limit triple clicks
+	void doubleClickTimeout();
+	
 private:
 	/// The slot connected to SyntheticMouseEvent::timeout.
 	void generateSyntheticMouseEvent();

Reply via email to