From 74b889f04fc6b2c72213cd887ad969a30e2aac55 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 10 Sep 2013 00:15:38 +0200 Subject: [PATCH 6/7] locator: Move distance threshold comparison earlier This makes sure we don't emit the LocationUpdated signal when the location change is below the threshold. In gnome-settings-daemon's datetime plugin we're setting the threshold to 50000 m (city level) and aren't interested in small changes within one city. Previously, the signal would be emitted when the user moved to another part within the same city -- due to the changed description from IP geolocation. https://bugs.freedesktop.org/show_bug.cgi?id=69105 --- src/gclue-locator.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gclue-locator.c b/src/gclue-locator.c index edc0f96..ce2e81b 100644 --- a/src/gclue-locator.c +++ b/src/gclue-locator.c @@ -170,8 +170,13 @@ gclue_locator_update_location (GClueLocator *locator, threshold_km = priv->threshold / 1000.0; distance_km = gclue_location_info_get_distance_from (priv->location, location); - if (gclue_location_info_equal (priv->location, location) && - distance_km < threshold_km) { + /* If it's below the threshold, ignore any changes in other properties */ + if (distance_km < threshold_km) { + g_debug ("Location remains unchanged, below distance threshold"); + return; + } + + if (gclue_location_info_equal (priv->location, location)) { g_debug ("Location remains unchanged"); return; } -- 1.8.3.1