]> err.no Git - mapper/commitdiff
Check that button is down in motion handler.
authorKaj-Michael Lang <milang@onion.tal.org>
Sun, 4 Nov 2007 20:06:37 +0000 (22:06 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Sun, 4 Nov 2007 20:06:37 +0000 (22:06 +0200)
- Workaround (bug?) in maemo gtk that skips button release signal if context menu is shown

src/map.c

index 46fa0b678afad8bc8e49553837333be132e6d14d..386fa43a5b2fec39c398d226060ed9ac528be814 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -34,6 +34,7 @@
 #include "settings.h"
 #include "latlon.h"
 #include "gpx.h"
+#include "speak.h"
 #include "map-poi.h"
 #include "map-download.h"
 
@@ -70,6 +71,7 @@ static gint _mark_height;
 
 static gint zoom_timeout_sid=0;
 static gint map_mode=0;
+static gboolean map_data_needs_refresh=FALSE;
 
 static osm_location map_loc = {NULL, NULL, NULL, FALSE, FALSE, 0, 0, 0.0, 0.0, 0 };
 
@@ -747,13 +749,16 @@ if (_show_tracks & TRACKS_MASK)
  *
  */
 static gboolean 
-map_follow_move_cb(GtkWidget *widget, GdkEventMotion *event)
+map_follow_move_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
 {
 GdkModifierType state;
 gint xx, yy;
 guint unitx, unity;
 guint cx, cy;
 
+if (!(event->state & GDK_BUTTON1_MASK))
+       return FALSE;
+
 if (event->is_hint) {
        gdk_window_get_pointer(event->window, &xx, &yy, &state);
        state = event->state;
@@ -769,6 +774,7 @@ cx = unit2x(_center.unitx);
 cy = unit2y(_center.unity);
 
 map_center_unit(x2unit((gint) (cx - (xx - before[0]))),        y2unit((gint) (cy - (yy - before[1]))));
+map_data_needs_refresh=TRUE;
 
 before[0] = xx;
 before[1] = yy;
@@ -794,12 +800,6 @@ if (_key_zoom_new < _zoom) {
                return FALSE;
 }
 
-/* We can zoom more - tell them how much they're zooming. */
-{
-       gchar buffer[32];
-       snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), _key_zoom_new);
-       MACRO_BANNER_SHOW_INFO(_window, buffer);
-}
 return TRUE;
 }
 
@@ -833,17 +833,11 @@ if (event->area.width && event->area.height) {
        distance = calculate_distance(lat1, lon1, lat2, lon2) * UNITS_CONVERT[_units];
 
        if (distance < 1.f)
-                       snprintf(buffer, sizeof(buffer),
-                                "%0.2f %s", distance,
-                                UNITS_TEXT[_units]);
+               snprintf(buffer, sizeof(buffer), "%0.2f %s", distance, UNITS_TEXT[_units]);
        else if (distance < 10.f)
-               snprintf(buffer, sizeof(buffer),
-                        "%0.1f %s", distance,
-                        UNITS_TEXT[_units]);
+               snprintf(buffer, sizeof(buffer), "%0.1f %s", distance, UNITS_TEXT[_units]);
        else
-               snprintf(buffer, sizeof(buffer),
-                        "%0.f %s", distance,
-                        UNITS_TEXT[_units]);
+               snprintf(buffer, sizeof(buffer), "%0.f %s", distance, UNITS_TEXT[_units]);
 
        pango_layout_set_text(_scale_layout, buffer, -1);
        pango_layout_get_pixel_size(_scale_layout, &width, NULL);
@@ -928,8 +922,6 @@ gint nzoom;
 nzoom = _zoom + zdir;
 
 if ((nzoom > 0) && (nzoom < MAX_ZOOM - 1)) {
-       snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), nzoom);
-       MACRO_BANNER_SHOW_INFO(_window, buffer);
        map_set_zoom(nzoom);
 }
 
@@ -1142,6 +1134,9 @@ press[1] = y;
 before[0] = press[0];
 before[1] = press[1];
 _center_mode=CENTER_MANUAL;
+if (map_drag_id!=0)
+       g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
+
 map_drag_id=g_signal_connect(G_OBJECT(_map_widget), "motion_notify_event", G_CALLBACK(map_follow_move_cb), NULL);
 }
 
@@ -1154,9 +1149,10 @@ map_drag_stop(gint x, gint y)
 if (map_drag_id==0)
        return;
 
+g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
+
 release[0]=x;
 release[1]=y;
-g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
 press[0]=0;
 press[1]=0;
 release[0]=0;
@@ -1186,15 +1182,18 @@ gint ux, uy;
 _cmenu_position_x = event->x + 0.5;
 _cmenu_position_y = event->y + 0.5;
 
+g_printf("BtnPress\n");
 switch (event->button) {
 case 1:
        if (event->type==GDK_2BUTTON_PRESS) {
                map_center_unit(x2unit((gint) (event->x + 0.5)), y2unit((gint) (event->y + 0.5)));
-               map_set_zoom(_zoom - 1);
+               map_set_zoom(_zoom-1);
+               map_data_needs_refresh=TRUE;
                return FALSE;
        }
-       if (event->type==GDK_3BUTTON_PRESS)
+       if (event->type==GDK_3BUTTON_PRESS) {
                return FALSE;
+       }
 
        ux=x2unit(_cmenu_position_x);
        uy=y2unit(_cmenu_position_y);
@@ -1224,6 +1223,7 @@ return FALSE;
 gboolean 
 map_cb_button_release(GtkWidget *widget, GdkEventButton *event)
 {
+g_printf("BtnRelease\n");
 switch (event->button) {
 case 1:
        if (_center_mode>0)
@@ -1242,8 +1242,11 @@ case 1:
        break;
        default:
                map_drag_stop(event->x, event->y);
-               /* map_render_data(); */
-               g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
+               if (map_data_needs_refresh==TRUE) {
+                       map_data_needs_refresh=FALSE;
+                       map_render_data();
+                       g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
+               }
        break;
        }
 break;