summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-07-08 00:14:19 +0000
committerDarkvater <darkvater@openttd.org>2005-07-08 00:14:19 +0000
commita014ef63402b1166eb0fd6bc25fbc8dda39b6731 (patch)
tree676563459da0d4d5fad9860a275eb2b8dfb3f90b /window.c
parent480ced43c996d11985ff8d33c0e0d4c8787dd072 (diff)
downloadopenttd-a014ef63402b1166eb0fd6bc25fbc8dda39b6731.tar.xz
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Diffstat (limited to 'window.c')
-rw-r--r--window.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/window.c b/window.c
index 1641b0cea..e069cbedf 100644
--- a/window.c
+++ b/window.c
@@ -98,13 +98,22 @@ void DispatchRightClickEvent(Window *w, int x, int y) {
w->wndproc(w, &e);
}
-
-void DispatchMouseWheelEvent(Window *w, uint widget, int wheel)
+/** Dispatch the mousewheel-action to the window which will scroll any
+ * compatible scrollbars if the mouse is pointed over the bar or its contents
+ * @param *w Window
+ * @param widget the widget where the scrollwheel was used
+ * @param wheel scroll up or down
+ */
+void DispatchMouseWheelEvent(Window *w, int widget, int wheel)
{
- const Widget *wi1 = &w->widget[widget];
- const Widget *wi2 = &w->widget[widget + 1];
+ const Widget *wi1, *wi2;
Scrollbar *sb;
+ if (widget < 0) return;
+
+ wi1 = &w->widget[widget];
+ wi2 = &w->widget[widget + 1];
+
/* The listbox can only scroll if scrolling was done on the scrollbar itself,
* or on the listbox (and the next item is (must be) the scrollbar)
* XXX - should be rewritten as a widget-dependent scroller but that's