summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorGartoxFR <ewan.chorynski@insa-lyon.fr>2024-03-02 01:35:17 +0100
committerGitHub <noreply@github.com>2024-03-02 00:35:17 +0000
commitb2c34404777ea0850f90f4c38f64484f03599d14 (patch)
tree60f42773d2d606ae2072884cb537c751a7ab4b0f /src/managers
parentf115ba94d2ec6e093c94f425535b027bc570185e (diff)
animations: Refactor AnimatedVariable (#4911)
* animation: Refactor AnimatedVariable This commit decomposes the AnimatedVariable class into a base class with the common attribute to all variable types and a templated derived type containing strongly typed info on the type being animated. Access to the typed version is perfomed using the visitor pattern. A utility is provided to build a visitor on the fly using lambdas. Adding a new type to be animated should just be a matter of adding the typed in the list defined by the ANIMABLE_TYPES macro The size of the commit is justified by the API change in the AnimatedVariable class. No more vec(), fl() or col() method but a unified value() method. * animation: Remove visitor pattern * animation: Fix coding style * animation: Fix coding style
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/AnimationManager.cpp111
-rw-r--r--src/managers/AnimationManager.hpp6
-rw-r--r--src/managers/KeybindManager.cpp52
-rw-r--r--src/managers/XWaylandManager.cpp6
-rw-r--r--src/managers/input/InputManager.cpp16
-rw-r--r--src/managers/input/InputMethodRelay.cpp6
-rw-r--r--src/managers/input/Swipe.cpp6
-rw-r--r--src/managers/input/Tablets.cpp2
-rw-r--r--src/managers/input/Touch.cpp4
9 files changed, 90 insertions, 119 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index 859e3b03..f9d709d3 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -1,6 +1,7 @@
#include "AnimationManager.hpp"
#include "../Compositor.hpp"
#include "HookSystemManager.hpp"
+#include "macros.hpp"
int wlTick(void* data) {
if (g_pAnimationManager)
@@ -58,11 +59,11 @@ void CAnimationManager::tick() {
if (!**PANIMENABLED)
animGlobalDisabled = true;
- static auto* const PSHADOWSENABLED = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:drop_shadow");
+ static auto* const PSHADOWSENABLED = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:drop_shadow");
- const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
+ const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
- std::vector<CAnimatedVariable*> animationEndedVars;
+ std::vector<CBaseAnimatedVariable*> animationEndedVars;
for (auto& av : m_vActiveAnimatedVariables) {
@@ -101,7 +102,7 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageWindow(w.get());
}
} else if (PLAYER) {
- WLRBOXPREV = CBox{PLAYER->realPosition.vec(), PLAYER->realSize.vec()};
+ WLRBOXPREV = CBox{PLAYER->realPosition.value(), PLAYER->realSize.value()};
PMONITOR = g_pCompositor->getMonitorFromVector(Vector2D(PLAYER->geometry.x, PLAYER->geometry.y) + Vector2D(PLAYER->geometry.width, PLAYER->geometry.height) / 2.f);
if (!PMONITOR)
continue;
@@ -113,78 +114,48 @@ void CAnimationManager::tick() {
// beziers are with a switch unforto
// TODO: maybe do something cleaner
- switch (av->m_eVarType) {
- case AVARTYPE_FLOAT: {
- // for disabled anims just warp
- if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
- av->warp(false);
- break;
- }
+ auto updateVariable = [&]<Animable T>(CAnimatedVariable<T>& av) {
+ // for disabled anims just warp
+ if (av.m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
+ av.warp(false);
+ return;
+ }
- if (SPENT >= 1.f || av->m_fBegun == av->m_fGoal) {
- av->warp(false);
- break;
- }
+ if (SPENT >= 1.f || av.m_Begun == av.m_Goal) {
+ av.warp(false);
+ return;
+ }
- const auto DELTA = av->m_fGoal - av->m_fBegun;
- const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
+ const auto DELTA = av.m_Goal - av.m_Begun;
+ const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
- if (BEZIER != m_mBezierCurves.end())
- av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA;
- else
- av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA;
+ if (BEZIER != m_mBezierCurves.end())
+ av.m_Value = av.m_Begun + DELTA * BEZIER->second.getYForPoint(SPENT);
+ else
+ av.m_Value = av.m_Begun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT);
+ };
+
+ switch (av->m_Type) {
+ case AVARTYPE_FLOAT: {
+ auto typedAv = static_cast<CAnimatedVariable<float>*>(av);
+ updateVariable(*typedAv);
break;
}
case AVARTYPE_VECTOR: {
- // for disabled anims just warp
- if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
- av->warp(false);
- break;
- }
-
- if (SPENT >= 1.f || av->m_vBegun == av->m_vGoal) {
- av->warp(false);
- break;
- }
-
- const auto DELTA = av->m_vGoal - av->m_vBegun;
- const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
-
- if (BEZIER != m_mBezierCurves.end())
- av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
- else
- av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT);
+ auto typedAv = static_cast<CAnimatedVariable<Vector2D>*>(av);
+ updateVariable(*typedAv);
break;
}
case AVARTYPE_COLOR: {
- // for disabled anims just warp
- if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
- av->warp(false);
- break;
- }
-
- if (SPENT >= 1.f || av->m_cBegun == av->m_cGoal) {
- av->warp(false);
- break;
- }
-
- const auto DELTA = av->m_cGoal - av->m_cBegun;
- const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
-
- if (BEZIER != m_mBezierCurves.end())
- av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
- else
- av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT);
+ auto typedAv = static_cast<CAnimatedVariable<CColor>*>(av);
+ updateVariable(*typedAv);
break;
}
- default: {
- ;
- }
+ default: UNREACHABLE();
}
-
// set size and pos if valid, but only if damage policy entire (dont if border for example)
if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE && PWINDOW->m_iX11Type != 2)
- g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
+ g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goal());
// check if we did not finish animating. If so, trigger onAnimationEnd.
if (!av->isBeingAnimated())
@@ -216,7 +187,7 @@ void CAnimationManager::tick() {
if (w->m_bIsFloating) {
auto bb = w->getFullWindowBoundingBox();
- bb.translate(PWORKSPACE->m_vRenderOffset.vec());
+ bb.translate(PWORKSPACE->m_vRenderOffset.value());
g_pHyprRenderer->damageBox(&bb);
}
}
@@ -250,7 +221,7 @@ void CAnimationManager::tick() {
BORDERSIZE + ROUNDINGSIZE); // bottom
// damage for new box
- const CBox WLRBOXNEW = {PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y};
+ const CBox WLRBOXNEW = {PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y, PWINDOW->m_vRealSize.value().x, PWINDOW->m_vRealSize.value().y};
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // left
g_pHyprRenderer->damageBox(WLRBOXNEW.x + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
@@ -323,23 +294,23 @@ bool CAnimationManager::bezierExists(const std::string& bezier) {
//
void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPerc) {
- const auto GOALPOS = pWindow->m_vRealPosition.goalv();
- const auto GOALSIZE = pWindow->m_vRealSize.goalv();
+ const auto GOALPOS = pWindow->m_vRealPosition.goal();
+ const auto GOALSIZE = pWindow->m_vRealSize.goal();
if (!close) {
pWindow->m_vRealSize.setValue((GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y}));
- pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vValue / 2.f);
+ pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_Value / 2.f);
} else {
pWindow->m_vRealSize = (GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y});
- pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vGoal / 2.f;
+ pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_Goal / 2.f;
}
}
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) {
pWindow->m_vRealSize.warp(false); // size we preserve in slide
- const auto GOALPOS = pWindow->m_vRealPosition.goalv();
- const auto GOALSIZE = pWindow->m_vRealSize.goalv();
+ const auto GOALPOS = pWindow->m_vRealPosition.goal();
+ const auto GOALSIZE = pWindow->m_vRealSize.goal();
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp
index 281c61f8..ae82a60b 100644
--- a/src/managers/AnimationManager.hpp
+++ b/src/managers/AnimationManager.hpp
@@ -28,8 +28,8 @@ class CAnimationManager {
std::unordered_map<std::string, CBezierCurve> getAllBeziers();
- std::vector<CAnimatedVariable*> m_vAnimatedVariables;
- std::vector<CAnimatedVariable*> m_vActiveAnimatedVariables;
+ std::vector<CBaseAnimatedVariable*> m_vAnimatedVariables;
+ std::vector<CBaseAnimatedVariable*> m_vActiveAnimatedVariables;
wl_event_source* m_pAnimationTick;
@@ -52,4 +52,4 @@ class CAnimationManager {
void animationSlide(CWindow*, std::string force = "", bool close = false);
};
-inline std::unique_ptr<CAnimationManager> g_pAnimationManager; \ No newline at end of file
+inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 58425757..1ab8fa91 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -874,8 +874,8 @@ void CKeybindManager::centerWindow(std::string args) {
if (args == "1")
RESERVEDOFFSET = (PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight) / 2.f;
- PWINDOW->m_vRealPosition = PMONITOR->middle() - PWINDOW->m_vRealSize.goalv() / 2.f + RESERVEDOFFSET;
- PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
+ PWINDOW->m_vRealPosition = PMONITOR->middle() - PWINDOW->m_vRealSize.goal() / 2.f + RESERVEDOFFSET;
+ PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goal();
}
void CKeybindManager::toggleActivePseudo(std::string args) {
@@ -1222,14 +1222,14 @@ void CKeybindManager::moveActiveTo(std::string args) {
switch (arg) {
case 'l': vPos.x = PMONITOR->vecReservedTopLeft.x + BORDERSIZE + PMONITOR->vecPosition.x; break;
- case 'r': vPos.x = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PLASTWINDOW->m_vRealSize.goalv().x - BORDERSIZE + PMONITOR->vecPosition.x; break;
+ case 'r': vPos.x = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PLASTWINDOW->m_vRealSize.goal().x - BORDERSIZE + PMONITOR->vecPosition.x; break;
case 't':
case 'u': vPos.y = PMONITOR->vecReservedTopLeft.y + BORDERSIZE + PMONITOR->vecPosition.y; break;
case 'b':
- case 'd': vPos.y = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PLASTWINDOW->m_vRealSize.goalv().y - BORDERSIZE + PMONITOR->vecPosition.y; break;
+ case 'd': vPos.y = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PLASTWINDOW->m_vRealSize.goal().y - BORDERSIZE + PMONITOR->vecPosition.y; break;
}
- PLASTWINDOW->m_vRealPosition = Vector2D(vPos.x != 0 ? vPos.x : PLASTWINDOW->m_vRealPosition.goalv().x, vPos.y != 0 ? vPos.y : PLASTWINDOW->m_vRealPosition.goalv().y);
+ PLASTWINDOW->m_vRealPosition = Vector2D(vPos.x != 0 ? vPos.x : PLASTWINDOW->m_vRealPosition.goal().x, vPos.y != 0 ? vPos.y : PLASTWINDOW->m_vRealPosition.goal().y);
return;
}
@@ -1377,22 +1377,22 @@ void CKeybindManager::moveCursorToCorner(std::string arg) {
switch (CORNER) {
case 0:
// bottom left
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x,
- PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.value().x,
+ PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y);
break;
case 1:
// bottom right
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
- PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x,
+ PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y);
break;
case 2:
// top right
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
- PWINDOW->m_vRealPosition.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x,
+ PWINDOW->m_vRealPosition.value().y);
break;
case 3:
// top left
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y);
break;
}
}
@@ -1457,8 +1457,8 @@ void CKeybindManager::workspaceOpt(std::string args) {
continue;
if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) {
- const auto SAVEDPOS = w->m_vRealPosition.vec();
- const auto SAVEDSIZE = w->m_vRealSize.vec();
+ const auto SAVEDPOS = w->m_vRealPosition.value();
+ const auto SAVEDSIZE = w->m_vRealSize.value();
w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating;
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(w);
@@ -1467,8 +1467,8 @@ void CKeybindManager::workspaceOpt(std::string args) {
w->m_vRealPosition.setValueAndWarp(SAVEDPOS);
w->m_vRealSize.setValueAndWarp(SAVEDSIZE);
g_pXWaylandManager->setWindowSize(w, SAVEDSIZE);
- w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4, 4);
- w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2, 2);
+ w->m_vRealSize = w->m_vRealSize.value() + Vector2D(4, 4);
+ w->m_vRealPosition = w->m_vRealPosition.value() - Vector2D(2, 2);
}
}
}
@@ -1651,14 +1651,14 @@ void CKeybindManager::resizeActive(std::string args) {
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
return;
- const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
+ const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealSize.goal());
if (SIZ.x < 1 || SIZ.y < 1)
return;
- g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
+ g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - g_pCompositor->m_pLastWindow->m_vRealSize.goal());
- if (g_pCompositor->m_pLastWindow->m_vRealSize.goalv().x > 1 && g_pCompositor->m_pLastWindow->m_vRealSize.goalv().y > 1)
+ if (g_pCompositor->m_pLastWindow->m_vRealSize.goal().x > 1 && g_pCompositor->m_pLastWindow->m_vRealSize.goal().y > 1)
g_pCompositor->m_pLastWindow->setHidden(false);
}
@@ -1666,9 +1666,9 @@ void CKeybindManager::moveActive(std::string args) {
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
return;
- const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
+ const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goal());
- g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
+ g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - g_pCompositor->m_pLastWindow->m_vRealPosition.goal());
}
void CKeybindManager::moveWindow(std::string args) {
@@ -1686,9 +1686,9 @@ void CKeybindManager::moveWindow(std::string args) {
if (PWINDOW->m_bIsFullscreen)
return;
- const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goalv());
+ const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goal());
- g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goalv(), PWINDOW);
+ g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goal(), PWINDOW);
}
void CKeybindManager::resizeWindow(std::string args) {
@@ -1706,14 +1706,14 @@ void CKeybindManager::resizeWindow(std::string args) {
if (PWINDOW->m_bIsFullscreen)
return;
- const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv());
+ const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goal());
if (SIZ.x < 1 || SIZ.y < 1)
return;
- g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), CORNER_NONE, PWINDOW);
+ g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goal(), CORNER_NONE, PWINDOW);
- if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1)
+ if (PWINDOW->m_vRealSize.goal().x > 1 && PWINDOW->m_vRealSize.goal().y > 1)
PWINDOW->setHidden(false);
}
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index 2dcb3bcc..f70022cf 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -55,7 +55,7 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate)
void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
if (pWindow->m_bIsX11) {
- setWindowSize(pWindow, pWindow->m_vRealSize.vec()); // update xwayland output pos
+ setWindowSize(pWindow, pWindow->m_vRealSize.value()); // update xwayland output pos
if (activate) {
wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false);
@@ -161,7 +161,7 @@ void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, Vector2D size, bool f
// calculate pos
// TODO: this should be decoupled from setWindowSize IMO
- Vector2D windowPos = pWindow->m_vRealPosition.vec();
+ Vector2D windowPos = pWindow->m_vRealPosition.value();
if (pWindow->m_bIsX11 && PMONITOR) {
windowPos = windowPos - PMONITOR->vecPosition; // normalize to monitor
@@ -266,7 +266,7 @@ void CHyprXWaylandManager::moveXWaylandWindow(CWindow* pWindow, const Vector2D&
if (!pWindow->m_bIsX11)
return;
- wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pos.x, pos.y, pWindow->m_vRealSize.vec().x, pWindow->m_vRealSize.vec().y);
+ wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pos.x, pos.y, pWindow->m_vRealSize.value().x, pWindow->m_vRealSize.value().y);
}
void CHyprXWaylandManager::checkBorders(CWindow* pWindow) {
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 2c8c2d7c..5944ba87 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -66,7 +66,7 @@ void CInputManager::sendMotionEventsToFocused() {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
- const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_vRealPosition.goalv() : (PLS ? Vector2D{PLS->geometry.x, PLS->geometry.y} : Vector2D{}));
+ const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_vRealPosition.goal() : (PLS ? Vector2D{PLS->geometry.x, PLS->geometry.y} : Vector2D{}));
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, LOCAL.x, LOCAL.y);
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, now.tv_sec * 1000 + now.tv_nsec / 10000000, LOCAL.x, LOCAL.y);
@@ -134,7 +134,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (forcedFocus) {
pFoundWindow = forcedFocus;
- surfacePos = pFoundWindow->m_vRealPosition.vec();
+ surfacePos = pFoundWindow->m_vRealPosition.value();
foundSurface = pFoundWindow->m_pWLSurface.wlr();
}
@@ -182,7 +182,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (CONSTRAINTWINDOW->m_bIsX11) {
foundSurface = CONSTRAINTWINDOW->m_pWLSurface.wlr();
- surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
+ surfacePos = CONSTRAINTWINDOW->m_vRealPosition.value();
} else {
g_pCompositor->vectorWindowToSurface(mouseCoords, CONSTRAINTWINDOW, surfaceCoords);
}
@@ -273,7 +273,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
surfacePos = Vector2D(-1337, -1337);
} else {
foundSurface = pFoundWindow->m_pWLSurface.wlr();
- surfacePos = pFoundWindow->m_vRealPosition.vec();
+ surfacePos = pFoundWindow->m_vRealPosition.value();
}
}
@@ -302,7 +302,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
} else {
foundSurface = pFoundWindow->m_pWLSurface.wlr();
- surfacePos = pFoundWindow->m_vRealPosition.vec();
+ surfacePos = pFoundWindow->m_vRealPosition.value();
}
}
}
@@ -626,7 +626,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
// TODO detect click on LS properly
if (**PRESIZEONBORDER && !m_bLastFocusOnLS && e->state == WLR_BUTTON_PRESSED) {
if (w && !w->m_bIsFullscreen) {
- const CBox real = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
+ const CBox real = {w->m_vRealPosition.value().x, w->m_vRealPosition.value().y, w->m_vRealSize.value().x, w->m_vRealSize.value().y};
const CBox grab = {real.x - BORDER_GRAB_AREA, real.y - BORDER_GRAB_AREA, real.width + 2 * BORDER_GRAB_AREA, real.height + 2 * BORDER_GRAB_AREA};
if ((grab.containsPoint(mouseCoords) && (!real.containsPoint(mouseCoords) || w->isInCurvedCorner(mouseCoords.x, mouseCoords.y))) && !w->hasPopupAt(mouseCoords)) {
@@ -1304,9 +1304,9 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
if (const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface); PWINDOW) {
const auto RELATIVETO = PWINDOW->m_bIsX11 ?
- (PWINDOW->m_bIsMapped ? PWINDOW->m_vRealPosition.goalv() :
+ (PWINDOW->m_bIsMapped ? PWINDOW->m_vRealPosition.goal() :
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y})) :
- PWINDOW->m_vRealPosition.goalv();
+ PWINDOW->m_vRealPosition.goal();
PCONSTRAINT->cursorPosOnActivate = (MOUSECOORDS - RELATIVETO) * PWINDOW->m_fX11SurfaceScaledBy;
}
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index aef9bb69..fb668cc2 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -192,8 +192,8 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
if (PWINDOW) {
- parentPos = PWINDOW->m_vRealPosition.goalv();
- parentSize = PWINDOW->m_vRealSize.goalv();
+ parentPos = PWINDOW->m_vRealPosition.goal();
+ parentSize = PWINDOW->m_vRealSize.goal();
pMonitor = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
}
}
@@ -298,7 +298,7 @@ void CInputMethodRelay::damagePopup(SIMEPopup* pPopup) {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
if (PWINDOW) {
- parentPos = PWINDOW->m_vRealPosition.goalv();
+ parentPos = PWINDOW->m_vRealPosition.goal();
}
}
diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp
index 1cc1b031..f32e983a 100644
--- a/src/managers/input/Swipe.cpp
+++ b/src/managers/input/Swipe.cpp
@@ -79,7 +79,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW || PSWIPENUMBER
auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); // not guaranteed if PSWIPENUMBER
- const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
+ const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.value();
const auto XDISTANCE = m_sActiveSwipe.pMonitor->vecSize.x + **PWORKSPACEGAP;
const auto YDISTANCE = m_sActiveSwipe.pMonitor->vecSize.y + **PWORKSPACEGAP;
@@ -118,7 +118,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
pSwitchedTo = m_sActiveSwipe.pWorkspaceBegin;
} else if (m_sActiveSwipe.delta < 0) {
// switch to left
- const auto RENDEROFFSET = PWORKSPACEL ? PWORKSPACEL->m_vRenderOffset.vec() : Vector2D();
+ const auto RENDEROFFSET = PWORKSPACEL ? PWORKSPACEL->m_vRenderOffset.value() : Vector2D();
if (PWORKSPACEL)
m_sActiveSwipe.pMonitor->changeWorkspace(workspaceIDLeft);
@@ -144,7 +144,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
pSwitchedTo = PWORKSPACEL;
} else {
// switch to right
- const auto RENDEROFFSET = PWORKSPACER ? PWORKSPACER->m_vRenderOffset.vec() : Vector2D();
+ const auto RENDEROFFSET = PWORKSPACER ? PWORKSPACER->m_vRenderOffset.value() : Vector2D();
if (PWORKSPACER)
m_sActiveSwipe.pMonitor->changeWorkspace(workspaceIDRight);
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 959ce432..f692620c 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -267,7 +267,7 @@ void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool moti
}
if (motion) {
- auto local = CURSORPOS - PWINDOW->m_vRealPosition.goalv();
+ auto local = CURSORPOS - PWINDOW->m_vRealPosition.goal();
if (PWINDOW->m_bIsX11)
local = local * PWINDOW->m_fX11SurfaceScaledBy;
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 600df302..0b26bd30 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -34,8 +34,8 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
if (m_sTouchData.touchFocusWindow) {
if (m_sTouchData.touchFocusWindow->m_bIsX11) {
- local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition.goalv()) * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
- m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_vRealPosition.goalv();
+ local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition.goal()) * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
+ m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_vRealPosition.goal();
} else {
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_sTouchData.touchFocusWindow, local);
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;