summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fryatt <steve@stevefryatt.org.uk>2011-12-19 23:27:10 +0000
committerSteve Fryatt <steve@stevefryatt.org.uk>2011-12-19 23:27:10 +0000
commit67501d5dfcc2d18f82421b939f7d3ad3f556a5d9 (patch)
treeec268030b13f874e017098fa3e4a50995a2768df
parent648fdafe824ceb1bc22f93045f78b642bc5e550f (diff)
downloadnetsurf-67501d5dfcc2d18f82421b939f7d3ad3f556a5d9.tar.gz
netsurf-67501d5dfcc2d18f82421b939f7d3ad3f556a5d9.tar.bz2
Provide a generic fall-back scroll event handler for scroll wheels.
svn path=/trunk/netsurf/; revision=13300
-rw-r--r--riscos/gui.c7
-rw-r--r--riscos/wimp.c57
-rw-r--r--riscos/wimp.h3
3 files changed, 66 insertions, 1 deletions
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
+