Add specific flag for detecting delibrate movement within the TrackWaypoint handling.
Also fix incorrect function definition for select move.
Hence replace the removed button state with a 'something selected' flag.
typedef void (*VikLayerFuncDragDropRequest) (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
typedef gboolean (*VikLayerFuncSelectClick) (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
-typedef gboolean (*VikLayerFuncSelectMove) (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean (*VikLayerFuncSelectMove) (VikLayer *, GdkEventMotion *, VikViewport *, tool_ed_t*);
typedef gboolean (*VikLayerFuncSelectRelease) (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
typedef gboolean (*VikLayerFuncSelectedViewportMenu) (VikLayer *, GdkEventButton *, VikViewport *);
static void trw_layer_free_copied_item ( gint subtype, gpointer item );
static void trw_layer_drag_drop_request ( VikTrwLayer *vtl_src, VikTrwLayer *vtl_dest, GtkTreeIter *src_item_iter, GtkTreePath *dest_path );
static gboolean trw_layer_select_click ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp, tool_ed_t *t );
-static gboolean trw_layer_select_move ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp, tool_ed_t *t );
+static gboolean trw_layer_select_move ( VikTrwLayer *vtl, GdkEventMotion *event, VikViewport *vvp, tool_ed_t *t );
static gboolean trw_layer_select_release ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp, tool_ed_t *t );
static gboolean trw_layer_show_selected_viewport_menu ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp );
/* End Layer Interface function definitions */
static void marker_end_move ( tool_ed_t *t );
//
-static gboolean trw_layer_select_move ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp, tool_ed_t* t )
+static gboolean trw_layer_select_move ( VikTrwLayer *vtl, GdkEventMotion *event, VikViewport *vvp, tool_ed_t* t )
{
if ( t->holding ) {
VikCoord new_coord;
{
if ( t->holding && event->button == 1 )
{
+ // Prevent accidental (small) shifts when specific movement has not been requested
+ // (as the click release has occurred within the click object detection area)
+ if ( !t->moving )
+ return FALSE;
+
VikCoord new_coord;
vik_viewport_screen_to_coord ( vvp, event->x, event->y, &new_coord );
vik_viewport_sync(t->vvp);
t->oldx = x;
t->oldy = y;
+ t->moving = FALSE;
}
static void marker_moveto ( tool_ed_t *t, gint x, gint y )
vik_viewport_draw_rectangle ( vvp, t->gc, FALSE, x-3, y-3, 6, 6 );
t->oldx = x;
t->oldy = y;
+ t->moving = TRUE;
if (tool_sync_done) {
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, tool_sync, vvp, NULL);
vik_viewport_draw_rectangle ( t->vvp, t->gc, FALSE, t->oldx-3, t->oldy-3, 6, 6 );
g_object_unref ( t->gc );
t->holding = FALSE;
+ t->moving = FALSE;
}
/*** Edit waypoint ****/
gboolean show_toolbar;
gboolean show_main_menu;
+ gboolean select_move;
gboolean pan_move;
gint pan_x, pan_y;
gint delayed_pan_x, delayed_pan_y; // Temporary storage
vw->loaded_type = LOAD_TYPE_READ_FAILURE; //AKA none
vw->modified = FALSE;
vw->only_updating_coord_mode_ui = FALSE;
-
+
+ vw->select_move = FALSE;
vw->pan_move = FALSE;
vw->pan_x = vw->pan_y = -1;
vw->single_click_pending = FALSE;
static VikLayerToolFuncStatus selecttool_click (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
{
+ t->vw->select_move = FALSE;
/* Only allow selection on primary button */
if ( event->button == 1 ) {
/* Enable click to apply callback to potentially all track/waypoint layers */
}
}
}
+ else {
+ // Something found - so enable movement
+ t->vw->select_move = TRUE;
+ }
}
else if ( ( event->button == 3 ) && ( vl && ( vl->type == VIK_LAYER_TRW ) ) ) {
if ( vl->visible )
return VIK_LAYER_TOOL_ACK;
}
-static VikLayerToolFuncStatus selecttool_move (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
+static VikLayerToolFuncStatus selecttool_move (VikLayer *vl, GdkEventMotion *event, tool_ed_t *t)
{
- /* Only allow selection on primary button */
- if ( event->button == 1 ) {
+ if ( t->vw->select_move ) {
// Don't care about vl here
if ( t->vtl )
if ( vik_layer_get_interface(VIK_LAYER_TRW)->select_move )
- vik_layer_get_interface(VIK_LAYER_TRW)->select_move ( vl, event, t->vvp, t );
+ vik_layer_get_interface(VIK_LAYER_TRW)->select_move ( vl, event, t->vvp, t );
}
return VIK_LAYER_TOOL_ACK;
}
static VikLayerToolFuncStatus selecttool_release (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
{
- /* Only allow selection on primary button */
+ /* Only allow deselection on primary button */
if ( event->button == 1 ) {
// Don't care about vl here
if ( t->vtl )
if ( vik_layer_get_interface(VIK_LAYER_TRW)->select_release )
- vik_layer_get_interface(VIK_LAYER_TRW)->select_release ( (VikLayer*)t->vtl, event, t->vvp, t );
+ vik_layer_get_interface(VIK_LAYER_TRW)->select_release ( (VikLayer*)t->vtl, event, t->vvp, t );
}
+
+ // End of this select movement
+ t->vw->select_move = FALSE;
+
return VIK_LAYER_TOOL_ACK;
}
VikViewport *vvp;
gpointer *vtl; // VikTrwlayer
gboolean holding;
+ gboolean moving;
gboolean is_waypoint; // otherwise a track
GdkGC *gc;
int oldx, oldy;