From da6296e553e67eb0f76eb4a93c67baa6e3b06ee8 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 16 Jan 2022 21:20:51 +0000 Subject: [PATCH] fix(taskbar): `order-list` tasks pushed after unordered on start --- src/modules/wlr/taskbar.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index d38646e5..ee50e96e 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -806,15 +806,27 @@ Taskbar::~Taskbar() void Taskbar::update() { if (!order_list_.empty()) { + auto begin = order_list_.begin(); + auto end = order_list.end(); + + // first pass - sort ordered tasks for (auto& task : tasks_) { - auto begin = order_list_.begin(); - auto itr = std::find(begin, order_list_.end(), task->app_id()); + 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_) {