From d8b7ded18c47e5e10d21ac162a42256d573a9e91 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 5 Nov 2023 16:18:41 +0000 Subject: compositor: find windows in direction on floating --- src/helpers/MiscFunctions.cpp | 4 ++++ src/helpers/MiscFunctions.hpp | 1 + src/helpers/Vector2D.cpp | 4 ++++ src/helpers/Vector2D.hpp | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/helpers') 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 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; -- cgit v1.2.3