Diff of /trunk/src/osm-gps-map.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 113 by harbaum, Wed Sep 16 13:45:10 2009 UTC revision 121 by harbaum, Sun Sep 20 19:26:29 2009 UTC
# Line 149  struct _OsmGpsMapPrivate Line 149  struct _OsmGpsMapPrivate
149      int drag_start_mouse_y;      int drag_start_mouse_y;
150      int drag_start_map_x;      int drag_start_map_x;
151      int drag_start_map_y;      int drag_start_map_y;
152        guint drag_expose;
153    
154      //for customizing the redering of the gps track      //for customizing the redering of the gps track
155      int ui_gps_track_width;      int ui_gps_track_width;
# Line 1546  osm_gps_map_dispose (GObject *object) Line 1547  osm_gps_map_dispose (GObject *object)
1547      if (priv->idle_map_redraw != 0)      if (priv->idle_map_redraw != 0)
1548          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1549    
1550        if (priv->drag_expose != 0)
1551            g_source_remove (priv->drag_expose);
1552    
1553      g_free(priv->gps);      g_free(priv->gps);
1554    
1555  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
# Line 1797  osm_gps_map_button_press (GtkWidget *wid Line 1801  osm_gps_map_button_press (GtkWidget *wid
1801  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
1802      /* pressed inside OSD control? */      /* pressed inside OSD control? */
1803      if(priv->osd) {      if(priv->osd) {
1804          osd_button_t but = priv->osd->check(priv->osd, event->x, event->y);          osd_button_t but =
1805                priv->osd->check(priv->osd, TRUE, event->x, event->y);
1806    
1807          if(but != OSD_NONE)          if(but != OSD_NONE)
1808          {          {
1809              int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP;              int step =
1810                    GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP;
1811              priv->drag_counter = -1;              priv->drag_counter = -1;
1812    
1813              switch(but) {              switch(but) {
# Line 1880  osm_gps_map_button_release (GtkWidget *w Line 1887  osm_gps_map_button_release (GtkWidget *w
1887    
1888          osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget));          osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget));
1889      }      }
1890    #ifdef ENABLE_OSD
1891        /* pressed inside OSD control? */
1892        else if(priv->osd)
1893            priv->osd->check(priv->osd, FALSE, event->x, event->y);
1894    #endif
1895    
1896  #ifdef DRAG_DEBUG  #ifdef DRAG_DEBUG
1897      printf("dragging done\n");      printf("dragging done\n");
# Line 1894  static gboolean Line 1906  static gboolean
1906  osm_gps_map_expose (GtkWidget *widget, GdkEventExpose  *event);  osm_gps_map_expose (GtkWidget *widget, GdkEventExpose  *event);
1907    
1908  static gboolean  static gboolean
1909    osm_gps_map_map_expose (GtkWidget *widget)
1910    {
1911        OsmGpsMapPrivate *priv = OSM_GPS_MAP(widget)->priv;
1912    
1913        priv->drag_expose = 0;
1914        osm_gps_map_expose (widget, NULL);
1915        return FALSE;
1916    }
1917    
1918    static gboolean
1919  osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion  *event)  osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion  *event)
1920  {  {
1921      int x, y;      int x, y;
# Line 1916  osm_gps_map_motion_notify (GtkWidget *wi Line 1938  osm_gps_map_motion_notify (GtkWidget *wi
1938      if (priv->drag_counter < 0)      if (priv->drag_counter < 0)
1939          return FALSE;          return FALSE;
1940    
1941      priv->drag_counter++;      /* not yet dragged far enough? */
1942        if(!priv->drag_counter &&
1943      // we havent dragged more than 6 pixels         ( (x - priv->drag_start_mouse_x) * (x - priv->drag_start_mouse_x) +
1944      if (priv->drag_counter < 6)           (y - priv->drag_start_mouse_y) * (y - priv->drag_start_mouse_y) <
1945             10*10))
1946          return FALSE;          return FALSE;
1947    
1948  #ifdef OSM_GPS_MAP_REFRESH      priv->drag_counter++;
     /* reduce update frequency on maemo to keep screen update fluid */  
     static guint32 last_time = 0;  
   
     if(event->time - last_time < (1000/OSM_GPS_MAP_REFRESH)) return FALSE;  
     last_time = event->time;  
 #endif  
1949    
1950      priv->dragging = TRUE;      priv->dragging = TRUE;
1951    
# Line 1938  osm_gps_map_motion_notify (GtkWidget *wi Line 1955  osm_gps_map_motion_notify (GtkWidget *wi
1955      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;
1956      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;
1957    
1958      osm_gps_map_expose (widget, NULL);      /* instead of redrawing directly just add an idle function */
1959        if (!priv->drag_expose)
1960            priv->drag_expose =
1961                g_idle_add ((GSourceFunc)osm_gps_map_map_expose, widget);
1962    
1963      return FALSE;      return FALSE;
1964  }  }

Legend:
Removed from v.113  
changed lines
  Added in v.121