mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
autotile: different handling of except workspaces rule
This commit is contained in:
parent
b9e72a008a
commit
3737f8234b
3 changed files with 13 additions and 10 deletions
|
@ -1731,15 +1731,21 @@ void Hy3Layout::updateAtWorkspaces() {
|
||||||
return;
|
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
|
// split on space and comma
|
||||||
const std::regex regex {R"([\s,]+)"};
|
const std::regex regex {R"([\s,]+)"};
|
||||||
const auto begin = std::regex_token_iterator(
|
const auto begin = std::sregex_token_iterator(
|
||||||
this->at_raw_workspaces.begin(),
|
at_raw_workspaces_filtered.begin(),
|
||||||
this->at_raw_workspaces.end(),
|
at_raw_workspaces_filtered.end(),
|
||||||
regex,
|
regex,
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
const auto end = std::regex_token_iterator<std::string::iterator>();
|
const auto end = std::sregex_token_iterator();
|
||||||
|
|
||||||
for (auto s = begin; s != end; ++s) {
|
for (auto s = begin; s != end; ++s) {
|
||||||
try {
|
try {
|
||||||
|
@ -1751,11 +1757,8 @@ void Hy3Layout::updateAtWorkspaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hy3Layout::shouldAtWorkspace(int workspace_id) {
|
bool Hy3Layout::shouldAtWorkspace(int workspace_id) {
|
||||||
static const auto* at_workspaces_except
|
if (this->at_workspaces_blacklist) {
|
||||||
= &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces.except")->intValue;
|
return !this->at_workspaces.contains(workspace_id);
|
||||||
|
|
||||||
if (*at_workspaces_except) {
|
|
||||||
return !this->at_workspaces.empty() && !this->at_workspaces.contains(workspace_id);
|
|
||||||
} else {
|
} else {
|
||||||
return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id);
|
return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,6 +143,7 @@ private:
|
||||||
bool shouldAtWorkspace(int);
|
bool shouldAtWorkspace(int);
|
||||||
|
|
||||||
std::string at_raw_workspaces;
|
std::string at_raw_workspaces;
|
||||||
|
bool at_workspaces_blacklist;
|
||||||
std::set<int> at_workspaces;
|
std::set<int> at_workspaces;
|
||||||
|
|
||||||
friend struct Hy3Node;
|
friend struct Hy3Node;
|
||||||
|
|
|
@ -44,7 +44,6 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
CONF("autotile:trigger_height", int, 0);
|
CONF("autotile:trigger_height", int, 0);
|
||||||
CONF("autotile:trigger_width", int, 0);
|
CONF("autotile:trigger_width", int, 0);
|
||||||
CONF("autotile:workspaces", str, "all");
|
CONF("autotile:workspaces", str, "all");
|
||||||
CONF("autotile:workspaces.except", int, 0);
|
|
||||||
|
|
||||||
#undef CONF
|
#undef CONF
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue