From 55490637aaf13c8400a0679fcf5b7fca417bc923 Mon Sep 17 00:00:00 2001 From: niki-on-github <63949202+niki-on-github@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:34:19 +0200 Subject: [PATCH] windowrules: add subtract window option to move rule (#5770) Co-authored-by: nix --- src/events/Windows.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 54a5486c..53539eee 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -387,10 +387,14 @@ void Events::listener_mapWindow(void* owner, void* data) { int posY = 0; if (POSXSTR.starts_with("100%-")) { - const auto POSXRAW = POSXSTR.substr(5); + const bool subtractWindow = POSXSTR.starts_with("100%-w-"); + const auto POSXRAW = (subtractWindow) ? POSXSTR.substr(7) : POSXSTR.substr(5); posX = PMONITOR->vecSize.x - (!POSXRAW.contains('%') ? std::stoi(POSXRAW) : std::stof(POSXRAW.substr(0, POSXRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.x); + if (subtractWindow) + posX -= PWINDOW->m_vRealSize.goal().x; + if (CURSOR) Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!"); } else if (!CURSOR) { @@ -406,10 +410,14 @@ void Events::listener_mapWindow(void* owner, void* data) { } if (POSYSTR.starts_with("100%-")) { - const auto POSYRAW = POSYSTR.substr(5); + const bool subtractWindow = POSYSTR.starts_with("100%-w-"); + const auto POSYRAW = (subtractWindow) ? POSYSTR.substr(7) : POSYSTR.substr(5); posY = PMONITOR->vecSize.y - (!POSYRAW.contains('%') ? std::stoi(POSYRAW) : std::stof(POSYRAW.substr(0, POSYRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.y); + if (subtractWindow) + posY -= PWINDOW->m_vRealSize.goal().y; + if (CURSOR) Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!"); } else if (!CURSOR) {