From f3c68eaadacc13c7447f41d85369276af26e81d9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 22 Mar 2020 14:06:27 +0900 Subject: [PATCH] Implement mouse auto events These are for when a button is held down: good for scroll bar arrows etc. --- ruamoko/qwaq/qwaq-button.r | 7 +++++-- ruamoko/qwaq/qwaq-curses.c | 5 +++++ ruamoko/qwaq/qwaq-curses.h | 2 ++ ruamoko/qwaq/qwaq-input.c | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ruamoko/qwaq/qwaq-button.r b/ruamoko/qwaq/qwaq-button.r index fe7aa5f2f..ab8477a8a 100644 --- a/ruamoko/qwaq/qwaq-button.r +++ b/ruamoko/qwaq/qwaq-button.r @@ -66,8 +66,11 @@ } break; case qe_mouseauto: - click = 0; - action = onAuto; + if (pressed + && [self containsPoint: {event.mouse.x, event.mouse.y}]) { + click = 0; + action = onAuto; + } break; } if (action) { diff --git a/ruamoko/qwaq/qwaq-curses.c b/ruamoko/qwaq/qwaq-curses.c index eb4be924b..3306af584 100644 --- a/ruamoko/qwaq/qwaq-curses.c +++ b/ruamoko/qwaq/qwaq-curses.c @@ -712,6 +712,11 @@ get_event (qwaq_resources_t *res, qwaq_event_t *event) if (ret == 0) { RB_READ_DATA (res->event_queue, event, 1); was_event = 1; + } else if (res->button_state) { + event->what = qe_mouseauto; + event->mouse.buttons = res->button_state; + event->mouse.x = res->mouse_x; + event->mouse.y = res->mouse_y; } else { event->what = qe_none; } diff --git a/ruamoko/qwaq/qwaq-curses.h b/ruamoko/qwaq/qwaq-curses.h index 55f121990..be87e6423 100644 --- a/ruamoko/qwaq/qwaq-curses.h +++ b/ruamoko/qwaq/qwaq-curses.h @@ -188,6 +188,8 @@ typedef struct qwaq_resources_s { dstring_t escbuff; esc_state_t escstate; unsigned button_state; + int mouse_x; + int mouse_y; qwaq_event_t lastClick; struct hashtab_s *key_sequences; } qwaq_resources_t; diff --git a/ruamoko/qwaq/qwaq-input.c b/ruamoko/qwaq/qwaq-input.c index 558744d81..cab020328 100644 --- a/ruamoko/qwaq/qwaq-input.c +++ b/ruamoko/qwaq/qwaq-input.c @@ -266,6 +266,8 @@ parse_mouse (qwaq_resources_t *res, unsigned ctrl, int x, int y, int cmd) } } } + res->mouse_x = x; + res->mouse_y = y; mouse_event (res, what, x, y); }