]> err.no Git - mapper/commitdiff
sigh, try to fix thumb scrolling and map popup-menu. Move thumb code to button up...
authorKaj-Michael Lang <milang@tal.org>
Tue, 15 Apr 2008 09:54:44 +0000 (12:54 +0300)
committerKaj-Michael Lang <milang@tal.org>
Tue, 15 Apr 2008 09:54:44 +0000 (12:54 +0300)
src/map.c

index 6b95bdc322565d236dc010c280fb2ef5745030d9..a1ceeb8f4de3badc3e92e8377edcabf52bd9d3dd 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1450,31 +1450,6 @@ map_cb_button_press(GtkWidget *widget, GdkEventButton *event)
 _cmenu_position_x = event->x + 0.5;
 _cmenu_position_y = event->y + 0.5;
 
-/* Handle map panning using clicks, use thumb on tablets and middle button on non-tablets */
-#if defined(WITH_HILDON_NEW)
-if (hildon_helper_event_button_is_finger(event)) {
-       g_debug("Thumb down");
-#else
-if (event->button==2) {
-#endif
-       gint pns=0, pew=0;
-       if (event->x<MAP_THUMB_MARGIN_X)
-               pns=-PAN_UNITS;
-       else if (event->x>(_screen_width_pixels-MAP_THUMB_MARGIN_X))
-               pns=PAN_UNITS;
-
-       if (event->y<MAP_THUMB_MARGIN_Y)
-               pew=-PAN_UNITS;
-       else if (event->y>(_screen_height_pixels-MAP_THUMB_MARGIN_Y))
-               pew=PAN_UNITS;
-
-       if (pns!=0 || pew!=0) {
-               map_pan(pns, pew);
-               g_debug("MPAN: %d, %d", pns, pew);
-               return FALSE;
-       }
-}
-
 switch (event->button) {
 case 1:
        if (event->type==GDK_2BUTTON_PRESS) {
@@ -1507,6 +1482,29 @@ break;
 return FALSE;
 }
 
+static void
+map_pan_click_check(gint x, gint y)
+{
+gint pns=0, pew=0;
+
+if (x<MAP_THUMB_MARGIN_X)
+       pns=-PAN_UNITS;
+else if (x>(_screen_width_pixels-MAP_THUMB_MARGIN_X))
+       pns=PAN_UNITS;
+
+if (y<MAP_THUMB_MARGIN_Y)
+       pew=-PAN_UNITS;
+else if (y>(_screen_height_pixels-MAP_THUMB_MARGIN_Y))
+       pew=PAN_UNITS;
+
+if (pns!=0 || pew!=0) {
+       map_pan(pns, pew);
+       g_debug("MPAN: %d, %d", pns, pew);
+       return TRUE;
+}
+return FALSE;
+}
+
 static gboolean 
 map_cb_button_release(GtkWidget *widget, GdkEventButton *event)
 {
@@ -1514,17 +1512,16 @@ gdouble lat, lon;
 guint poi_id;
 gint ux, uy;
 
-#if defined(WITH_HILDON_NEW)
-if (hildon_helper_event_button_is_finger(event)) {
-       g_debug("Thumb up");
-       return FALSE;
-}
-#endif
-
 switch (event->button) {
 case 1:
-       if (_center_mode>0)
-               set_action_activate("autocenter_none", TRUE);
+
+#if defined(WITH_HILDON_NEW)
+       if (hildon_helper_event_button_is_finger(event)) {
+               g_debug("Thumb down");
+               if (map_pan_click_check(event->x, event->y))
+                       return FALSE;
+       }
+#endif
 
        switch (map_mode) {
        case MAP_MODE_DRAW_TRACK:
@@ -1550,14 +1547,18 @@ case 1:
                        map_render_data();
                        g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
                }
+               if (_center_mode>0)
+                       set_action_activate("autocenter_none", TRUE);
                map_drag_stop(event->x, event->y);
        break;
        }
 break;
 case 2:
-       /* */
+       map_pan_click_check(event->x, event->y);
+       return FALSE;
 break;
 case 3:
+       /* */
 break;
 }