mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 04:45:59 +01:00
dispatchers: add tiled/floating to cyclenext
This commit is contained in:
parent
ff75f991a5
commit
5aab4a96e3
4 changed files with 36 additions and 7 deletions
|
@ -1624,7 +1624,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
|
CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||||
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)
|
||||||
|
@ -1635,11 +1635,17 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
|
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
@ -1647,7 +1653,7 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
|
CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||||
bool gotToWindow = false;
|
bool gotToWindow = false;
|
||||||
for (auto& w : m_vWindows | std::views::reverse) {
|
for (auto& w : m_vWindows | std::views::reverse) {
|
||||||
if (w.get() != pWindow && !gotToWindow)
|
if (w.get() != pWindow && !gotToWindow)
|
||||||
|
@ -1658,11 +1664,17 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& w : m_vWindows | std::views::reverse) {
|
for (auto& w : m_vWindows | std::views::reverse) {
|
||||||
|
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,8 @@ class CCompositor {
|
||||||
void changeWindowZOrder(CWindow*, bool);
|
void changeWindowZOrder(CWindow*, bool);
|
||||||
void cleanupFadingOut(const int& monid);
|
void cleanupFadingOut(const int& monid);
|
||||||
CWindow* getWindowInDirection(CWindow*, char);
|
CWindow* getWindowInDirection(CWindow*, char);
|
||||||
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||||
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||||
int getNextAvailableNamedWorkspace();
|
int getNextAvailableNamedWorkspace();
|
||||||
bool isPointOnAnyMonitor(const Vector2D&);
|
bool isPointOnAnyMonitor(const Vector2D&);
|
||||||
CWindow* getConstraintWindow(SMouse*);
|
CWindow* getConstraintWindow(SMouse*);
|
||||||
|
|
|
@ -50,6 +50,15 @@ class CVarList {
|
||||||
return m_vArgs.end();
|
return m_vArgs.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool contains(const std::string& el) {
|
||||||
|
for (auto& a : m_vArgs) {
|
||||||
|
if (a == el)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_vArgs;
|
std::vector<std::string> m_vArgs;
|
||||||
};
|
};
|
|
@ -1571,10 +1571,18 @@ void CKeybindManager::circleNext(std::string arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
CVarList args{arg, 0, 's', true};
|
||||||
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
|
|
||||||
|
std::optional<bool> floatStatus = {};
|
||||||
|
if (args.contains("tile") || args.contains("tiled"))
|
||||||
|
floatStatus = false;
|
||||||
|
else if (args.contains("float") || args.contains("floating"))
|
||||||
|
floatStatus = true;
|
||||||
|
|
||||||
|
if (args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l"))
|
||||||
|
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow, true, floatStatus));
|
||||||
else
|
else
|
||||||
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
|
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow, true, floatStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::focusWindow(std::string regexp) {
|
void CKeybindManager::focusWindow(std::string regexp) {
|
||||||
|
|
Loading…
Reference in a new issue