Code

Fix #338838, in which zooming and panning with the middle mouse button made Inkscape...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Mon, 9 Mar 2009 20:19:01 +0000 (20:19 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Mon, 9 Mar 2009 20:19:01 +0000 (20:19 +0000)
src/display/sp-canvas.cpp
src/knot.cpp
src/knotholder.cpp
src/node-context.cpp
src/nodepath.cpp

index 75a1f4e63cba6fe9fd28831353be38144952ca68..0f9e883ed4376a9db8a9bb700b9e282d381010b2 100644 (file)
@@ -1681,6 +1681,7 @@ gboolean sp_canvas_snap_watchdog_callback(gpointer data)
                dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
        }
 
+       ((GdkEventMotion *)canvas->watchdog_event)->time = GDK_CURRENT_TIME;
        emit_event(canvas, canvas->watchdog_event);
        gdk_event_free(canvas->watchdog_event);
        canvas->watchdog_event = NULL;
index cf1a3e9444e8194d15a97b9c16a6b8973b5cbfaf..fab622bbd10ac3d190d149947e3c6c4801ded606 100644 (file)
@@ -285,7 +285,9 @@ void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y,
  */
 static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot)
 {
-    g_assert(knot != NULL);
+       static bool snap_delay_temporarily_active = false;
+
+       g_assert(knot != NULL);
     g_assert(SP_IS_KNOT(knot));
 
     /* Run client universal event handler, if present */
@@ -316,6 +318,10 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
             if (event->button.button == 1 && !knot->desktop->event_context->space_panning) {
                 Geom::Point const p = knot->desktop->w2d(Geom::Point(event->button.x, event->button.y));
                 sp_knot_start_dragging(knot, p, (gint) event->button.x, (gint) event->button.y, event->button.time);
+                if (knot->desktop->canvas->context_snap_delay_active == false) {
+                                       sp_canvas_set_snap_delay_active(knot->desktop->canvas, true);
+                                       snap_delay_temporarily_active = true;
+                               }
                 consumed = TRUE;
             }
             break;
@@ -347,6 +353,13 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
                     grabbed = FALSE;
                     moved = FALSE;
                     consumed = TRUE;
+
+                    if (snap_delay_temporarily_active) {
+                       if (knot->desktop->canvas->context_snap_delay_active == true) {
+                               sp_canvas_set_snap_delay_active(knot->desktop->canvas, false);
+                       }
+                                               snap_delay_temporarily_active = false;
+                                       }
                 }
             }
             break;
@@ -411,7 +424,6 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
 
             grabbed = FALSE;
             moved = FALSE;
-
             consumed = TRUE;
             break;
        case GDK_KEY_PRESS: // keybindings for knot
@@ -435,6 +447,10 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
                     }
                     grabbed = FALSE;
                     moved = FALSE;
+                    if (snap_delay_temporarily_active) {
+                                               sp_canvas_set_snap_delay_active(knot->desktop->canvas, false);
+                                               snap_delay_temporarily_active = false;
+                                       }
                     break;
                default:
                     consumed = FALSE;
@@ -568,7 +584,7 @@ void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state)
 }
 
 /**
- * Move knot to new position, without emitting a MOVED signal. 
+ * Move knot to new position, without emitting a MOVED signal.
  */
 void sp_knot_moveto(SPKnot *knot, Geom::Point const &p)
 {
index eaf5658f803dc5cb3db25637b366875dfece1846..60c1f80846a965a882401b4a16846771644573c9 100644 (file)
@@ -139,7 +139,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state)
 {
     if (this->dragging == false) {
        this->dragging = true;
-       sp_canvas_set_snap_delay_active(desktop->canvas, true);
+       //sp_canvas_set_snap_delay_active(desktop->canvas, true);
     }
 
        // this was a local change and the knotholder does not need to be recreated:
@@ -165,7 +165,7 @@ void
 KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/)
 {
        this->dragging = false;
-       sp_canvas_set_snap_delay_active(desktop->canvas, false);
+       //sp_canvas_set_snap_delay_active(desktop->canvas, false);
 
        if (this->released) {
         this->released(this->item);
index 57af59bd4d8ce945d5d313c692936b5b05a8b480..f40d1b7fc79927f69c76674e3e46ec790e45cb14 100644 (file)
@@ -116,8 +116,6 @@ sp_node_context_dispose(GObject *object)
        SPNodeContext *nc = SP_NODE_CONTEXT(object);
     SPEventContext *ec = SP_EVENT_CONTEXT(object);
 
-    sp_canvas_set_snap_delay_active(ec->desktop->canvas, false);
-
     ec->enableGrDrag(false);
 
     nc->sel_changed_connection.disconnect();
@@ -175,8 +173,6 @@ sp_node_context_setup(SPEventContext *ec)
     nc->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
 
     ec->shape_editor->update_statusbar();
-
-    sp_canvas_set_snap_delay_active(ec->desktop->canvas, true);
 }
 
 static void
@@ -298,7 +294,8 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 if (!(event->button.state & GDK_SHIFT_MASK)) {
                     if (!nc->drag) {
                         if (se->has_nodepath() && selection->single() /* && item_over */) {
-                            // save drag origin
+                               sp_canvas_set_snap_delay_active(desktop->canvas, true);
+                               // save drag origin
                             bool over_stroke = se->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
                             //only dragging curves
                             if (over_stroke) {
@@ -412,7 +409,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     if (over_stroke || nc->added_node) {
                         switch (event->type) {
                             case GDK_BUTTON_RELEASE:
-                                if (event->button.state & GDK_CONTROL_MASK && event->button.state & GDK_MOD1_MASK) {
+                               if (event->button.state & GDK_CONTROL_MASK && event->button.state & GDK_MOD1_MASK) {
                                     //add a node
                                     se->add_node_near_point();
                                 } else {
@@ -428,11 +425,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                     }
                                     desktop->updateNow();
                                 }
+                               sp_canvas_set_snap_delay_active(desktop->canvas, false);
                                 break;
                             case GDK_2BUTTON_PRESS:
                                 //add a node
                                 se->add_node_near_point();
                                 nc->added_node = true;
+                                sp_canvas_set_snap_delay_active(desktop->canvas, false);
                                 break;
                             default:
                                 break;
@@ -450,16 +449,16 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 }
             }
             if (event->type == GDK_BUTTON_RELEASE) {
-                event_context->xp = event_context->yp = 0;
+               event_context->xp = event_context->yp = 0;
                 if (event->button.button == 1) {
-                    Geom::OptRect b = Inkscape::Rubberband::get(desktop)->getRectangle();
+                       Geom::OptRect b = Inkscape::Rubberband::get(desktop)->getRectangle();
 
                     if (se->hits_curve() && !event_context->within_tolerance) { //drag curve
                         se->finish_drag();
                     } else if (b && !event_context->within_tolerance) { // drag to select
                         se->select_rect(*b, event->button.state & GDK_SHIFT_MASK);
                     } else {
-                        if (!(nc->rb_escaped)) { // unless something was cancelled
+                        if (!(nc->rb_escaped)) { // unless something was canceled
                             if (se->has_selection())
                                 se->deselect();
                             else
index 318649e5ff53b6e81f94ad1dece7c538ea4a2d7a..51d4b9bef8395d07f904881e1644e3a589934948 100644 (file)
@@ -3587,7 +3587,7 @@ static void node_grabbed(SPKnot *knot, guint state, gpointer data)
     }
 
     n->is_dragging = true;
-    sp_canvas_set_snap_delay_active(n->subpath->nodepath->desktop->canvas, true);
+    //sp_canvas_set_snap_delay_active(n->subpath->nodepath->desktop->canvas, true);
     // Reconstruct and store the location of the mouse pointer at the time when we started dragging (needed for snapping)
     n->subpath->nodepath->drag_origin_mouse = knot->grabbed_rel_pos + knot->drag_origin;
 
@@ -3605,7 +3605,7 @@ static void node_ungrabbed(SPKnot */*knot*/, guint /*state*/, gpointer data)
 
    n->dragging_out = NULL;
    n->is_dragging = false;
-   sp_canvas_set_snap_delay_active(n->subpath->nodepath->desktop->canvas, false);
+   //sp_canvas_set_snap_delay_active(n->subpath->nodepath->desktop->canvas, false);
    n->subpath->nodepath->drag_origin_mouse = Geom::Point(NR_HUGE, NR_HUGE);
    sp_canvas_end_forced_full_redraws(n->subpath->nodepath->desktop->canvas);