summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-09-03 15:35:53 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-09-03 15:35:53 +0200
commitf4add0ac6d633379ade7470a5e6b4afd45f4a073 (patch)
treec3f283024c927191d4e609f8651081cad92b7991 /src
parent3c3f80c2fe093303b84cd52be22b523ea06a3c6e (diff)
refocus on reserved area
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp13
-rw-r--r--src/Compositor.hpp1
-rw-r--r--src/managers/KeybindManager.cpp4
3 files changed, 17 insertions, 1 deletions
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();