Could the Qt-ers amongst you try out the attached patch. It gives you 
scrolling behaviour similar to that of the xforms frontend.

Specifically, if you move the mouse cursor above/below the work area, 
you should get 'sensible' scrolling behaviour.

Try it out and let me know.

Angus

ps, Using this on the User Guide will crash eventually and may also 
occasionally 'get stuck' (for me the start of Chapter 2) moving the 
mouse back into the work area and out again fixed that for me. I 
assume that both these bugs are 'PosIterator' related.

A.
Index: src/frontends/qt2/QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.27
diff -u -p -r1.27 QContentPane.C
--- src/frontends/qt2/QContentPane.C	24 Nov 2003 08:26:08 -0000	1.27
+++ src/frontends/qt2/QContentPane.C	29 Nov 2003 21:15:12 -0000
@@ -10,6 +10,11 @@
 
 #include <config.h>
 
+#include "debug.h"
+#include "funcrequest.h"
+
+#include <boost/bind.hpp>
+
 #include "QWorkArea.h"
 #include "QContentPane.h"
 #include "QLyXKeySym.h"
@@ -18,9 +23,6 @@
 #include <qtimer.h>
 #include <qapplication.h>
 
-#include "funcrequest.h"
-
-
 namespace {
 
 /// return the LyX key state from Qt's
@@ -76,8 +78,11 @@ mouse_button::state q_motion_state(Qt::B
 
 QContentPane::QContentPane(QWorkArea * parent)
 	: QWidget(parent, "content_pane", WRepaintNoErase),
-	  wa_(parent), track_scrollbar_(true)
+	  timeout_(200), track_scrollbar_(true), wa_(parent)
 {
+	timeout_.timeout.connect(
+		boost::bind(&QContentPane::timeout_slot, this));
+
 	setFocusPolicy(QWidget::WheelFocus);
 	setFocus();
 	setCursor(ibeamCursor);
@@ -89,6 +94,28 @@ QContentPane::QContentPane(QWorkArea * p
 }
 
 
+namespace {
+
+FuncRequest synthetic_mouse_move_event_;
+int x_old = -1;
+int y_old = -1;
+double scrollbar_value_old = -1.0;
+
+}// namespace anon
+
+
+void QContentPane::timeout_slot()
+{
+	lyxerr << "QContentPane::timeout_slot()" << std::endl;
+	timeout_.start();
+	double const scrollbar_value = wa_->scrollbar_->value();
+	if (scrollbar_value != scrollbar_value_old) {
+		scrollbar_value_old = scrollbar_value;
+		wa_->dispatch(synthetic_mouse_move_event_);
+	}
+}
+
+
 void QContentPane::scrollBarChanged(int val)
 {
 	if (track_scrollbar_)
@@ -107,6 +134,9 @@ void QContentPane::mousePressEvent(QMous
 		return;
 	}
 
+	if (timeout_.running())
+		timeout_.stop();
+
 	FuncRequest cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
 			q_button_state(e->button()));
 	wa_->dispatch(cmd);
@@ -115,6 +145,9 @@ void QContentPane::mousePressEvent(QMous
 
 void QContentPane::mouseReleaseEvent(QMouseEvent * e)
 {
+	if (timeout_.running())
+		timeout_.stop();
+
 	FuncRequest cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
 			q_button_state(e->button()));
 	wa_->dispatch(cmd);
@@ -123,9 +156,27 @@ void QContentPane::mouseReleaseEvent(QMo
 
 void QContentPane::mouseMoveEvent(QMouseEvent * e)
 {
-	FuncRequest cmd
-		(LFUN_MOUSE_MOTION, e->x(), e->y(), q_motion_state(e->state()));
-	wa_->dispatch(cmd);
+	FuncRequest cmd(LFUN_MOUSE_MOTION, e->x() - x(), e->y() - y(),
+			q_motion_state(e->state()));
+
+	bool const above_or_below_workarea =
+		e->y() <= y() || e->y() >= y() + height();
+
+	if (above_or_below_workarea) {
+		if (timeout_.running())
+			return;
+		synthetic_mouse_move_event_ = cmd;
+		timeout_.start();
+	}
+
+	double const scrollbar_value = wa_->scrollbar_->value();
+	if (e->x() != x_old || e->y() != y_old ||
+	    scrollbar_value != scrollbar_value_old) {
+		x_old = e->x();
+		y_old = e->y();
+		scrollbar_value_old = scrollbar_value;
+		wa_->dispatch(cmd);
+	}  	
 }
 
 
Index: src/frontends/qt2/QContentPane.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v
retrieving revision 1.11
diff -u -p -r1.11 QContentPane.h
--- src/frontends/qt2/QContentPane.h	24 Nov 2003 08:26:08 -0000	1.11
+++ src/frontends/qt2/QContentPane.h	29 Nov 2003 21:15:12 -0000
@@ -12,6 +12,11 @@
 #ifndef QCONTENTPANE_H
 #define QCONTENTPANE_H
 
+#ifdef emit
+#undef emit
+#endif
+#include "Timeout.h"
+
 #include <qwidget.h>
 #include <qpixmap.h>
 
@@ -76,6 +81,9 @@ public slots:
 
 	void scrollBarChanged(int);
 private:
+	void timeout_slot();
+	Timeout timeout_;
+
 	///
 	bool track_scrollbar_;
 	/// owning widget

Reply via email to