From: Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
Subject: [PATCH] Disable autodownloading when dragging the map

I recently discovered that a recent commit introduce a significant
change on CPU usage.
The commit is 71eff775d86be02173e28421cea7f7d3f5a8344. It offers a
smooth pan when drag&drop, but it introduces a huge amount of tile
requests.

For exemple, when I drag the map, I quickly observe around 600
requests on local tile cache while around 10 requests would be enough.

The matter is, in order to keep a smooth dragging, the viewport is
requested to redraw completly. While doing this, all displayed maps
need to check their local cache. And this, for each X event.

This fix is a temporary one.
A better solution implies certainly a significant refactoring
of display/download.

Signed-off-by: Guilhem Bonnefille <guilhem.bonnefille@gmail.com>

---
 src/vikmapslayer.c |    3 +++
 src/vikwindow.c    |    5 +++++
 src/vikwindow.h    |    1 +
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/vikmapslayer.c b/src/vikmapslayer.c
index 40b3e67..8af939a 100644
--- a/src/vikmapslayer.c
+++ b/src/vikmapslayer.c
@@ -628,6 +628,9 @@ gboolean should_start_autodownload(VikMapsLayer *vml, VikViewport *vvp)
 {
   const VikCoord *center = vik_viewport_get_center ( vvp );
 
+  if (!vik_window_get_pan_move (VIK_GTK_WINDOW_FROM_WIDGET(GTK_WIDGET(vvp))))
+    return FALSE;
+
   if (vml->last_center == NULL) {
     VikCoord *new_center = g_malloc(sizeof(VikCoord));
     *new_center = *center;
diff --git a/src/vikwindow.c b/src/vikwindow.c
index 60d4483..3f431d5 100644
--- a/src/vikwindow.c
+++ b/src/vikwindow.c
@@ -1409,6 +1409,11 @@ GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode m
   return mode_button;
 }
 
+gboolean vik_window_get_pan_move ( VikWindow *vw )
+{
+  return vw->pan_move;
+}
+
 static void on_activate_recent_item (GtkRecentChooser *chooser,
                                      VikWindow *self)
 {
diff --git a/src/vikwindow.h b/src/vikwindow.h
index 682b776..80f5fd5 100644
--- a/src/vikwindow.h
+++ b/src/vikwindow.h
@@ -51,6 +51,7 @@ GType vik_window_get_type ();
 
 VikWindow *vik_window_new ();
 GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode mode );
+gboolean vik_window_get_pan_move ( VikWindow *vw );
 void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean changefilename );
 struct _VikLayer;
 void vik_window_selected_layer(VikWindow *vw, struct _VikLayer *vl);
-- 
tg: (33be396..) t/fix/pan_autodownload (depends on: master)
