Provide a generic fall-back scroll event handler for scroll wheels.

svn path=/trunk/netsurf/; revision=13300
This commit is contained in:
Steve Fryatt 2011-12-19 23:27:10 +00:00
parent 648fdafe82
commit 67501d5dfc
3 changed files with 66 additions and 1 deletions

View File

@ -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:

View File

@ -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));
}
}

View File

@ -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