focusable checks in nextWindow calls

This commit is contained in:
vaxerski 2022-09-29 16:53:31 +01:00
parent 2636abca2d
commit 9f9129e536
3 changed files with 15 additions and 15 deletions

View file

@ -1154,7 +1154,7 @@ void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclud
} }
} }
CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) { CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
bool gotToWindow = false; bool gotToWindow = false;
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w.get() != pWindow && !gotToWindow) if (w.get() != pWindow && !gotToWindow)
@ -1165,19 +1165,19 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) {
continue; continue;
} }
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden) if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden && (!focusableOnly || !w->m_bNoFocus))
return w.get(); return w.get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden) if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden && (!focusableOnly || !w->m_bNoFocus))
return w.get(); return w.get();
} }
return nullptr; return nullptr;
} }
CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow) { CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
bool gotToWindow = false; bool gotToWindow = false;
for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) {
if (it->get() != pWindow && !gotToWindow) if (it->get() != pWindow && !gotToWindow)
@ -1188,12 +1188,12 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow) {
continue; continue;
} }
if ((*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden) if ((*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden && (!focusableOnly || !(*it)->m_bNoFocus))
return it->get(); return it->get();
} }
for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) {
if (it->get() != pWindow && (*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden) if (it->get() != pWindow && (*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden && (!focusableOnly || !(*it)->m_bNoFocus))
return it->get(); return it->get();
} }

View file

@ -138,8 +138,8 @@ public:
void cleanupFadingOut(const int& monid); void cleanupFadingOut(const int& monid);
CWindow* getWindowInDirection(CWindow*, char); CWindow* getWindowInDirection(CWindow*, char);
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr); void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
CWindow* getNextWindowOnWorkspace(CWindow*); CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
CWindow* getPrevWindowOnWorkspace(CWindow*); CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
int getNextAvailableNamedWorkspace(); int getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&); bool isPointOnAnyMonitor(const Vector2D&);
CWindow* getConstraintWindow(SMouse*); CWindow* getConstraintWindow(SMouse*);

View file

@ -1003,7 +1003,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
if (PWINDOWTOCHANGETO) { if (PWINDOWTOCHANGETO) {
switchToWindow(PWINDOWTOCHANGETO); switchToWindow(PWINDOWTOCHANGETO);
} else { } else {
const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true);
if (PWINDOWNEXT) { if (PWINDOWNEXT) {
switchToWindow(PWINDOWNEXT); switchToWindow(PWINDOWNEXT);
} }
@ -1415,9 +1415,9 @@ void CKeybindManager::circleNext(std::string arg) {
}; };
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow)); switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
else else
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow)); switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
} }
void CKeybindManager::focusWindow(std::string regexp) { void CKeybindManager::focusWindow(std::string regexp) {
@ -1577,16 +1577,16 @@ void CKeybindManager::swapnext(std::string arg) {
const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) && g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ? g_pCompositor->m_pLastWindow->m_pLastCycledWindow : nullptr; const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) && g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ? g_pCompositor->m_pLastWindow->m_pLastCycledWindow : nullptr;
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
else else
toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
// sometimes we may come back to ourselves. // sometimes we may come back to ourselves.
if (toSwap == PLASTWINDOW) { if (toSwap == PLASTWINDOW) {
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW); toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW), true;
else else
toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true);
} }
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap);