mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:45:59 +01:00
windowrules: add onworkspace
cool
This commit is contained in:
parent
48ecb13b14
commit
4eb42fab7b
5 changed files with 57 additions and 15 deletions
|
@ -1814,6 +1814,15 @@ void CCompositor::updateAllWindowsAnimatedDecorationValues() {
|
|||
}
|
||||
}
|
||||
|
||||
void CCompositor::updateWorkspaceWindows(const int64_t& id) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (!w->m_bIsMapped || w->m_iWorkspaceID != id)
|
||||
continue;
|
||||
|
||||
w->updateDynamicRules();
|
||||
}
|
||||
}
|
||||
|
||||
void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||
// optimization
|
||||
static auto* const ACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.active_border")->data.get();
|
||||
|
@ -2643,6 +2652,9 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
|
|||
|
||||
if (FULLSCREEN)
|
||||
setWindowFullscreen(pWindow, true, FULLSCREENMODE);
|
||||
|
||||
g_pCompositor->updateWorkspaceWindows(pWorkspace->m_iID);
|
||||
g_pCompositor->updateWorkspaceWindows(pWindow->m_iWorkspaceID);
|
||||
}
|
||||
|
||||
CWindow* CCompositor::getForceFocus() {
|
||||
|
|
|
@ -172,6 +172,7 @@ class CCompositor {
|
|||
CWindow* getConstraintWindow(SMouse*);
|
||||
CMonitor* getMonitorInDirection(const char&);
|
||||
void updateAllWindowsAnimatedDecorationValues();
|
||||
void updateWorkspaceWindows(const int64_t& id);
|
||||
void updateWindowAnimatedDecorationValues(CWindow*);
|
||||
int getNextAvailableMonitorID(std::string const& name);
|
||||
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
|
||||
|
|
|
@ -448,6 +448,8 @@ void CWindow::onUnmap() {
|
|||
|
||||
if (PMONITOR && PMONITOR->solitaryClient == this)
|
||||
PMONITOR->solitaryClient = nullptr;
|
||||
|
||||
g_pCompositor->updateWorkspaceWindows(m_iWorkspaceID);
|
||||
}
|
||||
|
||||
void CWindow::onMap() {
|
||||
|
@ -485,6 +487,8 @@ void CWindow::onMap() {
|
|||
"CWindow");
|
||||
|
||||
m_vReportedSize = m_vPendingReportedSize;
|
||||
|
||||
g_pCompositor->updateWorkspaceWindows(m_iWorkspaceID);
|
||||
}
|
||||
|
||||
void CWindow::onBorderAngleAnimEnd(void* ptr) {
|
||||
|
|
|
@ -156,6 +156,7 @@ struct SWindowRule {
|
|||
int bFullscreen = -1;
|
||||
int bPinned = -1;
|
||||
int bFocus = -1;
|
||||
int iOnWorkspace = -1;
|
||||
std::string szWorkspace = ""; // empty means any
|
||||
};
|
||||
|
||||
|
|
|
@ -1032,11 +1032,22 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
|||
const auto FLOATPOS = VALUE.find("floating:");
|
||||
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
|
||||
const auto PINNEDPOS = VALUE.find("pinned:");
|
||||
const auto WORKSPACEPOS = VALUE.find("workspace:");
|
||||
const auto FOCUSPOS = VALUE.find("focus:");
|
||||
const auto ONWORKSPACEPOS = VALUE.find("onworkspace:");
|
||||
|
||||
// find workspacepos that isn't onworkspacepos
|
||||
size_t WORKSPACEPOS = std::string::npos;
|
||||
size_t currentPos = 0;
|
||||
while (currentPos != std::string::npos) {
|
||||
if (currentPos > 0 && VALUE[currentPos - 1] != 'n') {
|
||||
WORKSPACEPOS = currentPos;
|
||||
break;
|
||||
}
|
||||
currentPos = VALUE.find("workspace:", currentPos + 1);
|
||||
}
|
||||
|
||||
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos &&
|
||||
PINNEDPOS == std::string::npos && WORKSPACEPOS == std::string::npos && FOCUSPOS == std::string::npos) {
|
||||
PINNEDPOS == std::string::npos && WORKSPACEPOS == std::string::npos && FOCUSPOS == std::string::npos && ONWORKSPACEPOS == std::string::npos) {
|
||||
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
|
||||
parseError = "Invalid rulev2 syntax: " + VALUE;
|
||||
return;
|
||||
|
@ -1059,6 +1070,8 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
|||
min = FULLSCREENPOS;
|
||||
if (PINNEDPOS > pos && PINNEDPOS < min)
|
||||
min = PINNEDPOS;
|
||||
if (ONWORKSPACEPOS > pos && ONWORKSPACEPOS < min)
|
||||
min = ONWORKSPACEPOS;
|
||||
if (WORKSPACEPOS > pos && WORKSPACEPOS < min)
|
||||
min = WORKSPACEPOS;
|
||||
if (FOCUSPOS > pos && FOCUSPOS < min)
|
||||
|
@ -1098,6 +1111,9 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
|||
if (FOCUSPOS != std::string::npos)
|
||||
rule.bFocus = extract(FOCUSPOS + 6) == "1" ? 1 : 0;
|
||||
|
||||
if (ONWORKSPACEPOS != std::string::npos)
|
||||
rule.iOnWorkspace = configStringToInt(extract(ONWORKSPACEPOS + 12));
|
||||
|
||||
if (RULE == "unset") {
|
||||
std::erase_if(m_dWindowRules, [&](const SWindowRule& other) {
|
||||
if (!other.v2) {
|
||||
|
@ -1127,6 +1143,9 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
|||
if (rule.bFocus != -1 && rule.bFocus != other.bFocus)
|
||||
return false;
|
||||
|
||||
if (rule.iOnWorkspace != -1 && rule.iOnWorkspace != other.iOnWorkspace)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -2012,6 +2031,11 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (rule.iOnWorkspace != -1) {
|
||||
if (rule.iOnWorkspace != g_pCompositor->getWindowsOnWorkspace(pWindow->m_iWorkspaceID))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rule.szWorkspace.empty()) {
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue