Implement ignore-list
This commit is contained in:
@ -90,6 +90,7 @@ class Workspace {
|
||||
|
||||
void updateTaskbar(const std::string& workspace_icon);
|
||||
bool handleClick(const GdkEventButton* event_button, WindowAddress const& addr) const;
|
||||
bool shouldSkipWindow(const WindowRepr& window_repr) const;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto taskbarIconSize() const -> int { return m_taskbarIconSize; }
|
||||
auto taskbarOrientation() const -> Gtk::Orientation { return m_taskbarOrientation; }
|
||||
auto onClickWindow() const -> std::string { return m_onClickWindow; }
|
||||
auto getIgnoredWindows() const -> std::vector<std::regex> { return m_ignoreWindows; }
|
||||
|
||||
std::string getRewrite(std::string window_class, std::string window_title);
|
||||
std::string& getWindowSeparator() { return m_formatWindowSeparator; }
|
||||
@ -182,6 +183,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::string m_currentActiveWindowAddress;
|
||||
|
||||
std::vector<std::regex> m_ignoreWorkspaces;
|
||||
std::vector<std::regex> m_ignoreWindows;
|
||||
|
||||
std::mutex m_mutex;
|
||||
const Bar& m_bar;
|
||||
|
@ -256,6 +256,9 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||
|
||||
bool isFirst = true;
|
||||
for (const auto &window_repr : m_windowMap) {
|
||||
if (shouldSkipWindow(window_repr)) {
|
||||
continue;
|
||||
}
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
} else if (m_workspaceManager.getWindowSeparator() != "") {
|
||||
@ -326,4 +329,13 @@ bool Workspace::handleClick(const GdkEventButton *event_button, WindowAddress co
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Workspace::shouldSkipWindow(const WindowRepr &window_repr) const {
|
||||
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
||||
auto it = std::ranges::find_if(ignore_list, [&window_repr](const auto &ignoreItem) {
|
||||
return std::regex_match(window_repr.window_class, ignoreItem) ||
|
||||
std::regex_match(window_repr.window_title, ignoreItem);
|
||||
});
|
||||
return it != ignore_list.end();
|
||||
}
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -757,6 +757,17 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo
|
||||
if (workspaceTaskbar["on-click-window"].isString()) {
|
||||
m_onClickWindow = workspaceTaskbar["on-click-window"].asString();
|
||||
}
|
||||
|
||||
if (workspaceTaskbar["ignore-list"].isArray()) {
|
||||
for (auto &windowRegex : workspaceTaskbar["ignore-list"]) {
|
||||
std::string ruleString = windowRegex.asString();
|
||||
try {
|
||||
m_ignoreWindows.emplace_back(ruleString, std::regex_constants::icase);
|
||||
} catch (const std::regex_error &e) {
|
||||
spdlog::error("Invalid rule {}: {}", ruleString, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Workspaces::registerOrphanWindow(WindowCreationPayload create_window_payload) {
|
||||
|
Reference in New Issue
Block a user