diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-05-07 12:36:08 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-05-08 09:52:54 +0100 |
commit | 52b16237ad863ce30746ac7efc46a9ece7e3bdd2 (patch) | |
tree | 4cd5c83fb53da9c89219c7d0eba636d04b5d3634 /src/window.cpp | |
parent | 8321ef0061fa898cfb215e57c67aebd7411475e1 (diff) | |
download | openttd-52b16237ad863ce30746ac7efc46a9ece7e3bdd2.tar.xz |
Codechange: Don't update window contents if scrollbar position has not moved.
Diffstat (limited to 'src/window.cpp')
-rw-r--r-- | src/window.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/window.cpp b/src/window.cpp index 20c7ffbdd..d69a34144 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -849,8 +849,7 @@ static void DispatchMouseWheelEvent(Window *w, NWidgetCore *nwid, int wheel) if (nwid->type == NWID_VSCROLLBAR) { NWidgetScrollbar *sb = static_cast<NWidgetScrollbar *>(nwid); if (sb->GetCount() > sb->GetCapacity()) { - sb->UpdatePosition(wheel); - w->SetDirty(); + if (sb->UpdatePosition(wheel)) w->SetDirty(); } return; } @@ -858,8 +857,7 @@ static void DispatchMouseWheelEvent(Window *w, NWidgetCore *nwid, int wheel) /* Scroll the widget attached to the scrollbar. */ Scrollbar *sb = (nwid->scrollbar_index >= 0 ? w->GetScrollbar(nwid->scrollbar_index) : nullptr); if (sb != nullptr && sb->GetCount() > sb->GetCapacity()) { - sb->UpdatePosition(wheel); - w->SetDirty(); + if (sb->UpdatePosition(wheel)) w->SetDirty(); } } @@ -2413,8 +2411,7 @@ static void HandleScrollbarScrolling(Window *w) if (sb->disp_flags & ND_SCROLLBAR_BTN) { if (_scroller_click_timeout == 1) { _scroller_click_timeout = 3; - sb->UpdatePosition(rtl == HasBit(sb->disp_flags, NDB_SCROLLBAR_UP) ? 1 : -1); - w->SetDirty(); + if (sb->UpdatePosition(rtl == HasBit(sb->disp_flags, NDB_SCROLLBAR_UP) ? 1 : -1)) w->SetDirty(); } return; } |