diff options
| author | GartoxFR <ewan.chorynski@insa-lyon.fr> | 2024-03-02 01:35:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-02 00:35:17 +0000 |
| commit | b2c34404777ea0850f90f4c38f64484f03599d14 (patch) | |
| tree | 60f42773d2d606ae2072884cb537c751a7ab4b0f /src/managers/input | |
| parent | f115ba94d2ec6e093c94f425535b027bc570185e (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/input')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 16 | ||||
| -rw-r--r-- | src/managers/input/InputMethodRelay.cpp | 6 | ||||
| -rw-r--r-- | src/managers/input/Swipe.cpp | 6 | ||||
| -rw-r--r-- | src/managers/input/Tablets.cpp | 2 | ||||
| -rw-r--r-- | src/managers/input/Touch.cpp | 4 |
5 files changed, 17 insertions, 17 deletions
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; |
