index 6d996fbe22a93fd9a495ba1b50b25b1c607e6581..fc68bcfc00a3c6ac304033832b183ab925738eab 100644 (file)
-#define __SP_CANVAS_C__
-
/** \file
* Port of GnomeCanvas for Inkscape needs
*
/** \file
* Port of GnomeCanvas for Inkscape needs
*
#include "helper/sp-marshal.h"
#include <helper/recthull.h>
#include "helper/sp-marshal.h"
#include <helper/recthull.h>
-#include <display/sp-canvas.h>
-#include "display-forward.h"
+#include "display/sp-canvas.h"
+#include "display/sp-canvas-group.h"
#include <2geom/matrix.h>
#include <2geom/matrix.h>
-#include <libnr/nr-convex-hull.h>
+#include "libnr/nr-convex-hull.h"
#include "preferences.h"
#include "inkscape.h"
#include "sodipodi-ctrlrect.h"
#include "preferences.h"
#include "inkscape.h"
#include "sodipodi-ctrlrect.h"
static void sp_canvas_item_dispose (GObject *object);
static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
static void sp_canvas_item_dispose (GObject *object);
static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
-
static int emit_event (SPCanvas *canvas, GdkEvent *event);
static int emit_event (SPCanvas *canvas, GdkEvent *event);
+static int pick_current_item (SPCanvas *canvas, GdkEvent *event);
static guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
static guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
// See comment at in sp-canvas.h.
canvas->gen_all_enter_events = false;
// See comment at in sp-canvas.h.
canvas->gen_all_enter_events = false;
+
+ canvas->drawing_disabled = false;
canvas->tiles=NULL;
canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
canvas->tiles=NULL;
canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) {
item = canvas->grabbed_item;
} else {
if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) {
item = canvas->grabbed_item;
} else {
+ // Make sure that current_item is up-to-date. If a snap indicator was just deleted, then
+ // sp_canvas_item_dispose has been called and there is no current_item specified. We need
+ // that though because otherwise we don't know where to send this event to, leading to a
+ // lost event. We can't wait for idle events to have current_item updated, we need it now!
+ // Otherwise, scrolling when hovering above a pre-snap indicator won't work (for example)
+ // See this bug report: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8
+ if (canvas->need_repick && !canvas->in_repick && event->type == GDK_SCROLL) {
+ // To avoid side effects, we'll only do this for scroll events, because this is the
+ // only thing we want to fix here. An example of a reported side effect is that
+ // otherwise selection of nodes in the node editor by dragging a rectangle using a
+ // tablet will break
+ canvas->need_repick = FALSE;
+ pick_current_item (canvas, (GdkEvent *) event);
+ }
item = canvas->current_item;
}
item = canvas->current_item;
}
retval = emit_event (canvas, &new_event);
}
retval = emit_event (canvas, &new_event);
}
+
+
return retval;
}
return retval;
}
static int
sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
{
static int
sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
{
- int status;
+ int status;
SPCanvas *canvas = SP_CANVAS (widget);
track_latency((GdkEvent *)event);
SPCanvas *canvas = SP_CANVAS (widget);
track_latency((GdkEvent *)event);
return FALSE;
canvas->state = event->state;
return FALSE;
canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
- status = emit_event (canvas, (GdkEvent *) event);
- if (event->is_hint) {
- request_motions(widget->window, event);
- }
+ pick_current_item (canvas, (GdkEvent *) event);
+ status = emit_event (canvas, (GdkEvent *) event);
+ if (event->is_hint) {
+ request_motions(widget->window, event);
+ }
return status;
}
return status;
}
static int
do_update (SPCanvas *canvas)
{
static int
do_update (SPCanvas *canvas)
{
- if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop durring interrupted display!
+ if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop during interrupted display!
+ return TRUE;
+
+ if (canvas->drawing_disabled)
return TRUE;
/* Cause the update if necessary */
return TRUE;
/* Cause the update if necessary */
@@ -2196,6 +2215,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear,
} else {
// scrolling as part of zoom; do nothing here - the next do_update will perform full redraw
}
} else {
// scrolling as part of zoom; do nothing here - the next do_update will perform full redraw
}
+
}
/**
}
/**
@@ -2430,4 +2450,4 @@ void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8
fill-column:99
End:
*/
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :