From ce7ea957602bc5295de08e13ba0fb7475f909b33 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 11 Feb 2017 17:05:54 -0500 Subject: fix moving the mouse after making a selection previously it was always moving the existing selection around even if the mouse button wasn't held down --- src/window-xlib.c | 23 +++++++++++++++++------ src/window-xlib.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/window-xlib.c b/src/window-xlib.c index 20258f3..93e237d 100644 --- a/src/window-xlib.c +++ b/src/window-xlib.c @@ -869,7 +869,12 @@ static void runes_window_handle_button_event(RunesTerm *t, XButtonEvent *e) static void runes_window_handle_motion_event(RunesTerm *t, XMotionEvent *e) { - if (!(e->state & Button1Mask)) { + RunesWindow *w = t->w; + + /* unclear why we can't rely on (e->state & Button1Mask) here - it seems to + * always be true, which is confusing to me. i'd expect it to only be true + * if we had Button1 held down while moving the mouse. */ + if (!w->mouse_down) { return; } @@ -1043,11 +1048,14 @@ static int runes_window_handle_builtin_keypress( static int runes_window_handle_builtin_button_press( RunesTerm *t, XButtonEvent *e) { + RunesWindow *w = t->w; + switch (e->type) { case ButtonPress: switch (e->button) { case Button1: runes_window_start_selection(t, e->x, e->y); + w->mouse_down = 1; return 1; break; case Button2: @@ -1071,7 +1079,14 @@ static int runes_window_handle_builtin_button_press( } break; case ButtonRelease: - runes_window_handle_multi_click(t, e); + switch (e->button) { + case Button1: + runes_window_handle_multi_click(t, e); + w->mouse_down = 0; + break; + default: + break; + } break; default: break; @@ -1084,10 +1099,6 @@ static void runes_window_handle_multi_click(RunesTerm *t, XButtonEvent *e) { RunesWindow *w = t->w; - if (e->button != Button1) { - return; - } - if (w->multi_click_timer_event) { runes_loop_timer_clear(t->loop, w->multi_click_timer_event); runes_term_refcnt_dec(t); diff --git a/src/window-xlib.h b/src/window-xlib.h index 46ed900..c7bca22 100644 --- a/src/window-xlib.h +++ b/src/window-xlib.h @@ -20,6 +20,7 @@ struct runes_window { unsigned int owns_selection: 1; unsigned int visual_bell_is_ringing: 1; unsigned int delaying: 1; + unsigned int mouse_down: 1; }; RunesWindow *runes_window_new(RunesWindowBackend *wb); -- cgit v1.2.3