mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
autotile: pack fields into struct
This commit is contained in:
parent
191f3f676c
commit
a55ca43e21
2 changed files with 20 additions and 18 deletions
|
@ -1717,31 +1717,31 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3Layout::updateAutotileWorkspaces() {
|
void Hy3Layout::updateAutotileWorkspaces() {
|
||||||
static const auto* at_raw_workspaces
|
static const auto* autotile_raw_workspaces
|
||||||
= &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces")->strValue;
|
= &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces")->strValue;
|
||||||
|
|
||||||
if (*at_raw_workspaces == this->at_raw_workspaces) {
|
if (*autotile_raw_workspaces == this->autotile.raw_workspaces) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->at_raw_workspaces = *at_raw_workspaces;
|
this->autotile.raw_workspaces = *autotile_raw_workspaces;
|
||||||
this->at_workspaces.clear();
|
this->autotile.workspaces.clear();
|
||||||
|
|
||||||
if (this->at_raw_workspaces == "all") {
|
if (this->autotile.raw_workspaces == "all") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->at_workspaces_blacklist = this->at_raw_workspaces.rfind("not:", 0) == 0;
|
this->autotile.workspace_blacklist = this->autotile.raw_workspaces.rfind("not:", 0) == 0;
|
||||||
|
|
||||||
const auto at_raw_workspaces_filtered = (this->at_workspaces_blacklist)
|
const auto autotile_raw_workspaces_filtered = (this->autotile.workspace_blacklist)
|
||||||
? this->at_raw_workspaces.substr(4)
|
? this->autotile.raw_workspaces.substr(4)
|
||||||
: this->at_raw_workspaces;
|
: this->autotile.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::sregex_token_iterator(
|
const auto begin = std::sregex_token_iterator(
|
||||||
at_raw_workspaces_filtered.begin(),
|
autotile_raw_workspaces_filtered.begin(),
|
||||||
at_raw_workspaces_filtered.end(),
|
autotile_raw_workspaces_filtered.end(),
|
||||||
regex,
|
regex,
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
|
@ -1749,7 +1749,7 @@ void Hy3Layout::updateAutotileWorkspaces() {
|
||||||
|
|
||||||
for (auto s = begin; s != end; ++s) {
|
for (auto s = begin; s != end; ++s) {
|
||||||
try {
|
try {
|
||||||
this->at_workspaces.insert(std::stoi(*s));
|
this->autotile.workspaces.insert(std::stoi(*s));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
hy3_log(ERR, "autotile:workspaces: invalid workspace id: {}", (std::string) *s);
|
hy3_log(ERR, "autotile:workspaces: invalid workspace id: {}", (std::string) *s);
|
||||||
}
|
}
|
||||||
|
@ -1757,9 +1757,9 @@ void Hy3Layout::updateAutotileWorkspaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hy3Layout::shouldAutotileWorkspace(int workspace_id) {
|
bool Hy3Layout::shouldAutotileWorkspace(int workspace_id) {
|
||||||
if (this->at_workspaces_blacklist) {
|
if (this->autotile.workspace_blacklist) {
|
||||||
return !this->at_workspaces.contains(workspace_id);
|
return !this->autotile.workspaces.contains(workspace_id);
|
||||||
} else {
|
} else {
|
||||||
return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id);
|
return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,11 @@ private:
|
||||||
void updateAutotileWorkspaces();
|
void updateAutotileWorkspaces();
|
||||||
bool shouldAutotileWorkspace(int);
|
bool shouldAutotileWorkspace(int);
|
||||||
|
|
||||||
std::string at_raw_workspaces;
|
struct {
|
||||||
bool at_workspaces_blacklist;
|
std::string raw_workspaces;
|
||||||
std::set<int> at_workspaces;
|
bool workspace_blacklist;
|
||||||
|
std::set<int> workspaces;
|
||||||
|
} autotile;
|
||||||
|
|
||||||
friend struct Hy3Node;
|
friend struct Hy3Node;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue