diff options
author | Darkvater <darkvater@openttd.org> | 2005-07-08 00:14:19 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-07-08 00:14:19 +0000 |
commit | a014ef63402b1166eb0fd6bc25fbc8dda39b6731 (patch) | |
tree | 676563459da0d4d5fad9860a275eb2b8dfb3f90b /widget.c | |
parent | 480ced43c996d11985ff8d33c0e0d4c8787dd072 (diff) | |
download | openttd-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 'widget.c')
-rw-r--r-- | widget.c | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -125,14 +125,11 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y) SetWindowDirty(w); } -/***************************************************** - * Returns the index for the widget located at the given - * position relative to the window. - * Parameters: - * w - Window - * x/y - Window client coordinates - * Returns: - * A widget index, or -1 if no widget was found. +/** Returns the index for the widget located at the given position + * relative to the window. It includes all widget-corner pixels as well. + * @param *w Window to look inside + * @param x,y Window client coordinates + * @return A widget index, or -1 if no widget was found. */ int GetWidgetFromPos(Window *w, int x, int y) { @@ -141,19 +138,16 @@ int GetWidgetFromPos(Window *w, int x, int y) // Go through the widgets and check if we find the widget that the coordinate is // inside. - for(index=0,wi=w->widget; wi->type != WWT_LAST; index++, wi++) { + for (index = 0,wi = w->widget; wi->type != WWT_LAST; index++, wi++) { if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue; - if (x >= wi->left && - x < wi->right && - y >= wi->top && - y < wi->bottom && !HASBIT(w->hidden_state,index)) { + if (x >= wi->left && x <= wi->right && y >= wi->top && y <= wi->bottom && + !HASBIT(w->hidden_state,index)) { found_index = index; } } - // Return the index return found_index; } |