]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Polished the "reject zero moves" fix.
authorc vw <dl1ycf@darc.de>
Mon, 8 Mar 2021 08:32:06 +0000 (09:32 +0100)
committerc vw <dl1ycf@darc.de>
Mon, 8 Mar 2021 08:32:06 +0000 (09:32 +0100)
receiver.c

index ef880a8ab782eb66fad486830b5dd84162528920..6774dfc10a841408ec7baaaac21c62771adeed9f 100644 (file)
@@ -142,25 +142,37 @@ gboolean receiver_motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
   int x, y;
   GdkModifierType state;
   RECEIVER *rx=(RECEIVER *)data;
-  // DL1YCF: if !pressed, we may come from the destruction
-  //         of a menu, and should not move the VFO.
-  if(!making_active && pressed) {
+  //
+  // if !pressed, we may come from the destruction
+  // of a menu, and should not move the VFO.
+  //
+  if (!making_active && pressed) {
     gdk_window_get_device_position (event->window,
-                                event->device,
-                                &x,
-                                &y,
-                                &state);
+                                    event->device,
+                                    &x,
+                                    &y,
+                                    &state);
+    //
+    // Sometimes it turned out to be difficult sometimes to "jump" to a
+    // new frequency by just clicking in the panadaper. Futher analysis
+    // showed that there were "moves" with zero offset arriving between
+    // pressing and releasing the mouse button.
+    // (In fact, on my Macintosh I see zillions of moves with zero offset)
+    // Accepting such a "move" between a  "press" and the next "release" event
+    // sets "has_moved" and results in a "VFO drag" instead of a "VFO set".
     //
-    // It turns out to be difficult sometimes to "jump" to a
-    // frequency by just clicking in the panadaper, since the
-    // operating system may report a very small move between
-    // pressing and releasing. Then x and last_x is the same.
+    // So we do the following:
+    // - "moves" with zero offset are always ignored
+    // - the first "move" to be accepted after a "press" must lead us
+    //   at least 2 pixels away from the original position.
     //
     int moved=x-last_x;
-    if (moved != 0) {
-      vfo_move((long long)((float)moved*rx->hz_per_pixel),FALSE);
-      last_x=x;
-      has_moved=TRUE;
+    if (moved) {
+      if (has_moved || move < -1 || move > 1) {
+        vfo_move((long long)((float)moved*rx->hz_per_pixel),FALSE);
+        last_x=x;
+        has_moved=TRUE;
+      }
     }
   }