mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-02 21:21:55 -07:00
desktop: add ability to target pinned windows in workspace rules (#9344)
* desktop: add ability to target pinned windows in workspace rules * desktop: add ability to target pinned windows in workspace rules * fix formating
This commit is contained in:
@@ -261,6 +261,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
// n - named: n[true] or n[s:string] or n[e:string]
|
// n - named: n[true] or n[s:string] or n[e:string]
|
||||||
// m - monitor: m[monitor_selector]
|
// m - monitor: m[monitor_selector]
|
||||||
// w - windowCount: w[1-4] or w[1], optional flag t or f for tiled or floating and
|
// w - windowCount: w[1-4] or w[1], optional flag t or f for tiled or floating and
|
||||||
|
// flag p to count only pinned windows, e.g. w[p1-2], w[pg4]
|
||||||
// flag g to count groups instead of windows, e.g. w[t1-2], w[fg4]
|
// flag g to count groups instead of windows, e.g. w[t1-2], w[fg4]
|
||||||
// flag v will count only visible windows
|
// flag v will count only visible windows
|
||||||
// f - fullscreen state : f[-1], f[0], f[1], or f[2] for different fullscreen states
|
// f - fullscreen state : f[-1], f[0], f[1], or f[2] for different fullscreen states
|
||||||
@@ -370,6 +371,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
prop = prop.substr(2, prop.length() - 3);
|
prop = prop.substr(2, prop.length() - 3);
|
||||||
|
|
||||||
int wantsOnlyTiled = -1;
|
int wantsOnlyTiled = -1;
|
||||||
|
int wantsOnlyPinned = false;
|
||||||
bool wantsCountGroup = false;
|
bool wantsCountGroup = false;
|
||||||
bool wantsCountVisible = false;
|
bool wantsCountVisible = false;
|
||||||
|
|
||||||
@@ -381,6 +383,9 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
} else if (flag == 'f' && wantsOnlyTiled == -1) {
|
} else if (flag == 'f' && wantsOnlyTiled == -1) {
|
||||||
wantsOnlyTiled = 0;
|
wantsOnlyTiled = 0;
|
||||||
flagCount++;
|
flagCount++;
|
||||||
|
} else if (flag == 'p' && !wantsOnlyPinned) {
|
||||||
|
wantsOnlyPinned = true;
|
||||||
|
flagCount++;
|
||||||
} else if (flag == 'g' && !wantsCountGroup) {
|
} else if (flag == 'g' && !wantsCountGroup) {
|
||||||
wantsCountGroup = true;
|
wantsCountGroup = true;
|
||||||
flagCount++;
|
flagCount++;
|
||||||
@@ -411,9 +416,11 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
int count;
|
int count;
|
||||||
if (wantsCountGroup)
|
if (wantsCountGroup)
|
||||||
count = getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
count = getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
||||||
|
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
|
||||||
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
||||||
else
|
else
|
||||||
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
||||||
|
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
|
||||||
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
||||||
|
|
||||||
if (count != from)
|
if (count != from)
|
||||||
@@ -444,10 +451,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
|
|
||||||
WORKSPACEID count;
|
WORKSPACEID count;
|
||||||
if (wantsCountGroup)
|
if (wantsCountGroup)
|
||||||
count = getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
count =
|
||||||
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
||||||
|
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
||||||
else
|
else
|
||||||
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
|
||||||
|
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
|
||||||
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
|
||||||
|
|
||||||
if (std::clamp(count, from, to) != count)
|
if (std::clamp(count, from, to) != count)
|
||||||
@@ -535,13 +544,15 @@ bool CWorkspace::isVisibleNotCovered() {
|
|||||||
return PMONITOR->activeWorkspace->m_iID == m_iID;
|
return PMONITOR->activeWorkspace->m_iID == m_iID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> onlyVisible) {
|
int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
|
||||||
int no = 0;
|
int no = 0;
|
||||||
for (auto const& w : g_pCompositor->m_vWindows) {
|
for (auto const& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
||||||
continue;
|
continue;
|
||||||
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
|
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
|
||||||
continue;
|
continue;
|
||||||
|
if (onlyPinned.has_value() && w->m_bPinned != onlyPinned.value())
|
||||||
|
continue;
|
||||||
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
|
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
|
||||||
continue;
|
continue;
|
||||||
no++;
|
no++;
|
||||||
@@ -550,7 +561,7 @@ int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> on
|
|||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyVisible) {
|
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
|
||||||
int no = 0;
|
int no = 0;
|
||||||
for (auto const& w : g_pCompositor->m_vWindows) {
|
for (auto const& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
||||||
@@ -559,6 +570,8 @@ int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onl
|
|||||||
continue;
|
continue;
|
||||||
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
|
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
|
||||||
continue;
|
continue;
|
||||||
|
if (onlyPinned.has_value() && w->m_bPinned != onlyPinned.value())
|
||||||
|
continue;
|
||||||
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
|
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
|
||||||
continue;
|
continue;
|
||||||
no++;
|
no++;
|
||||||
|
@@ -72,8 +72,8 @@ class CWorkspace {
|
|||||||
SWorkspaceIDName getPrevWorkspaceIDName() const;
|
SWorkspaceIDName getPrevWorkspaceIDName() const;
|
||||||
void updateWindowDecos();
|
void updateWindowDecos();
|
||||||
void updateWindowData();
|
void updateWindowData();
|
||||||
int getWindows(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
int getWindows(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
||||||
int getGroups(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
int getGroups(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
||||||
bool hasUrgentWindow();
|
bool hasUrgentWindow();
|
||||||
PHLWINDOW getFirstWindow();
|
PHLWINDOW getFirstWindow();
|
||||||
PHLWINDOW getTopLeftWindow();
|
PHLWINDOW getTopLeftWindow();
|
||||||
|
Reference in New Issue
Block a user