← easystroke

Add option to move the cursor back to the original position

850980a72287ceb07b1122f8df95d50e3e2a84e8 · Thomas Jaeger · Jan 23, 2010 15:31

+23 −2 · 5 files changed

  • gui.glade +12 −0
  • main.cc +3 −0
  • prefdb.cc +4 −1
  • prefdb.h +2 −1
  • prefs.cc +2 −0
diff --git a/gui.glade b/gui.glade
index d980346..039532d 100644
--- a/gui.glade
+++ b/gui.glade
@@ -999,6 +999,18 @@
                             <property name="position">3</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkCheckButton" id="check_move_back">
+                            <property name="label" translatable="yes">Move the cursor back to the original position after each gesture</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/main.cc b/main.cc
index 2b6ba11..1d94e2a 100644
--- a/main.cc
+++ b/main.cc
@@ -811,6 +811,9 @@ protected:
 	virtual void release(guint b, RTriple e) {
 		RStroke s = finish(0);
 
+		if (prefs.move_back.get() && !current_dev->absolute)
+			current_dev->fake_motion(orig->x, orig->y);
+
 		if (stroke_action) {
 			(*stroke_action)(s);
 			return parent->replace_child(NULL);
diff --git a/prefdb.cc b/prefdb.cc
index a6286a6..7f463b6 100644
--- a/prefdb.cc
+++ b/prefdb.cc
@@ -53,7 +53,8 @@ PrefDB::PrefDB() :
 	scroll_invert(true),
 	scroll_speed(2.0),
 	tray_feedback(false),
-	show_osd(true)
+	show_osd(true),
+	move_back(false)
 {}
 
 template<class Archive> void PrefDB::serialize(Archive & ar, const unsigned int version) {
@@ -128,6 +129,8 @@ template<class Archive> void PrefDB::serialize(Archive & ar, const unsigned int
 	ar & scroll_speed.unsafe_ref();
 	ar & tray_feedback.unsafe_ref();
 	ar & show_osd.unsafe_ref();
+	if (version < 16) return;
+	ar & move_back.unsafe_ref();
 }
 
 void PrefDB::timeout() {
diff --git a/prefdb.h b/prefdb.h
index 810153b..942a53b 100644
--- a/prefdb.h
+++ b/prefdb.h
@@ -133,12 +133,13 @@ public:
 	PrefSource<double> scroll_speed;
 	PrefSource<bool> tray_feedback;
 	PrefSource<bool> show_osd;
+	PrefSource<bool> move_back;
 
 	void init();
 	virtual void timeout();
 };
 
-BOOST_CLASS_VERSION(PrefDB, 15)
+BOOST_CLASS_VERSION(PrefDB, 16)
 
 extern PrefDB prefs;
 
diff --git a/prefs.cc b/prefs.cc
index f575adf..4916ec9 100644
--- a/prefs.cc
+++ b/prefs.cc
@@ -269,6 +269,8 @@ Prefs::Prefs() {
 	new Check(prefs.scroll_invert, "check_scroll_invert");
 	new Adjustment<double>(prefs.scroll_speed, "adjustment_scroll_speed");
 
+	new Check(prefs.move_back, "check_move_back");
+
 	new Check(prefs.show_osd, "check_osd");
 
 	Gtk::Button *bbutton, *add_exception, *remove_exception, *add_extra, *edit_extra, *remove_extra;