summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/connector-context.cpp8
-rw-r--r--src/display/sp-canvas.cpp24
-rw-r--r--src/display/sp-canvas.h8
3 files changed, 40 insertions, 0 deletions
diff --git a/src/connector-context.cpp b/src/connector-context.cpp
index cceea8267..93db0f844 100644
--- a/src/connector-context.cpp
+++ b/src/connector-context.cpp
@@ -279,6 +279,10 @@ sp_connector_context_setup(SPEventContext *ec)
if (prefs_get_int_attribute("tools.connector", "selcue", 0) != 0) {
ec->enableSelectionCue();
}
+
+ // Make sure we see all enter events for canvas items,
+ // even if a mouse button is depressed.
+ dt->canvas->gen_all_enter_events = true;
}
@@ -298,6 +302,10 @@ sp_connector_context_finish(SPEventContext *ec)
}
cc_clear_active_shape(cc);
cc_clear_active_conn(cc);
+
+ // Restore the default event generating behaviour.
+ SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
+ desktop->canvas->gen_all_enter_events = false;
}
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 1c1171d35..b1ed7d3d2 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -960,6 +960,9 @@ sp_canvas_init (SPCanvas *canvas)
canvas->need_repick = TRUE;
+ // See comment at in sp-canvas.h.
+ canvas->gen_all_enter_events = false;
+
canvas->tiles=NULL;
canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
canvas->tileH=canvas->tileV=0;
@@ -1251,10 +1254,22 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
static int
pick_current_item (SPCanvas *canvas, GdkEvent *event)
{
+ int button_down;
double x, y;
int retval = FALSE;
+ if (canvas->gen_all_enter_events == false) {
+ // If a button is down, we'll perform enter and leave events on the
+ // current item, but not enter on any other item. This is more or
+ // less like X pointer grabbing for canvas items.
+ //
+ button_down = canvas->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
+ GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
+
+ if (!button_down) canvas->left_grabbed_item = FALSE;
+ }
+
/* Save the event in the canvas. This is used to synthesize enter and
* leave events in case the current item changes. It is also used to
* re-pick the current item if the current one gets deleted. Also,
@@ -1342,6 +1357,15 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
canvas->in_repick = FALSE;
}
+ if (canvas->gen_all_enter_events == false) {
+ // new_current_item may have been set to NULL during the call to
+ // emit_event() above
+ if ((canvas->new_current_item != canvas->current_item) && button_down) {
+ canvas->left_grabbed_item = TRUE;
+ return retval;
+ }
+ }
+
/* Handle the rest of cases */
canvas->left_grabbed_item = FALSE;
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index a9bf2e4c3..86522870a 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -161,6 +161,14 @@ struct SPCanvas {
/* For use by internal pick_current_item() function */
unsigned int in_repick : 1;
+ // In most tools Inkscape only generates enter and leave events
+ // on the current item, but no other enter events if a mouse button
+ // is depressed -- see function pick_current_item(). Some tools
+ // may wish the canvas to generate to all enter events, (e.g., the
+ // connector tool). If so, they may temporarily set this flag to
+ // 'true'.
+ bool gen_all_enter_events;
+
int rendermode;
NR::Rect getViewbox() const;