Code

Added compensation factor for time-skew with event latency.
authorjoncruz <joncruz@users.sourceforge.net>
Sat, 26 Jul 2008 08:08:33 +0000 (08:08 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Sat, 26 Jul 2008 08:08:33 +0000 (08:08 +0000)
src/debug/gdk-event-latency-tracker.cpp
src/debug/gdk-event-latency-tracker.h
src/preferences-skeleton.h
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h

index 8e34d2fc2c5a0a64530bf025ea29632e52dbe2d9..6a8a48eb3c28e3f9ed266477bb6a345d37522d3e 100644 (file)
  */
 
 #include "debug/gdk-event-latency-tracker.h"
+#include "prefs-utils.h"
 
 namespace Inkscape {
 namespace Debug {
 
 GdkEventLatencyTracker::GdkEventLatencyTracker()
-: start_seconds(0.0), max_latency(0.0)
+    : start_seconds(0.0), max_latency(0.0), skew(1.0)
 {
     elapsed.stop();
     elapsed.reset();
@@ -31,9 +32,10 @@ boost::optional<double> GdkEventLatencyTracker::process(GdkEvent const *event) {
     if (start_seconds == 0.0) {
         elapsed.start();
         start_seconds = timestamp_seconds;
+        skew = prefs_get_double_attribute_limited("debug.latency", "skew", 1.0, 0.5, 2.0);
         return boost::optional<double>(0.0);
     } else {
-        double const current_seconds = elapsed.elapsed() + start_seconds;
+        double const current_seconds = (elapsed.elapsed() * skew) + start_seconds;
         double delta = current_seconds - timestamp_seconds;
         if (delta < 0.0) {
             start_seconds += -delta;
index 8a22fec8245c376d2ffde994dcb265e49b1462cd..cb04ee035ebdcd6bef45cdec584569f386c94117 100644 (file)
@@ -33,6 +33,7 @@ private:
 
     double start_seconds;
     double max_latency;
+    double skew;
     Glib::Timer elapsed;
 };
 
index 9670a4da55ad74a3ef55c4d32ab53770cf7a678b..7b762f8349ffe7446761f24008efb8bfccdae796 100644 (file)
@@ -388,6 +388,9 @@ static char const preferences_skeleton[] =
 "    <group id = \"server\" name = \"jabber.org\" port = \"5222\" username = \"\" ssl = \"0\"/>\n"
 "    <group id = \"room\" name = \"inkboard\" server = \"gristle.org\"/>\n"
 "  </group>\n"
+"  <group id=\"debug\">\n"
+"    <group id=\"latency\" skew=\"1\"/>\n"
+"  </group>\n"
 "\n"
 "</inkscape>\n";
 
index 455908a063396f554afcc149d4e7a11fe02a19ff..1f9ef051ec5da654995756d06872544704a01234 100644 (file)
@@ -1049,6 +1049,11 @@ void InkscapePreferences::initPageMisc()
     _page_misc.add_line( false, _("Simplification threshold:"), _misc_simpl, "",
                            _("How strong is the Simplify command by default. If you invoke this command several times in quick succession, it will act more and more aggressively; invoking it again after a pause restores the default threshold."), false);
 
+    _misc_latency_skew.init("debug.latency", "skew", 0.5, 2.0, 0.01, 0.10, 1.0, false, false);
+    _page_misc.add_line( false, _("Latency skew:"), _misc_latency_skew, _("(requires restart)"),
+                           _("Factor by which the event clock is skewed from the actual time (0.9766 on some systems)."), false);
+
+
     this->AddPage(_page_misc, _("Misc"), PREFS_PAGE_MISC);
 }
 
index f81ff75d09bbfe057ccef9ddbebc17a4a1311e17..3a0a300a2683d9045483e0f431ff5bbf6dc44d43 100644 (file)
@@ -164,6 +164,7 @@ protected:
     PrefCheckButton _sel_layer_deselects;
 
     PrefSpinButton  _importexport_export, _misc_recent, _misc_simpl;
+    PrefSpinButton  _misc_latency_skew;
     PrefCheckButton _misc_comment, _misc_forkvectors, _misc_scripts;
     PrefCombo       _misc_small_toolbar;
     PrefCombo       _misc_small_secondary;