diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index e747037..b527cdc 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include @@ -14,6 +16,30 @@ std::unique_ptr urgentHookPtr std::unique_ptr tickHookPtr = std::make_unique(Hy3Layout::tickHook); +std::set getAutotileWorkspaces() { + std::set workspaces; + auto at_workspaces = HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces")->strValue; + + if (at_workspaces == "all") { + return workspaces; + } + + // split on space and comma + const std::regex regex { R"([\s,]+)" }; + const auto begin = std::regex_token_iterator(at_workspaces.begin(), at_workspaces.end(), regex, -1); + const auto end = std::regex_token_iterator(); + + for (auto s = begin; s != end; ++s) { + try { + workspaces.insert(std::stoi(*s)); + } catch (...) { + hy3_log(ERR, "autotile:workspaces: invalid workspace id: {}", (std::string) *s); + } + } + + return workspaces; +} + bool performContainment(Hy3Node& node, bool contained, CWindow* window) { if (node.data.type == Hy3NodeType::Group) { auto& group = node.data.as_group; @@ -163,11 +189,13 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { static const auto* at_ephemeral = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:ephemeral_groups")->intValue; static const auto* at_trigger_width = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:trigger_width")->intValue; static const auto* at_trigger_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:trigger_height")->intValue; + static const auto at_workspaces = getAutotileWorkspaces(); // clang-format on auto& target_group = opening_into->data.as_group; if (*at_enable && opening_after != nullptr && target_group.children.size() > 1 - && target_group.layout != Hy3GroupLayout::Tabbed) + && target_group.layout != Hy3GroupLayout::Tabbed && + (at_workspaces.empty() || at_workspaces.contains(opening_into->workspace_id))) { auto is_horizontal = target_group.layout == Hy3GroupLayout::SplitH; auto trigger = is_horizontal ? *at_trigger_width : *at_trigger_height; diff --git a/src/main.cpp b/src/main.cpp index 5185f2e..138ec7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { CONF("autotile:ephemeral_groups", int, 1); CONF("autotile:trigger_height", int, 0); CONF("autotile:trigger_width", int, 0); + CONF("autotile:workspaces", str, "all"); #undef CONF