summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-11-16 21:43:27 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-11-18 18:01:39 +0000
commit4928517e27bf261d667eaa4417cecef0a04b3609 (patch)
tree3223de223e2dfbfc6013fae4062149ae8c5b3f50 /src
parentremove hex color defaults from pref skeleton (diff)
downloadinkscape-4928517e27bf261d667eaa4417cecef0a04b3609.tar.gz
inkscape-4928517e27bf261d667eaa4417cecef0a04b3609.zip
Selectively disable motion event compression for specific tools
It was globally disabled in ab71599ea1af1ea5042e35502e9aa722cc4ab51e However most of the time we do not care for intermediate motion events, and forcing to process them only causes unnecessary performance overhead.
Diffstat (limited to 'src')
-rw-r--r--src/display/sp-canvas.cpp1
-rw-r--r--src/ui/tools/calligraphic-tool.cpp2
-rw-r--r--src/ui/tools/pencil-tool.cpp3
-rw-r--r--src/ui/tools/spray-tool.cpp2
-rw-r--r--src/ui/tools/tool-base.cpp17
-rw-r--r--src/ui/tools/tool-base.h2
6 files changed, 26 insertions, 1 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 3a338c53b..88fec767f 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1133,7 +1133,6 @@ void SPCanvas::handle_realize(GtkWidget *widget)
GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
- gdk_window_set_event_compression (window, FALSE);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/useextinput/value", true)) {
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index ac9db6f0d..c7c1c3aa3 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -471,6 +471,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
ret = TRUE;
desktop->canvas->forceFullRedrawAfterInterruptions(3);
+ set_high_motion_precision();
this->is_drawing = true;
this->just_started_drawing = true;
}
@@ -729,6 +730,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate));
desktop->canvas->endForcedFullRedraws();
+ set_high_motion_precision(false);
this->is_drawing = false;
if (this->dragging && event->button.button == 1 && !this->space_panning) {
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index d3e226a84..fd876270d 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -257,6 +257,7 @@ bool PencilTool::_handleButtonPress(GdkEventButton const &bevent) {
break;
}
+ set_high_motion_precision();
this->_is_drawing = true;
}
return ret;
@@ -399,6 +400,8 @@ bool PencilTool::_handleMotionNotify(GdkEventMotion const &mevent) {
bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
bool ret = false;
+ set_high_motion_precision(false);
+
if ( revent.button == 1 && this->_is_drawing && !this->space_panning) {
this->_is_drawing = false;
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 52a8d114d..bc5eac75f 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -1245,6 +1245,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
sp_spray_extinput(this, event);
desktop->canvas->forceFullRedrawAfterInterruptions(3);
+ set_high_motion_precision();
this->is_drawing = true;
this->is_dilating = true;
this->has_dilated = false;
@@ -1341,6 +1342,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
Geom::Point const motion_dt(desktop->w2d(motion_w));
desktop->canvas->endForcedFullRedraws();
+ set_high_motion_precision(false);
this->is_drawing = false;
if (this->is_dilating && event->button.button == 1 && !this->space_panning) {
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index eb2f2119a..0047e32ef 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -1057,6 +1057,23 @@ bool ToolBase::deleteSelectedDrag(bool just_one) {
return FALSE;
}
+/** Enable (or disable) high precision for motion events
+ *
+ * This is intended to be used by drawing tools, that need to process motion events with high accuracy
+ * and high update rate (for example free hand tools)
+ *
+ * With standard accuracy some intermediate motion events might be discarded
+ *
+ * Call this function when an operation that requires high accuracy is started (e.g. mouse button is pressed
+ * to draw a line). Make sure to call it again and restore standard precision afterwards. **/
+void ToolBase::set_high_motion_precision(bool high_precision) {
+ Glib::RefPtr<Gdk::Window> window = desktop->getToplevel()->get_window();
+
+ if (window) {
+ window->set_event_compression(!high_precision);
+ }
+}
+
/**
* Calls virtual set() function of ToolBase.
*/
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index dc68c4b7f..c9c223823 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -232,6 +232,8 @@ protected:
gchar const *const *cursor_shape;
bool sp_event_context_knot_mouseover() const;
+ void set_high_motion_precision(bool high_precision = true);
+
private:
bool _keyboardMove(GdkEventKey const &event, Geom::Point const &dir);
void sp_event_context_set_cursor(GdkCursorType cursor_type);