From dc4deeab0cde24a8ef01d6d07ed51ddadcaf7398 Mon Sep 17 00:00:00 2001 From: Hombre Date: Wed, 18 Aug 2010 23:36:10 +0200 Subject: [PATCH] Bug corrected in the curve editor (pen device handling) --- rtgui/mycurve.cc | 89 ++++++++++++++++++++++-------------------------- rtgui/mycurve.h | 1 - 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/rtgui/mycurve.cc b/rtgui/mycurve.cc index 0f0287913..5c4e4e662 100644 --- a/rtgui/mycurve.cc +++ b/rtgui/mycurve.cc @@ -30,10 +30,9 @@ MyCurve::MyCurve () : listener(NULL), activeParam(-1), bghistvalid(false) { prevInnerHeight = innerHeight; grab_point = -1; lit_point = -1; - source = GDK_SOURCE_MOUSE; buttonPressed = false; - set_extension_events(Gdk::EXTENSION_EVENTS_CURSOR); + set_extension_events(Gdk::EXTENSION_EVENTS_ALL); add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK); signal_event().connect( sigc::mem_fun(*this, &MyCurve::handleEvents) ); @@ -298,10 +297,6 @@ bool MyCurve::handleEvents (GdkEvent* event) { buttonPressed = true; add_modal_grab (); - //we memorize the input device that "pressed" in the editor, to avoid unwanted motion from - //an eventual mouse connected - source = event->button.device->source; - // get the pointer position getCursorPosition(event); findClosestPoint(); @@ -339,52 +334,50 @@ bool MyCurve::handleEvents (GdkEvent* event) { case Gdk::BUTTON_RELEASE: if (curve.type!=Parametric) { - if (event->button.device->source == source) { - if (event->button.button == 1) { - buttonPressed = false; - } - if (!buttonPressed) { - /* get the pointer position */ - getCursorPosition(event); - findClosestPoint(); + if (event->button.button == 1) { + buttonPressed = false; + } + if (!buttonPressed) { + /* get the pointer position */ + getCursorPosition(event); + findClosestPoint(); - remove_modal_grab (); - int previous_lit_point = lit_point; - /* delete inactive points: */ - itx = curve.x.begin(); - ity = curve.y.begin(); - for (src = dst = 0; src < num; ++src) - if (curve.x[src] >= 0.0) { - curve.x[dst] = curve.x[src]; - curve.y[dst] = curve.y[src]; - ++dst; - ++itx; - ++ity; - } - if (dst < src) { - curve.x.erase (itx, curve.x.end()); - curve.y.erase (ity, curve.y.end()); - if (curve.x.size() <= 0) { - curve.x.push_back (0); - curve.y.push_back (0); - interpolate (); - draw (lit_point); - } + remove_modal_grab (); + int previous_lit_point = lit_point; + /* delete inactive points: */ + itx = curve.x.begin(); + ity = curve.y.begin(); + for (src = dst = 0; src < num; ++src) + if (curve.x[src] >= 0.0) { + curve.x[dst] = curve.x[src]; + curve.y[dst] = curve.y[src]; + ++dst; + ++itx; + ++ity; } - if (distanceX <= minDistanceX) { - new_type = CSMove; - lit_point = closest_point; - } - else { - new_type = CSPlus; - lit_point = -1; - } - if (lit_point != previous_lit_point) + if (dst < src) { + curve.x.erase (itx, curve.x.end()); + curve.y.erase (ity, curve.y.end()); + if (curve.x.size() <= 0) { + curve.x.push_back (0); + curve.y.push_back (0); + interpolate (); draw (lit_point); - grab_point = -1; - retval = true; - notifyListener (); + } } + if (distanceX <= minDistanceX) { + new_type = CSMove; + lit_point = closest_point; + } + else { + new_type = CSPlus; + lit_point = -1; + } + if (lit_point != previous_lit_point) + draw (lit_point); + grab_point = -1; + retval = true; + notifyListener (); } } break; diff --git a/rtgui/mycurve.h b/rtgui/mycurve.h index 9630b22ba..21b2b8b12 100644 --- a/rtgui/mycurve.h +++ b/rtgui/mycurve.h @@ -80,7 +80,6 @@ class MyCurve : public Gtk::DrawingArea { double distanceY; // Y distance from the cursor to the closest point double ugpX; // unclamped grabbed point X coordinate in the graph double ugpY; // unclamped grabbed point Y coordinate in the graph - GdkInputSource source; std::vector point; std::vector upoint; std::vector lpoint;