diff --git a/src/callback.c b/src/callback.c index 256cfe57..86044b7b 100644 --- a/src/callback.c +++ b/src/callback.c @@ -429,11 +429,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int int idx; double cursorx; idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL); - if(idx < 0) idx = 0; cursorx = xctx->graph_cursor1_x; - if(idx) { + if(idx >= 0 ) { cursorx = xctx->raw->cursor_a_val[idx]; } + if(idx < 0) idx = 0; /* dragging cursors when mouse is very close */ if( fabs(xctx->mousex - W_X(cursorx)) < 10) { xctx->graph_flags |= 16; /* Start move cursor1 */ @@ -443,11 +443,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int int idx; double cursorx; idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL); - if(idx < 0) idx = 0; cursorx = xctx->graph_cursor2_x; - if(idx) { + if(idx >= 0) { cursorx = xctx->raw->cursor_b_val[idx]; } + if(idx < 0) idx = 0; /* dragging cursors when mouse is very close */ if(fabs(xctx->mousex - W_X(cursorx)) < 10) { xctx->graph_flags |= 32; /* Start move cursor2 */ diff --git a/src/draw.c b/src/draw.c index 78afbeef..eb01ca2f 100644 --- a/src/draw.c +++ b/src/draw.c @@ -2920,8 +2920,7 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g other_cursorx = xctx->graph_cursor1_x; } idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL); - if(idx < 0) idx = 0; - if(idx) { + if(idx >= 0) { dbg(1, "draw_cursor(): idx=%d, cursor=%g\n", idx, xctx->raw->cursor_a_val[idx]); if(active_cursor == 1) { active_cursorx = xctx->raw->cursor_a_val[idx]; @@ -2931,6 +2930,7 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g other_cursorx = xctx->raw->cursor_a_val[idx]; } } + if(idx < 0) idx = 0; xx = W_X(active_cursorx); flip = (other_cursorx > active_cursorx) ? 0 : 1; xoffs = flip ? 3 : -3;