Whoops. Well, do you want to have a quick look at the attached patch
anyway? (This supersedes the previous one.) I made some slightly more
extensive changes than you did and did it in a slightly different way.
Much of that was motivated by some trouble I had with the "/1.5" setting
on my machine. My double click time is set quite short, and it ends up
being quite difficult for me to triple click. It seems to me that if you
can click, then click again in 0.3 seconds (say) to get a double click,
then you'd want to be able to click again in 0.3 seconds to get a triple
click. I think the "/1.5" may have been motivated by a desire to have
the selection of the word happen without too much delay. But that is
resolved by this version, since LFUN_MOUSE_DOUBLE is called from
mouseDoubleClickEvent, not from the timeout.

I also simplified the double_click class a bit and made the code for the
various mouse events more uniform. Some of them were using double_click
to get information about mouse events instead of simply using the mouse
event itself.

Richard


Jürgen Spitzmüller wrote:
> Richard Heck wrote:
>   
>> Also at bugzilla....
>>     
>
> Erm, I just fixed that (r17588).
>
> Jürgen
>   


-- 
==================================================================
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: frontends/qt4/GuiWorkArea.C
===================================================================
--- frontends/qt4/GuiWorkArea.C	(revision 17593)
+++ 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,28 +423,18 @@
 	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);
 }
 
 
Index: frontends/qt4/GuiWorkArea.h
===================================================================
--- frontends/qt4/GuiWorkArea.h	(revision 17593)
+++ 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,7 @@
 	* emits an 'int' action.
 	*/
 	void adjustViewWithScrollBar(int action = 0);
-	///
+	/// timer to limit triple clicks
 	void doubleClickTimeout();
 
 private:

Reply via email to