better keyboard window switching

This commit is contained in:
vaxerski
2022-04-13 20:45:06 +02:00
parent a558bcdfbf
commit 158af1eb09
3 changed files with 45 additions and 5 deletions

View File

@@ -281,16 +281,32 @@ void CKeybindManager::moveFocusTo(std::string args) {
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PLASTWINDOW))
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = PWINDOWTOCHANGETO->m_vEffectivePosition + PWINDOWTOCHANGETO->m_vEffectiveSize / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
};
if (!g_pCompositor->windowValidMapped(PLASTWINDOW)) {
const auto PWINDOWTOCHANGETO = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace);
if (!PWINDOWTOCHANGETO)
return;
switchToWindow(PWINDOWTOCHANGETO);
return;
}
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
if (PWINDOWTOCHANGETO) {
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = PWINDOWTOCHANGETO->m_vPosition + PWINDOWTOCHANGETO->m_vSize / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
}
switchToWindow(PWINDOWTOCHANGETO);
} else {
const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW);
if (PWINDOWNEXT) {
switchToWindow(PWINDOWNEXT);
}
}
}
void CKeybindManager::toggleGroup(std::string args) {