summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authoroutfoxxed <outfoxxed@outfoxxed.me>2025-05-16 14:39:28 -0700
committerGitHub <noreply@github.com>2025-05-16 23:39:28 +0200
commit2946009006bd8a988ff8a51b83528f6e1d8f0e98 (patch)
tree3ba2fde27a74b8cea0b4a70efbfb2db66639b67b /src/managers/input/InputManager.cpp
parentb0cc49218d37e6e791725b40fe5da97832daa9c8 (diff)
input: do not send mouse events when outside of a surface (#10416)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index cd603ca5..cc46aaec 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -201,6 +201,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
Vector2D surfacePos = Vector2D(-1337, -1337);
PHLWINDOW pFoundWindow;
PHLLS pFoundLayerSurface;
+ bool sendExternalMouseEvents = false;
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
@@ -297,7 +298,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
// and we're not dnd-ing, don't refocus. Keep focus on last surface.
if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped &&
g_pSeatManager->m_state.pointerFocus && !m_hardInput) {
- foundSurface = g_pSeatManager->m_state.pointerFocus.lock();
+ foundSurface = g_pSeatManager->m_state.pointerFocus.lock();
+ sendExternalMouseEvents = true;
// IME popups aren't desktop-like elements
// TODO: make them.
@@ -598,6 +600,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
m_lastFocusOnLS = true;
}
+ // Don't send events outside of the surface unless holding a mouse button,
+ // except for X11 surfaces which are always sent events in case of potential breakage.
+ if (!sendExternalMouseEvents && foundSurface && (!pFoundWindow || !pFoundWindow->m_isX11)) {
+ if (!foundSurface->at(surfaceLocal, true).first)
+ foundSurface = nullptr;
+ }
+
g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal);
g_pSeatManager->sendPointerMotion(time, surfaceLocal);
}