3737f8234baa2c735a3ad5ccb2f4e3cf6d57486e

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

Message

autotile: different handling of except workspaces rule

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index eb63370834229afba2e8b6001a19f51c0cdd99fc..7d4d26b15e435b4b3db251a7aece520cf204c50e 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -1731,15 +1731,21 @@ void Hy3Layout::updateAtWorkspaces() {
 6 		return;
 7 	}
 8 
 9+	this->at_workspaces_blacklist = this->at_raw_workspaces.rfind("not:", 0) == 0;
10+
11+	const auto at_raw_workspaces_filtered = (this->at_workspaces_blacklist)
12+	                                          ? this->at_raw_workspaces.substr(4)
13+	                                          : this->at_raw_workspaces;
14+
15 	// split on space and comma
16 	const std::regex regex {R"([\s,]+)"};
17-	const auto begin = std::regex_token_iterator(
18-	    this->at_raw_workspaces.begin(),
19-	    this->at_raw_workspaces.end(),
20+	const auto begin = std::sregex_token_iterator(
21+	    at_raw_workspaces_filtered.begin(),
22+	    at_raw_workspaces_filtered.end(),
23 	    regex,
24 	    -1
25 	);
26-	const auto end = std::regex_token_iterator<std::string::iterator>();
27+	const auto end = std::sregex_token_iterator();
28 
29 	for (auto s = begin; s != end; ++s) {
30 		try {
31@@ -1751,11 +1757,8 @@ void Hy3Layout::updateAtWorkspaces() {
32 }
33 
34 bool Hy3Layout::shouldAtWorkspace(int workspace_id) {
35-	static const auto* at_workspaces_except
36-	    = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:workspaces.except")->intValue;
37-
38-	if (*at_workspaces_except) {
39-		return !this->at_workspaces.empty() && !this->at_workspaces.contains(workspace_id);
40+	if (this->at_workspaces_blacklist) {
41+		return !this->at_workspaces.contains(workspace_id);
42 	} else {
43 		return this->at_workspaces.empty() || this->at_workspaces.contains(workspace_id);
44 	}
45diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
46index f7016639aa7bef02b64d842c975e22a04c1643b3..a171c7e4500aed87c0015127cb717464ee27ef17 100644
47--- a/src/Hy3Layout.hpp
48+++ b/src/Hy3Layout.hpp
49@@ -143,6 +143,7 @@ private:
50 	bool shouldAtWorkspace(int);
51 
52 	std::string at_raw_workspaces;
53+	bool at_workspaces_blacklist;
54 	std::set<int> at_workspaces;
55 
56 	friend struct Hy3Node;
57diff --git a/src/main.cpp b/src/main.cpp
58index 55afe9eb6bcda0dc0a5bc996204ae26a6567132c..138ec7f1ae429cb8a099ccf13259e67542abe32e 100644
59--- a/src/main.cpp
60+++ b/src/main.cpp
61@@ -44,7 +44,6 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
62 	CONF("autotile:trigger_height", int, 0);
63 	CONF("autotile:trigger_width", int, 0);
64 	CONF("autotile:workspaces", str, "all");
65-	CONF("autotile:workspaces.except", int, 0);
66 
67 #undef CONF
68