summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-11-05 16:18:41 +0000
committerVaxry <vaxry@vaxry.net>2023-11-05 16:18:41 +0000
commitd8b7ded18c47e5e10d21ac162a42256d573a9e91 (patch)
treeb708bf078bea9540d697255a854b4c8e652d319d /src/helpers
parentc4e1a9b13baf9a0f8b58824803c4a9e63cbc41b3 (diff)
compositor: find windows in direction on floating
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/MiscFunctions.cpp4
-rw-r--r--src/helpers/MiscFunctions.hpp1
-rw-r--r--src/helpers/Vector2D.cpp4
-rw-r--r--src/helpers/Vector2D.hpp2
4 files changed, 10 insertions, 1 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index b3a8ade7..376ac032 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -242,6 +242,10 @@ bool isDirection(const std::string& arg) {
return arg == "l" || arg == "r" || arg == "u" || arg == "d" || arg == "t" || arg == "b";
}
+bool isDirection(const char& arg) {
+ return arg == 'l' || arg == 'r' || arg == 'u' || arg == 'd' || arg == 't' || arg == 'b';
+}
+
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
int result = INT_MAX;
if (in.starts_with("special")) {
diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp
index 3bb07f79..b2fe5858 100644
--- a/src/helpers/MiscFunctions.hpp
+++ b/src/helpers/MiscFunctions.hpp
@@ -19,6 +19,7 @@ std::string escapeJSONStrings(const std::string& str);
std::string removeBeginEndSpacesTabs(std::string);
bool isNumber(const std::string&, bool allowfloat = false);
bool isDirection(const std::string&);
+bool isDirection(const char&);
int getWorkspaceIDFromString(const std::string&, std::string&);
std::optional<std::string> cleanCmdForWorkspace(const std::string&, std::string);
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
diff --git a/src/helpers/Vector2D.cpp b/src/helpers/Vector2D.cpp
index 118ba9d9..ae2484b3 100644
--- a/src/helpers/Vector2D.cpp
+++ b/src/helpers/Vector2D.cpp
@@ -45,3 +45,7 @@ bool Vector2D::inTriangle(const Vector2D& p1, const Vector2D& p2, const Vector2D
return 0 <= a && a <= 1 && 0 <= b && b <= 1 && 0 <= c && c <= 1;
}
+
+double Vector2D::size() const {
+ return std::sqrt(x * x + y * y);
+}
diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp
index 6112b8e4..17415289 100644
--- a/src/helpers/Vector2D.hpp
+++ b/src/helpers/Vector2D.hpp
@@ -57,7 +57,7 @@ class Vector2D {
}
double distance(const Vector2D& other) const;
-
+ double size() const;
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D()) const;
Vector2D floor() const;