From b0b3a5af100d6c68a30230c5b5eafd8087703a99 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Mon, 15 Aug 2022 15:59:07 +0200 Subject: added resizewindowpixel and movewindowpixel --- src/Compositor.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/Compositor.cpp') 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 -- cgit v1.2.3