support all workspace types in workspace keyword

This commit is contained in:
vaxerski 2022-06-21 22:25:54 +02:00
parent 4a3f9ccba2
commit 84d6e640ff
3 changed files with 15 additions and 8 deletions

View file

@ -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) { void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) {
const auto DISPLAY = value.substr(0, value.find_first_of(',')); 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) { for (auto& mr : m_dMonitorRules) {
if (mr.name == DISPLAY) { if (mr.name == DISPLAY) {
mr.defaultWorkspaceID = WORKSPACEID; mr.defaultWorkspace = WORKSPACE;
break; break;
} }
} }

View file

@ -28,7 +28,7 @@ struct SMonitorRule {
Vector2D offset = Vector2D(0,0); Vector2D offset = Vector2D(0,0);
float scale = 1; float scale = 1;
float refreshRate = 60; float refreshRate = 60;
int defaultWorkspaceID = -1; std::string defaultWorkspace = "";
bool disabled = false; bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
}; };

View file

@ -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); wlr_ext_workspace_group_handle_v1_output_enter(PNEWMONITOR->pWLRWorkspaceGroupHandle, PNEWMONITOR->output);
// Workspace // 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); 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); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID);
PNEWWORKSPACE->startAnim(true,true,true); PNEWWORKSPACE->startAnim(true,true,true);
} else { } else {
g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID);
PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
// We are required to set the name here immediately // 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_iID = WORKSPACEID;
PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID); PNEWWORKSPACE->m_szName = newDefaultWorkspaceName;
} }
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;