diff options
author | vaxerski <[email protected]> | 2022-06-21 22:25:54 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-06-21 22:25:54 +0200 |
commit | 84d6e640ff6e48c8161e1922349c7bce6b0b335f (patch) | |
tree | fdf983392b1ab5d5f887c219588ca0857dc485c3 | |
parent | 4a3f9ccba2cebaf62d6001c2b700367785a7179c (diff) | |
download | Hyprland-84d6e640ff6e48c8161e1922349c7bce6b0b335f.tar.gz Hyprland-84d6e640ff6e48c8161e1922349c7bce6b0b335f.zip |
support all workspace types in workspace keyword
-rw-r--r-- | src/config/ConfigManager.cpp | 4 | ||||
-rw-r--r-- | src/config/ConfigManager.hpp | 2 | ||||
-rw-r--r-- | src/events/Monitors.cpp | 17 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d511c05a..b76ab965 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -495,11 +495,11 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) { const auto DISPLAY = value.substr(0, value.find_first_of(',')); - const auto WORKSPACEID = stoi(value.substr(value.find_first_of(',') + 1)); + const auto WORKSPACE = value.substr(value.find_first_of(',') + 1); for (auto& mr : m_dMonitorRules) { if (mr.name == DISPLAY) { - mr.defaultWorkspaceID = WORKSPACEID; + mr.defaultWorkspace = WORKSPACE; break; } } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 866b8b8e..0d4386c1 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -28,7 +28,7 @@ struct SMonitorRule { Vector2D offset = Vector2D(0,0); float scale = 1; float refreshRate = 60; - int defaultWorkspaceID = -1; + std::string defaultWorkspace = ""; bool disabled = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; }; diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 25756548..afbc0745 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -114,7 +114,15 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { wlr_ext_workspace_group_handle_v1_output_enter(PNEWMONITOR->pWLRWorkspaceGroupHandle, PNEWMONITOR->output); // Workspace - const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() + 1 /* Cuz workspaces doesnt have the new one yet and we start with 1 */ : monitorRule.defaultWorkspaceID; + std::string newDefaultWorkspaceName = ""; + auto WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_lWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName); + + if (WORKSPACEID == INT_MAX || WORKSPACEID == (long unsigned int)SPECIAL_WORKSPACE_ID) { + WORKSPACEID = g_pCompositor->m_lWorkspaces.size() + 1; + newDefaultWorkspaceName = std::to_string(WORKSPACEID); + + Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace); + } auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID); @@ -127,14 +135,13 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID); PNEWWORKSPACE->startAnim(true,true,true); } else { - g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); - PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); + PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); // We are required to set the name here immediately - wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, std::to_string(WORKSPACEID).c_str()); + wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str()); PNEWWORKSPACE->m_iID = WORKSPACEID; - PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID); + PNEWWORKSPACE->m_szName = newDefaultWorkspaceName; } PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; |