diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 8d24e8dd..8eb75002 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1775,4 +1775,15 @@ void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) { g_pXWaylandManager->setWindowSize(w.get(), w->m_vRealSize.vec(), true); } } -} \ No newline at end of file +} + +bool CCompositor::cursorOnReservedArea() { + const auto PMONITOR = getMonitorFromCursor(); + + const auto XY1 = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; + const auto XY2 = PMONITOR->vecPosition + PMONITOR->vecSize - PMONITOR->vecReservedBottomRight; + + const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal(); + + return !VECINRECT(CURSORPOS, XY1.x, XY1.y, XY2.x, XY2.y); +} diff --git a/src/Compositor.hpp b/src/Compositor.hpp index e3b4bbbc..216e5e59 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -164,6 +164,7 @@ public: void closeWindow(CWindow*); Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&); void forceReportSizesToWindowsOnWorkspace(const int&); + bool cursorOnReservedArea(); std::string explicitConfigPath; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9371d7fd..edb6cfde 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -653,7 +653,11 @@ void CKeybindManager::changeworkspace(std::string args) { // warp and focus if (anotherMonitor) g_pCompositor->warpCursorTo(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f); + g_pCompositor->focusWindow(PWINDOW, g_pXWaylandManager->getWindowSurface(PWINDOW)); + + if (g_pCompositor->cursorOnReservedArea()) // fix focus on bars etc + g_pInputManager->refocus(); } else g_pInputManager->refocus();