mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 00:42:11 +01:00
better keyboard window switching
This commit is contained in:
parent
a558bcdfbf
commit
158af1eb09
3 changed files with 45 additions and 5 deletions
|
@ -649,4 +649,27 @@ void CCompositor::deactivateAllWLRWorkspaces() {
|
||||||
if (w.m_pWlrHandle)
|
if (w.m_pWlrHandle)
|
||||||
wlr_ext_workspace_handle_v1_set_active(w.m_pWlrHandle, false);
|
wlr_ext_workspace_handle_v1_set_active(w.m_pWlrHandle, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) {
|
||||||
|
bool gotToWindow = false;
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
if (&w != pWindow && !gotToWindow)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (&w == pWindow) {
|
||||||
|
gotToWindow = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w.m_iWorkspaceID == pWindow->m_iWorkspaceID && windowValidMapped(&w))
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
if (&w != pWindow && w.m_iWorkspaceID == pWindow->m_iWorkspaceID && windowValidMapped(&w))
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
|
@ -103,6 +103,7 @@ public:
|
||||||
void cleanupWindows();
|
void cleanupWindows();
|
||||||
CWindow* getWindowInDirection(CWindow*, char);
|
CWindow* getWindowInDirection(CWindow*, char);
|
||||||
void deactivateAllWLRWorkspaces();
|
void deactivateAllWLRWorkspaces();
|
||||||
|
CWindow* getNextWindowOnWorkspace(CWindow*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
|
|
|
@ -281,16 +281,32 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
||||||
|
|
||||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
||||||
|
|
||||||
if (PWINDOWTOCHANGETO) {
|
if (PWINDOWTOCHANGETO) {
|
||||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
switchToWindow(PWINDOWTOCHANGETO);
|
||||||
Vector2D middle = PWINDOWTOCHANGETO->m_vPosition + PWINDOWTOCHANGETO->m_vSize / 2.f;
|
} else {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
|
const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW);
|
||||||
}
|
if (PWINDOWNEXT) {
|
||||||
|
switchToWindow(PWINDOWNEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::toggleGroup(std::string args) {
|
void CKeybindManager::toggleGroup(std::string args) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue