From 67501d5dfcc2d18f82421b939f7d3ad3f556a5d9 Mon Sep 17 00:00:00 2001 From: Steve Fryatt Date: Mon, 19 Dec 2011 23:27:10 +0000 Subject: Provide a generic fall-back scroll event handler for scroll wheels. svn path=/trunk/netsurf/; revision=13300 --- riscos/gui.c | 7 ++++++- riscos/wimp.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ riscos/wimp.h | 3 +++ 3 files changed, 66 insertions(+), 1 deletion(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index 645dc4dfc..ab107e9b7 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1032,8 +1032,13 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) ro_gui_menu_selection(&(block->selection)); break; + /* Scroll requests fall back to a generic handler because we + * might get these events for any window from a scroll-wheel. + */ + case wimp_SCROLL_REQUEST: - ro_gui_wimp_event_scroll_window(&(block->scroll)); + if (!ro_gui_wimp_event_scroll_window(&(block->scroll))) + ro_gui_scroll(&(block->scroll)); break; case wimp_USER_MESSAGE: diff --git a/riscos/wimp.c b/riscos/wimp.c index 6043b6791..1f3a45297 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -1107,3 +1107,60 @@ int ro_gui_strncmp(const char *s1, const char *s2, size_t len) } return 0; } + + +/** + * Generic window scroll event handler. + * + * \param *scroll Pointer to Scroll Event block. + */ + +void ro_gui_scroll(wimp_scroll *scroll) +{ + os_error *error; + int x = scroll->visible.x1 - scroll->visible.x0 - 32; + int y = scroll->visible.y1 - scroll->visible.y0 - 32; + + switch (scroll->xmin) { + case wimp_SCROLL_PAGE_LEFT: + scroll->xscroll -= x; + break; + case wimp_SCROLL_COLUMN_LEFT: + scroll->xscroll -= 100; + break; + case wimp_SCROLL_COLUMN_RIGHT: + scroll->xscroll += 100; + break; + case wimp_SCROLL_PAGE_RIGHT: + scroll->xscroll += x; + break; + default: + scroll->xscroll += (x * (scroll->xmin>>2)) >> 2; + break; + } + + switch (scroll->ymin) { + case wimp_SCROLL_PAGE_UP: + scroll->yscroll += y; + break; + case wimp_SCROLL_LINE_UP: + scroll->yscroll += 100; + break; + case wimp_SCROLL_LINE_DOWN: + scroll->yscroll -= 100; + break; + case wimp_SCROLL_PAGE_DOWN: + scroll->yscroll -= y; + break; + default: + scroll->yscroll += (y * (scroll->ymin>>2)) >> 2; + break; + } + + error = xwimp_open_window((wimp_open *) scroll); + if (error) { + LOG(("xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess)); + } +} + diff --git a/riscos/wimp.h b/riscos/wimp.h index cd30fc7e5..fdcf67b95 100644 --- a/riscos/wimp.h +++ b/riscos/wimp.h @@ -77,4 +77,7 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, wimp_window_flags xor_mask); bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask); +void ro_gui_scroll(wimp_scroll *scroll); + #endif + -- cgit v1.2.3