summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-12-16 15:18:45 +0000
committerVaxry <vaxry@vaxry.net>2025-12-16 15:18:53 +0000
commitbeb1b578e89a21a32f6d0685dc52b7503c9541ff (patch)
tree5c6aed13d44f52a0ab19d4be85b9caed5d8a9ccc /src/managers/input/InputManager.cpp
parentc5beecb2c31eeee470027a45d4737b716841215d (diff)
input: cleanup sendMotionEventsToFocused()
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 98662d12..6908838e 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -7,8 +7,7 @@
#include <algorithm>
#include "../../config/ConfigValue.hpp"
#include "../../config/ConfigManager.hpp"
-#include "../../desktop/view/Window.hpp"
-#include "../../desktop/view/LayerSurface.hpp"
+#include "../../desktop/view/WLSurface.hpp"
#include "../../desktop/state/FocusState.hpp"
#include "../../protocols/CursorShape.hpp"
#include "../../protocols/IdleInhibit.hpp"
@@ -172,15 +171,29 @@ void CInputManager::sendMotionEventsToFocused() {
if (!Desktop::focusState()->surface() || isConstrained())
return;
- // todo: this sucks ass
- const auto PWINDOW = g_pCompositor->getWindowFromSurface(Desktop::focusState()->surface());
- const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(Desktop::focusState()->surface());
+ const auto SURF = Desktop::focusState()->surface();
- const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_realPosition->goal() : (PLS ? Vector2D{PLS->m_geometry.x, PLS->m_geometry.y} : Vector2D{}));
+ if (!SURF)
+ return;
+
+ const auto HLSurf = Desktop::View::CWLSurface::fromResource(SURF);
+
+ if (!HLSurf || !HLSurf->view())
+ return;
+
+ const auto VIEW = HLSurf->view();
+
+ if (!VIEW->aliveAndVisible())
+ return;
+
+ const auto BOX = HLSurf->getSurfaceBoxGlobal();
+
+ if (!BOX)
+ return;
m_emptyFocusCursorSet = false;
- g_pSeatManager->setPointerFocus(Desktop::focusState()->surface(), LOCAL);
+ g_pSeatManager->setPointerFocus(Desktop::focusState()->surface(), m_lastCursorPosFloored - BOX->pos());
}
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, std::optional<Vector2D> overridePos) {