fix(taskbar): `order-list` tasks pushed after unordered on start

pull/1396/head
Jake Stanger 2022-01-16 21:20:51 +00:00
parent 4c172ae924
commit da6296e553
1 changed files with 14 additions and 2 deletions

View File

@ -806,15 +806,27 @@ Taskbar::~Taskbar()
void Taskbar::update()
{
if (!order_list_.empty()) {
for (auto& task : tasks_) {
auto begin = order_list_.begin();
auto itr = std::find(begin, order_list_.end(), task->app_id());
auto end = order_list.end();
// first pass - sort ordered tasks
for (auto& task : tasks_) {
auto itr = std::find(begin, end, task->app_id());
if (itr != std::end(order_list_)) {
auto index = std::distance(begin, itr);
move_button(task->button_, index);
}
}
// second pass - push unordered to end
for (auto& task : tasks_) {
auto itr = std::find(begin, end, task->app_id());
if (itr == std::end(order_list_)) {
move_button(task->button_, -1);
}
}
}
for (auto& t : tasks_) {