fixed bug; when the shown task is removed it promotes another one
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ranges>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -185,6 +186,10 @@ class Taskbar : public waybar::AModule {
|
|||||||
const std::map<std::string, std::string> &app_ids_replace_map() const;
|
const std::map<std::string, std::string> &app_ids_replace_map() const;
|
||||||
std::size_t task_id_count(std::string_view id) const;
|
std::size_t task_id_count(std::string_view id) const;
|
||||||
std::size_t task_title_count(std::string_view title) const;
|
std::size_t task_title_count(std::string_view title) const;
|
||||||
|
|
||||||
|
auto tasks() {
|
||||||
|
return tasks_ | std::views::transform([](auto &task) -> Task & { return *task; });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace waybar::modules::wlr */
|
} /* namespace waybar::modules::wlr */
|
||||||
|
|||||||
@@ -392,6 +392,28 @@ void Task::handle_closed() {
|
|||||||
tbar_->remove_button(button);
|
tbar_->remove_button(button);
|
||||||
button_visible_ = false;
|
button_visible_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto &squash_list = tbar_->squash_list();
|
||||||
|
const bool in_squash_list =
|
||||||
|
squash_list.contains("*") || squash_list.contains(title_) || squash_list.contains(app_id_);
|
||||||
|
if (in_squash_list && !squashed_ &&
|
||||||
|
(tbar_->task_id_count(app_id_) > 1 || tbar_->task_title_count(title_) > 1)) {
|
||||||
|
// Find next squashed task with same title or id (excluding ourselves)
|
||||||
|
auto tasks = tbar_->tasks();
|
||||||
|
const auto it = std::ranges::find_if(tasks, [this](auto &&task) {
|
||||||
|
return &task != this && task.squashed_ &&
|
||||||
|
(task.app_id() == app_id_ || task.title() == title_);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != tasks.end() && !(*it).ignored_) {
|
||||||
|
Task &task = *it;
|
||||||
|
task.squashed_ = false;
|
||||||
|
tbar_->add_button(task.button);
|
||||||
|
task.button.show();
|
||||||
|
task.button_visible_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tbar_->remove_task(id_);
|
tbar_->remove_task(id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user