diff options
| author | vaxerski <vaxry@vaxry.net> | 2022-08-15 15:59:07 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2022-08-15 15:59:07 +0200 |
| commit | b0b3a5af100d6c68a30230c5b5eafd8087703a99 (patch) | |
| tree | c3529c5397aff49773271687d6af421836dbfee3 /src/Compositor.cpp | |
| parent | d47bfe6af1d040f5c5feb607cf24ea0947a4c8e8 (diff) | |
added resizewindowpixel and movewindowpixel
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index f8ca7d91..7c6566b7 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1563,4 +1563,43 @@ SLayerSurface* CCompositor::getLayerSurfaceFromSurface(wlr_surface* pSurface) { } return nullptr; +} + +// returns a delta +Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, const Vector2D& relativeTo) { + if (!args.contains(' ')) + return relativeTo; + + std::string x = args.substr(0, args.find_first_of(' ')); + std::string y = args.substr(args.find_first_of(' ') + 1); + + if (x == "exact") { + std::string newX = y.substr(0, y.find_first_of(' ')); + std::string newY = y.substr(y.find_first_of(' ') + 1); + + if (!isNumber(newX) || !isNumber(newY)) { + Debug::log(ERR, "parseWindowVectorArgsRelative: exact args not numbers"); + return relativeTo; + } + + const int X = std::stoi(newX); + const int Y = std::stoi(newY); + + if (X < 0 || Y < 0) { + Debug::log(ERR, "parseWindowVectorArgsRelative: exact args cannot be < 0"); + return relativeTo; + } + + return Vector2D(X, Y); + } + + if (!isNumber(x) || !isNumber(y)) { + Debug::log(ERR, "parseWindowVectorArgsRelative: args not numbers"); + return relativeTo; + } + + const int X = std::stoi(x); + const int Y = std::stoi(y); + + return Vector2D(X + relativeTo.x, Y + relativeTo.y); }
\ No newline at end of file |
