summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-18 21:20:01 +0100
committerVaxry <vaxry@vaxry.net>2024-05-18 21:20:01 +0100
commitf8857e6072bd85b95393499688872aaf7f088b5b (patch)
tree692865dffc79f97ad6cdd8b6f52a818dbc2b8c79 /src/managers/input/InputManager.cpp
parentc21a5a934061c248ff1cdd459a74a05b621fb427 (diff)
input: find surface pos correctly when mouse drag is active
fixes #6144
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index e05520f4..f4f97236 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -222,26 +222,29 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// if we are holding a pointer button,
// and we're not dnd-ing, don't refocus. Keep focus on last surface.
if (!PROTO::data->dndActive() && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_pLastFocus && g_pSeatManager->state.pointerFocus && !m_bHardInput) {
- foundSurface = g_pSeatManager->state.pointerFocus;
- pFoundLayerSurface = g_pCompositor->getLayerSurfaceFromSurface(foundSurface);
- if (pFoundLayerSurface) {
- surfacePos = pFoundLayerSurface->position;
+ foundSurface = g_pSeatManager->state.pointerFocus;
+
+ // IME popups aren't desktop-like elements
+ // TODO: make them.
+ CInputPopup* foundPopup = m_sIMERelay.popupFromSurface(foundSurface);
+ if (foundPopup) {
+ surfacePos = foundPopup->globalBox().pos();
m_bFocusHeldByButtons = true;
m_bRefocusHeldByButtons = refocus;
} else {
- CInputPopup* foundPopup = m_sIMERelay.popupFromSurface(foundSurface);
- if (foundPopup) {
- surfacePos = foundPopup->globalBox().pos();
- m_bFocusHeldByButtons = true;
- m_bRefocusHeldByButtons = refocus;
- } else if (!g_pCompositor->m_pLastWindow.expired()) {
- foundSurface = g_pSeatManager->state.pointerFocus;
- pFoundWindow = g_pCompositor->m_pLastWindow.lock();
-
- surfaceCoords = g_pCompositor->vectorToSurfaceLocal(mouseCoords, pFoundWindow, foundSurface);
- m_bFocusHeldByButtons = true;
- m_bRefocusHeldByButtons = refocus;
- }
+ auto HLSurface = CWLSurface::surfaceFromWlr(foundSurface);
+
+ if (HLSurface) {
+ const auto BOX = HLSurface->getSurfaceBoxGlobal();
+
+ if (BOX) {
+ surfacePos = BOX->pos();
+ pFoundLayerSurface = HLSurface->getLayer();
+ pFoundWindow = HLSurface->getWindow();
+ } else // reset foundSurface, find one normally
+ foundSurface = nullptr;
+ } else // reset foundSurface, find one normally
+ foundSurface = nullptr;
}
}