a55ca43e21f595b833366b595931244154ce0452

Author
André Silva <andrerfosilva@gmail.com>
Committer
André Silva <andrerfosilva@gmail.com>
Date

Message

autotile: pack fields into struct

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index b70416b2c908767ede7ee6099ce89756f0a75932..535ed08e6b83f3573c6ca3c4323b8f77b16ebf90 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -1717,31 +1717,31 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
 6 }
 7 
 8 void Hy3Layout::updateAutotileWorkspaces() {
 9-	static const auto* at_raw_workspaces
10+	static const auto* autotile_raw_workspaces
11 	    = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces")->strValue;
12 
13-	if (*at_raw_workspaces == this->at_raw_workspaces) {
14+	if (*autotile_raw_workspaces == this->autotile.raw_workspaces) {
15 		return;
16 	}
17 
18-	this->at_raw_workspaces = *at_raw_workspaces;
19-	this->at_workspaces.clear();
20+	this->autotile.raw_workspaces = *autotile_raw_workspaces;
21+	this->autotile.workspaces.clear();
22 
23-	if (this->at_raw_workspaces == "all") {
24+	if (this->autotile.raw_workspaces == "all") {
25 		return;
26 	}
27 
28-	this->at_workspaces_blacklist = this->at_raw_workspaces.rfind("not:", 0) == 0;
29+	this->autotile.workspace_blacklist = this->autotile.raw_workspaces.rfind("not:", 0) == 0;
30 
31-	const auto at_raw_workspaces_filtered = (this->at_workspaces_blacklist)
32-	                                          ? this->at_raw_workspaces.substr(4)
33-	                                          : this->at_raw_workspaces;
34+	const auto autotile_raw_workspaces_filtered = (this->autotile.workspace_blacklist)
35+	                                                ? this->autotile.raw_workspaces.substr(4)
36+	                                                : this->autotile.raw_workspaces;
37 
38 	// split on space and comma
39 	const std::regex regex {R"([\s,]+)"};
40 	const auto begin = std::sregex_token_iterator(
41-	    at_raw_workspaces_filtered.begin(),
42-	    at_raw_workspaces_filtered.end(),
43+	    autotile_raw_workspaces_filtered.begin(),
44+	    autotile_raw_workspaces_filtered.end(),
45 	    regex,
46 	    -1
47 	);
48@@ -1749,7 +1749,7 @@ void Hy3Layout::updateAutotileWorkspaces() {
49 
50 	for (auto s = begin; s != end; ++s) {
51 		try {
52-			this->at_workspaces.insert(std::stoi(*s));
53+			this->autotile.workspaces.insert(std::stoi(*s));
54 		} catch (...) {
55 			hy3_log(ERR, "autotile:workspaces: invalid workspace id: {}", (std::string) *s);
56 		}
57@@ -1757,9 +1757,9 @@ void Hy3Layout::updateAutotileWorkspaces() {
58 }
59 
60 bool Hy3Layout::shouldAutotileWorkspace(int workspace_id) {
61-	if (this->at_workspaces_blacklist) {
62-		return !this->at_workspaces.contains(workspace_id);
63+	if (this->autotile.workspace_blacklist) {
64+		return !this->autotile.workspaces.contains(workspace_id);
65 	} else {
66-		return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id);
67+		return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace_id);
68 	}
69 }
70diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
71index eacb27569443a64d882822adc58c8a8290ad296e..e8dd753ce98d7f297af9b2314ab3daa6cf9fe57b 100644
72--- a/src/Hy3Layout.hpp
73+++ b/src/Hy3Layout.hpp
74@@ -142,9 +142,11 @@ private:
75 	void updateAutotileWorkspaces();
76 	bool shouldAutotileWorkspace(int);
77 
78-	std::string at_raw_workspaces;
79-	bool at_workspaces_blacklist;
80-	std::set<int> at_workspaces;
81+	struct {
82+		std::string raw_workspaces;
83+		bool workspace_blacklist;
84+		std::set<int> workspaces;
85+	} autotile;
86 
87 	friend struct Hy3Node;
88 };