From 26cd1bf949d0460b754fe3b1ae7f06bd4b2535ee Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 9 Mar 2024 18:12:55 +0000 Subject: [PATCH] input: fix minor default cursor reset conditions --- src/events/Layers.cpp | 4 +++- src/events/Windows.cpp | 3 +++ src/managers/input/InputManager.cpp | 2 ++ src/managers/input/InputManager.hpp | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp index db237690..4e61baa0 100644 --- a/src/events/Layers.cpp +++ b/src/events/Layers.cpp @@ -154,6 +154,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) { g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y); wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y); + g_pInputManager->m_bEmptyFocusCursorSet = false; } layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y); @@ -235,7 +236,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) { foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface); - if (!foundSurface) { + if (!foundSurface && g_pCompositor->m_pLastWindow) { // if there isn't any, focus the last window const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->focusWindow(nullptr); @@ -347,6 +348,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) { g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y); wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y); + g_pInputManager->m_bEmptyFocusCursorSet = false; } else if (!layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pInputManager->isConstrained()) && layersurface->keyboardExclusive) { g_pInputManager->refocus(); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 84040ad5..2da54583 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -716,6 +716,9 @@ void Events::listener_unmapWindow(void* owner, void* data) { if (PWINDOWCANDIDATE != g_pCompositor->m_pLastWindow && PWINDOWCANDIDATE) g_pCompositor->focusWindow(PWINDOWCANDIDATE); + if (!PWINDOWCANDIDATE && g_pCompositor->getWindowsOnWorkspace(PWINDOW->m_iWorkspaceID) == 0) + g_pInputManager->refocus(); + g_pInputManager->sendMotionEventsToFocused(); // CWindow::onUnmap will remove this window's active status, but we can't really do it above. diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 32a9fbae..9072f27a 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -69,6 +69,8 @@ void CInputManager::sendMotionEventsToFocused() { const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_vRealPosition.goal() : (PLS ? Vector2D{PLS->geometry.x, PLS->geometry.y} : Vector2D{})); + m_bEmptyFocusCursorSet = false; + 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); } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index cef8386f..fd3aefe5 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -191,13 +191,15 @@ class CInputManager { CWindow* m_pLastMouseFocus = nullptr; wlr_surface* m_pLastMouseSurface = nullptr; + // + bool m_bEmptyFocusCursorSet = false; + private: bool m_bCursorImageOverridden = false; eBorderIconDirection m_eBorderIconDirection = BORDERICON_NONE; // for click behavior override eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT; - bool m_bEmptyFocusCursorSet = false; Vector2D m_vLastCursorPosFloored = Vector2D(); void processMouseDownNormal(wlr_pointer_button_event* e);