summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-09-12 21:05:52 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-09-12 21:05:52 +0200
commit006228109281ed4d07ace635cf419c605d62e4a6 (patch)
tree41f723bf0addc7d35ee341c151169a32a4f043ec /src
parent81f267dff95f16a6442688dbeaf25fb01b818a04 (diff)
added wsbind
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp21
-rw-r--r--src/config/ConfigManager.hpp5
-rw-r--r--src/managers/KeybindManager.cpp17
3 files changed, 41 insertions, 2 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index d25ea2cb..96a8f4da 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -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) {
if (dynamic) {
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 == "submap") handleSubmap(COMMAND, VALUE);
else if (COMMAND == "blurls") handleBlurLS(COMMAND, VALUE);
+ else if (COMMAND == "wsbind") handleBindWS(COMMAND, VALUE);
else
configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE);
@@ -1052,6 +1060,7 @@ void CConfigManager::loadConfigLoadVars() {
configDynamicVars.clear();
deviceConfigs.clear();
m_dBlurLSNamespaces.clear();
+ boundWorkspaces.clear();
setDefaultAnimationVars(); // reset anims
// paths
@@ -1500,3 +1509,15 @@ void CConfigManager::addParseError(const std::string& err) {
if (parseError == "")
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;
+}
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index c719c317..1f14d019 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -93,6 +93,8 @@ public:
SMonitorRule getMonitorRuleFor(std::string);
+ CMonitor* getBoundMonitorForWS(std::string);
+
std::vector<SWindowRule> getMatchingRules(CWindow*);
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@@ -129,6 +131,8 @@ private:
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
std::deque<SMonitorRule> m_dMonitorRules;
@@ -164,6 +168,7 @@ private:
void handleSource(const std::string&, const std::string&);
void handleSubmap(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;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 821b0588..6b6f8f3c 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -679,7 +679,9 @@ void CKeybindManager::changeworkspace(std::string args) {
}
// 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;
@@ -727,6 +729,12 @@ void CKeybindManager::changeworkspace(std::string args) {
// mark the monitor dirty
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)
g_pInputManager->refocus();
@@ -872,7 +880,12 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
// may be null until later!
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 OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;