Debugger: Debounce list control updates.

This commit is contained in:
Unknown W. Brackets 2021-12-12 11:03:19 -08:00
parent e7e5d031b2
commit c57e5b081d
2 changed files with 21 additions and 3 deletions

View file

@ -158,6 +158,9 @@ namespace W32Util
}
}
static constexpr UINT_PTR IDT_UPDATE = 0xC0DE0042;
static constexpr UINT UPDATE_DELAY = 1000 / 60;
GenericListControl::GenericListControl(HWND hwnd, const GenericListViewDef& def)
: handle(hwnd), columns(def.columns),columnCount(def.columnCount),valid(false),
inResizeColumns(false),updating(false)
@ -251,8 +254,12 @@ void GenericListControl::HandleNotify(LPARAM lParam)
}
}
void GenericListControl::Update()
{
void GenericListControl::Update() {
SetTimer(handle, IDT_UPDATE, UPDATE_DELAY, nullptr);
updateScheduled_ = true;
}
void GenericListControl::ProcessUpdate() {
updating = true;
int newRows = GetRowCount();
@ -279,7 +286,7 @@ void GenericListControl::Update()
ResizeColumns();
InvalidateRect(handle,NULL,true);
InvalidateRect(handle, nullptr, TRUE);
UpdateWindow(handle);
updating = false;
}
@ -338,6 +345,14 @@ LRESULT CALLBACK GenericListControl::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
break;
case WM_TIMER:
if (wParam == IDT_UPDATE) {
list->ProcessUpdate();
list->updateScheduled_ = false;
KillTimer(hwnd, wParam);
}
break;
}
return (LRESULT)CallWindowProc((WNDPROC)list->oldProc,hwnd,msg,wParam,lParam);

View file

@ -56,8 +56,10 @@ protected:
virtual void OnRightClick(int itemIndex, int column, const POINT& point) { };
virtual void CopyRows(int start, int size);
virtual void OnToggle(int item, bool newValue) { };
private:
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void ProcessUpdate();
void ResizeColumns();
void ProcessCopy();
void SelectAll();
@ -72,4 +74,5 @@ private:
// Used for hacky workaround to fix a rare hang (see issue #5184)
volatile bool inResizeColumns;
volatile bool updating;
bool updateScheduled_ = false;
};