mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-17 13:03:48 -07:00
input: do not send mouse events when outside of a surface (#10416)
This commit is contained in:
@@ -201,6 +201,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
|
|||||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||||
PHLWINDOW pFoundWindow;
|
PHLWINDOW pFoundWindow;
|
||||||
PHLLS pFoundLayerSurface;
|
PHLLS pFoundLayerSurface;
|
||||||
|
bool sendExternalMouseEvents = false;
|
||||||
|
|
||||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
|
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
|
||||||
|
|
||||||
@@ -298,6 +299,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
|
|||||||
if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped &&
|
if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped &&
|
||||||
g_pSeatManager->m_state.pointerFocus && !m_hardInput) {
|
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
|
// IME popups aren't desktop-like elements
|
||||||
// TODO: make them.
|
// TODO: make them.
|
||||||
@@ -598,6 +600,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
|
|||||||
m_lastFocusOnLS = true;
|
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->setPointerFocus(foundSurface, surfaceLocal);
|
||||||
g_pSeatManager->sendPointerMotion(time, surfaceLocal);
|
g_pSeatManager->sendPointerMotion(time, surfaceLocal);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user