aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorniki-on-github <[email protected]>2024-04-27 18:34:19 +0200
committerGitHub <[email protected]>2024-04-27 17:34:19 +0100
commit55490637aaf13c8400a0679fcf5b7fca417bc923 (patch)
treefecb473963c6fe4e263d8f2dff54f12882551bad
parente400a288d0f8ef75672cb201203b857b65b782bb (diff)
downloadHyprland-55490637aaf13c8400a0679fcf5b7fca417bc923.tar.gz
Hyprland-55490637aaf13c8400a0679fcf5b7fca417bc923.zip
windowrules: add subtract window option to move rule (#5770)
Co-authored-by: nix <nix@local>
-rw-r--r--src/events/Windows.cpp12
1 files 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) {