added wsbind

This commit is contained in:
vaxerski 2022-09-12 21:05:52 +02:00
parent 81f267dff9
commit 0062281092
3 changed files with 41 additions and 2 deletions

View File

@ -913,6 +913,13 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
} }
} }
void CConfigManager::handleBindWS(const std::string& command, const std::string& value) {
const auto WS = value.substr(0, value.find_first_of(','));
const auto MON = value.substr(value.find_first_of(',') + 1);
boundWorkspaces.push_back({WS, MON});
}
std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& VALUE, bool dynamic) { std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& VALUE, bool dynamic) {
if (dynamic) { if (dynamic) {
parseError = ""; parseError = "";
@ -941,6 +948,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
else if (COMMAND == "source") handleSource(COMMAND, VALUE); else if (COMMAND == "source") handleSource(COMMAND, VALUE);
else if (COMMAND == "submap") handleSubmap(COMMAND, VALUE); else if (COMMAND == "submap") handleSubmap(COMMAND, VALUE);
else if (COMMAND == "blurls") handleBlurLS(COMMAND, VALUE); else if (COMMAND == "blurls") handleBlurLS(COMMAND, VALUE);
else if (COMMAND == "wsbind") handleBindWS(COMMAND, VALUE);
else else
configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE); configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE);
@ -1052,6 +1060,7 @@ void CConfigManager::loadConfigLoadVars() {
configDynamicVars.clear(); configDynamicVars.clear();
deviceConfigs.clear(); deviceConfigs.clear();
m_dBlurLSNamespaces.clear(); m_dBlurLSNamespaces.clear();
boundWorkspaces.clear();
setDefaultAnimationVars(); // reset anims setDefaultAnimationVars(); // reset anims
// paths // paths
@ -1500,3 +1509,15 @@ void CConfigManager::addParseError(const std::string& err) {
if (parseError == "") if (parseError == "")
parseError = err; parseError = err;
} }
CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
for (auto&[ws, mon] : boundWorkspaces) {
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
if (WSNAME == wsname) {
return g_pCompositor->getMonitorFromString(mon);
}
}
return nullptr;
}

View File

@ -93,6 +93,8 @@ public:
SMonitorRule getMonitorRuleFor(std::string); SMonitorRule getMonitorRuleFor(std::string);
CMonitor* getBoundMonitorForWS(std::string);
std::vector<SWindowRule> getMatchingRules(CWindow*); std::vector<SWindowRule> getMatchingRules(CWindow*);
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas; std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@ -129,6 +131,8 @@ private:
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
std::vector<std::pair<std::string, std::string>> boundWorkspaces;
bool isFirstLaunch = true; // For exec-once bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules; std::deque<SMonitorRule> m_dMonitorRules;
@ -164,6 +168,7 @@ private:
void handleSource(const std::string&, const std::string&); void handleSource(const std::string&, const std::string&);
void handleSubmap(const std::string&, const std::string&); void handleSubmap(const std::string&, const std::string&);
void handleBlurLS(const std::string&, const std::string&); void handleBlurLS(const std::string&, const std::string&);
void handleBindWS(const std::string&, const std::string&);
}; };
inline std::unique_ptr<CConfigManager> g_pConfigManager; inline std::unique_ptr<CConfigManager> g_pConfigManager;

View File

@ -679,7 +679,9 @@ void CKeybindManager::changeworkspace(std::string args) {
} }
// Workspace doesn't exist, create and switch // Workspace doesn't exist, create and switch
const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); const auto BOUNDMON = g_pConfigManager->getBoundMonitorForWS(workspaceName);
const auto PMONITOR = BOUNDMON ? BOUNDMON : g_pCompositor->getMonitorFromCursor();
const auto OLDWORKSPACE = PMONITOR->activeWorkspace; const auto OLDWORKSPACE = PMONITOR->activeWorkspace;
@ -727,6 +729,12 @@ void CKeybindManager::changeworkspace(std::string args) {
// mark the monitor dirty // mark the monitor dirty
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
// some stuf with the cursor and focus
if (g_pCompositor->m_pLastMonitor != PMONITOR)
g_pCompositor->warpCursorTo(PMONITOR->vecPosition + PMONITOR->vecSize / 2.f);
g_pCompositor->m_pLastMonitor = PMONITOR;
// focus (clears the last) // focus (clears the last)
g_pInputManager->refocus(); g_pInputManager->refocus();
@ -872,7 +880,12 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
// may be null until later! // may be null until later!
auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo); auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo);
const auto PMONITORNEW = PWORKSPACE ? g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID) : PMONITOR; auto PMONITORNEW = PWORKSPACE ? g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID) : PMONITOR;
if (!PWORKSPACE) {
const auto BOUNDMON = g_pConfigManager->getBoundMonitorForWS(workspaceName);
if (BOUNDMON)
PMONITORNEW = BOUNDMON;
}
const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace; const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace;
const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace; const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;