feat(taskbar): `order-list` option
parent
81f0bcb3a3
commit
4c172ae924
|
@ -46,6 +46,8 @@ class Task
|
||||||
INVALID = (1 << 4)
|
INVALID = (1 << 4)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Gtk::Button button_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint32_t global_id;
|
static uint32_t global_id;
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ class Task
|
||||||
|
|
||||||
uint32_t id_;
|
uint32_t id_;
|
||||||
|
|
||||||
Gtk::Button button_;
|
|
||||||
Gtk::Box content_;
|
Gtk::Box content_;
|
||||||
Gtk::Image icon_;
|
Gtk::Image icon_;
|
||||||
Gtk::Label text_before_;
|
Gtk::Label text_before_;
|
||||||
|
@ -143,6 +145,7 @@ class Taskbar : public waybar::AModule
|
||||||
|
|
||||||
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes_;
|
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes_;
|
||||||
std::unordered_set<std::string> ignore_list_;
|
std::unordered_set<std::string> ignore_list_;
|
||||||
|
std::vector<std::string> order_list_;
|
||||||
std::map<std::string, std::string> app_ids_replace_map_;
|
std::map<std::string, std::string> app_ids_replace_map_;
|
||||||
|
|
||||||
struct zwlr_foreign_toplevel_manager_v1 *manager_;
|
struct zwlr_foreign_toplevel_manager_v1 *manager_;
|
||||||
|
|
|
@ -72,6 +72,10 @@ Addressed by *wlr/taskbar*
|
||||||
typeof: array ++
|
typeof: array ++
|
||||||
List of app_id/titles to be invisible.
|
List of app_id/titles to be invisible.
|
||||||
|
|
||||||
|
*ignore-list*: ++
|
||||||
|
typeof: array ++
|
||||||
|
List of app_ids in the order they should appear.
|
||||||
|
|
||||||
*app_ids-mapping*: ++
|
*app_ids-mapping*: ++
|
||||||
typeof: object ++
|
typeof: object ++
|
||||||
Dictionary of app_id to be replaced with
|
Dictionary of app_id to be replaced with
|
||||||
|
|
|
@ -764,6 +764,13 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load order-list
|
||||||
|
if (config_["order-list"].isArray()) {
|
||||||
|
for (auto& app_name : config_["order-list"]) {
|
||||||
|
order_list_.push_back(app_name.asString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load app_id remappings
|
// Load app_id remappings
|
||||||
if (config_["app_ids-mapping"].isObject()) {
|
if (config_["app_ids-mapping"].isObject()) {
|
||||||
const Json::Value& mapping = config_["app_ids-mapping"];
|
const Json::Value& mapping = config_["app_ids-mapping"];
|
||||||
|
@ -798,6 +805,18 @@ Taskbar::~Taskbar()
|
||||||
|
|
||||||
void Taskbar::update()
|
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());
|
||||||
|
|
||||||
|
if (itr != std::end(order_list_)) {
|
||||||
|
auto index = std::distance(begin, itr);
|
||||||
|
move_button(task->button_, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& t : tasks_) {
|
for (auto& t : tasks_) {
|
||||||
t->update();
|
t->update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue