Merge pull request #1074 from Anakael/feature/taskbar-ignore-list
[wlr/taskbar] Add ignore-list param
This commit is contained in:
commit
70e67c5daa
|
@ -8,6 +8,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ class Task
|
||||||
Gtk::Label text_before_;
|
Gtk::Label text_before_;
|
||||||
Gtk::Label text_after_;
|
Gtk::Label text_after_;
|
||||||
bool button_visible_;
|
bool button_visible_;
|
||||||
|
bool ignored_;
|
||||||
|
|
||||||
bool with_icon_;
|
bool with_icon_;
|
||||||
std::string format_before_;
|
std::string format_before_;
|
||||||
|
@ -132,6 +134,7 @@ class Taskbar : public waybar::AModule
|
||||||
std::vector<TaskPtr> tasks_;
|
std::vector<TaskPtr> tasks_;
|
||||||
|
|
||||||
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes_;
|
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes_;
|
||||||
|
std::unordered_set<std::string> ignore_list_;
|
||||||
|
|
||||||
struct zwlr_foreign_toplevel_manager_v1 *manager_;
|
struct zwlr_foreign_toplevel_manager_v1 *manager_;
|
||||||
struct wl_seat *seat_;
|
struct wl_seat *seat_;
|
||||||
|
@ -155,6 +158,7 @@ class Taskbar : public waybar::AModule
|
||||||
bool all_outputs() const;
|
bool all_outputs() const;
|
||||||
|
|
||||||
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes() const;
|
std::vector<Glib::RefPtr<Gtk::IconTheme>> icon_themes() const;
|
||||||
|
const std::unordered_set<std::string>& ignore_list() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace waybar::modules::wlr */
|
} /* namespace waybar::modules::wlr */
|
||||||
|
|
|
@ -68,6 +68,10 @@ Addressed by *wlr/taskbar*
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
Command to execute when the module is updated.
|
Command to execute when the module is updated.
|
||||||
|
|
||||||
|
*ignore-list*: ++
|
||||||
|
typeof: array ++
|
||||||
|
List of app_id to be invisible.
|
||||||
|
|
||||||
# FORMAT REPLACEMENTS
|
# FORMAT REPLACEMENTS
|
||||||
|
|
||||||
*{icon}*: The icon of the application.
|
*{icon}*: The icon of the application.
|
||||||
|
@ -98,7 +102,10 @@ Addressed by *wlr/taskbar*
|
||||||
"icon-theme": "Numix-Circle",
|
"icon-theme": "Numix-Circle",
|
||||||
"tooltip-format": "{title}",
|
"tooltip-format": "{title}",
|
||||||
"on-click": "activate",
|
"on-click": "activate",
|
||||||
"on-click-middle": "close"
|
"on-click-middle": "close",
|
||||||
|
"ignore-list": [
|
||||||
|
"Alacritty"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ Task::Task(const waybar::Bar &bar, const Json::Value &config, Taskbar *tbar,
|
||||||
bar_{bar}, config_{config}, tbar_{tbar}, handle_{tl_handle}, seat_{seat},
|
bar_{bar}, config_{config}, tbar_{tbar}, handle_{tl_handle}, seat_{seat},
|
||||||
id_{global_id++},
|
id_{global_id++},
|
||||||
content_{bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0},
|
content_{bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0},
|
||||||
button_visible_{false}
|
button_visible_{false}, ignored_{false}
|
||||||
{
|
{
|
||||||
zwlr_foreign_toplevel_handle_v1_add_listener(handle_, &toplevel_handle_impl, this);
|
zwlr_foreign_toplevel_handle_v1_add_listener(handle_, &toplevel_handle_impl, this);
|
||||||
|
|
||||||
|
@ -383,6 +383,21 @@ void Task::handle_app_id(const char *app_id)
|
||||||
{
|
{
|
||||||
app_id_ = app_id;
|
app_id_ = app_id;
|
||||||
|
|
||||||
|
if (tbar_->ignore_list().count(app_id)) {
|
||||||
|
ignored_ = true;
|
||||||
|
if (button_visible_) {
|
||||||
|
auto output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||||
|
handle_output_leave(output);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bool is_was_ignored = ignored_;
|
||||||
|
ignored_ = false;
|
||||||
|
if (is_was_ignored) {
|
||||||
|
auto output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||||
|
handle_output_enter(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!with_icon_)
|
if (!with_icon_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -405,6 +420,11 @@ void Task::handle_output_enter(struct wl_output *output)
|
||||||
{
|
{
|
||||||
spdlog::debug("{} entered output {}", repr(), (void*)output);
|
spdlog::debug("{} entered output {}", repr(), (void*)output);
|
||||||
|
|
||||||
|
if (ignored_) {
|
||||||
|
spdlog::debug("{} is ignored", repr());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!button_visible_ && (tbar_->all_outputs() || tbar_->show_output(output))) {
|
if (!button_visible_ && (tbar_->all_outputs() || tbar_->show_output(output))) {
|
||||||
/* The task entered the output of the current bar make the button visible */
|
/* The task entered the output of the current bar make the button visible */
|
||||||
tbar_->add_button(button_);
|
tbar_->add_button(button_);
|
||||||
|
@ -694,6 +714,14 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
|
||||||
|
|
||||||
icon_themes_.push_back(it);
|
icon_themes_.push_back(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load ignore-list
|
||||||
|
if (config_["ignore-list"].isArray()) {
|
||||||
|
for (auto& app_name : config_["ignore-list"]) {
|
||||||
|
ignore_list_.emplace(app_name.asString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
icon_themes_.push_back(Gtk::IconTheme::get_default());
|
icon_themes_.push_back(Gtk::IconTheme::get_default());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,5 +857,6 @@ std::vector<Glib::RefPtr<Gtk::IconTheme>> Taskbar::icon_themes() const
|
||||||
{
|
{
|
||||||
return icon_themes_;
|
return icon_themes_;
|
||||||
}
|
}
|
||||||
|
const std::unordered_set<std::string> &Taskbar::ignore_list() const { return ignore_list_; }
|
||||||
|
|
||||||
} /* namespace waybar::modules::wlr */
|
} /* namespace waybar::modules::wlr */
|
||||||
|
|
Loading…
Reference in New Issue