Angus Leeming <[EMAIL PROTECTED]> writes: | Where scrolling is set to true in setScrollbarParams (presumably).
This diff actually works quite well, I only have to reduce the timeout a bit. ++ src/frontends/xforms/XWorkArea.C 3 Dec 2002 17:15:55 -0000 @@ -33,6 +33,8 @@ #include <cmath> #include <cctype> +#include <sys/time.h> + // xforms doesn't define this (but it should be in <forms.h>). extern "C" FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *); @@ -312,6 +314,33 @@ void XWorkArea::scroll_cb() } +class Timer { +public: + Timer(){ + timerclear(&tv); + } + Timer & now() { + gettimeofday(&tv, 0); + return *this; + } + Timer & add(int usec) { + tv.tv_usec += usec; + if (tv.tv_usec >= 1000000) { + tv.tv_sec += 1; + tv.tv_usec -= 1000000; + } + return *this; + } + friend bool operator>(Timer const &, Timer const &); +private: + struct timeval tv; +}; + +bool operator>(Timer const & t1, Timer const & t2) +{ + return timercmp(&t1.tv, &t2.tv, >); +} + int XWorkArea::work_area_handler(FL_OBJECT * ob, int event, FL_Coord, FL_Coord, int key, void * xev) @@ -319,6 +348,7 @@ int XWorkArea::work_area_handler(FL_OBJE static int x_old = -1; static int y_old = -1; static double scrollbar_value_old = -1.0; + static Timer timdel; XEvent * ev = static_cast<XEvent*>(xev); XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata); @@ -337,6 +367,7 @@ int XWorkArea::work_area_handler(FL_OBJE if (!ev || ev->xbutton.button == 0) break; // Should really have used xbutton.state lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl; + timdel.now().add(250000); area->dispatch( FuncRequest(LFUN_MOUSE_PRESS, ev->xbutton.x - ob->x, @@ -358,6 +389,11 @@ int XWorkArea::work_area_handler(FL_OBJE #else case FL_DRAG: #endif + if (timdel > Timer().now()) + break; + else + timdel.now().add(250000); + if (!ev || !area->scrollbar) break; if (ev->xmotion.x != x_old || -- Lgb