summaryrefslogtreecommitdiff
path: root/src/events/Windows.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-11-10 16:59:08 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-11-10 16:59:08 +0000
commitc0bb4db15c91b172bb71accee28bd338f43ee8e5 (patch)
tree260d1b65d6e44e533dcdfd2d3c8acc7b9dd1e90e /src/events/Windows.cpp
parent27cada2a023cd2448c2a870a09895931b036eb4a (diff)
add move cursor windowrule
Diffstat (limited to 'src/events/Windows.cpp')
-rw-r--r--src/events/Windows.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 2620e495..000d1e33 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -347,9 +347,15 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
} else if (r.szRule.find("move") == 0) {
try {
- const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
- const auto POSXSTR = VALUE.substr(0, VALUE.find(" "));
- const auto POSYSTR = VALUE.substr(VALUE.find(" ") + 1);
+ auto value = r.szRule.substr(r.szRule.find(" ") + 1);
+
+ const bool CURSOR = value.find("cursor") == 0;
+
+ if (CURSOR)
+ value = value.substr(value.find_first_of(' ') + 1);
+
+ const auto POSXSTR = value.substr(0, value.find(" "));
+ const auto POSYSTR = value.substr(value.find(" ") + 1);
int posX = 0;
int posY = 0;
@@ -358,16 +364,36 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const auto POSXRAW = POSXSTR.substr(5);
posX = PMONITOR->vecSize.x - (!POSXRAW.contains('%') ? std::stoi(POSXRAW) : std::stoi(POSXRAW.substr(0, POSXRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
- } else {
+
+ if (CURSOR)
+ Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
+ } else if (!CURSOR) {
posX = !POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x;
+ } else {
+ // cursor
+ if (POSXSTR == "cursor") {
+ posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x;
+ } else {
+ posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x + (!POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().x);
+ }
}
if (POSYSTR.find("100%-") == 0) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const auto POSYRAW = POSYSTR.substr(5);
posY = PMONITOR->vecSize.y - (!POSYRAW.contains('%') ? std::stoi(POSYRAW) : std::stoi(POSYRAW.substr(0, POSYRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
- } else {
+
+ if (CURSOR)
+ Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
+ } else if (!CURSOR) {
posY = !POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y;
+ } else {
+ // cursor
+ if (POSYSTR == "cursor") {
+ posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y;
+ } else {
+ posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y + (!POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().y);
+ }
}
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);