From 3737f8234baa2c735a3ad5ccb2f4e3cf6d57486e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Thu, 14 Sep 2023 11:28:44 +0100 Subject: [PATCH] autotile: different handling of except workspaces rule --- src/Hy3Layout.cpp | 21 ++++++++++++--------- src/Hy3Layout.hpp | 1 + src/main.cpp | 1 - 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index eb63370..7d4d26b 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1731,15 +1731,21 @@ void Hy3Layout::updateAtWorkspaces() { return; } + this->at_workspaces_blacklist = this->at_raw_workspaces.rfind("not:", 0) == 0; + + const auto at_raw_workspaces_filtered = (this->at_workspaces_blacklist) + ? this->at_raw_workspaces.substr(4) + : this->at_raw_workspaces; + // split on space and comma const std::regex regex {R"([\s,]+)"}; - const auto begin = std::regex_token_iterator( - this->at_raw_workspaces.begin(), - this->at_raw_workspaces.end(), + const auto begin = std::sregex_token_iterator( + at_raw_workspaces_filtered.begin(), + at_raw_workspaces_filtered.end(), regex, -1 ); - const auto end = std::regex_token_iterator(); + const auto end = std::sregex_token_iterator(); for (auto s = begin; s != end; ++s) { try { @@ -1751,11 +1757,8 @@ void Hy3Layout::updateAtWorkspaces() { } bool Hy3Layout::shouldAtWorkspace(int workspace_id) { - static const auto* at_workspaces_except - = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces.except")->intValue; - - if (*at_workspaces_except) { - return !this->at_workspaces.empty() && !this->at_workspaces.contains(workspace_id); + if (this->at_workspaces_blacklist) { + return !this->at_workspaces.contains(workspace_id); } else { return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id); } diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index f701663..a171c7e 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -143,6 +143,7 @@ private: bool shouldAtWorkspace(int); std::string at_raw_workspaces; + bool at_workspaces_blacklist; std::set at_workspaces; friend struct Hy3Node; diff --git a/src/main.cpp b/src/main.cpp index 55afe9e..138ec7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,6 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { CONF("autotile:trigger_height", int, 0); CONF("autotile:trigger_width", int, 0); CONF("autotile:workspaces", str, "all"); - CONF("autotile:workspaces.except", int, 0); #undef CONF