Codechange: Don't update window contents if scrollbar position has not moved.

This commit is contained in:
Peter Nelson
2021-05-07 12:36:08 +01:00
committed by PeterN
parent 8321ef0061
commit 52b16237ad
3 changed files with 23 additions and 15 deletions

View File

@@ -108,6 +108,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
int pos;
int button_size;
bool rtl = false;
bool changed = false;
if (sb->type == NWID_HSCROLLBAR) {
pos = x;
@@ -122,7 +123,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
SetBit(sb->disp_flags, NDB_SCROLLBAR_UP);
if (_scroller_click_timeout <= 1) {
_scroller_click_timeout = 3;
sb->UpdatePosition(rtl ? 1 : -1);
changed = sb->UpdatePosition(rtl ? 1 : -1);
}
w->mouse_capture_widget = sb->index;
} else if (pos >= ma - button_size) {
@@ -131,16 +132,16 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
if (_scroller_click_timeout <= 1) {
_scroller_click_timeout = 3;
sb->UpdatePosition(rtl ? -1 : 1);
changed = sb->UpdatePosition(rtl ? -1 : 1);
}
w->mouse_capture_widget = sb->index;
} else {
Point pt = HandleScrollbarHittest(sb, mi, ma, sb->type == NWID_HSCROLLBAR);
if (pos < pt.x) {
sb->UpdatePosition(rtl ? 1 : -1, Scrollbar::SS_BIG);
changed = sb->UpdatePosition(rtl ? 1 : -1, Scrollbar::SS_BIG);
} else if (pos > pt.y) {
sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG);
changed = sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG);
} else {
_scrollbar_start_pos = pt.x - mi - button_size;
_scrollbar_size = ma - mi - button_size * 2;
@@ -149,7 +150,13 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
}
}
w->SetDirty();
if (changed) {
/* Position changed so refresh the window */
w->SetDirty();
} else {
/* No change so only refresh this scrollbar */
sb->SetDirty(w);
}
}
/**