diff options
author | vaxerski <[email protected]> | 2022-05-31 12:10:34 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-31 12:10:34 +0200 |
commit | 68f7e565e628a1a52b4bc043e102c7bab7e6dd9a (patch) | |
tree | 5266bf5a631455606375df0045a507d980f89569 | |
parent | 48a3b1c51435af24e12c63547f0a11eabd6ed2f1 (diff) | |
download | Hyprland-68f7e565e628a1a52b4bc043e102c7bab7e6dd9a.tar.gz Hyprland-68f7e565e628a1a52b4bc043e102c7bab7e6dd9a.zip |
Use existing default mon workspace if available on connect
-rw-r--r-- | src/events/Monitors.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 64f6e56a..43e861d0 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -110,18 +110,27 @@ 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->getWorkspaceByID(monitorRule.defaultWorkspaceID) ? g_pCompositor->m_lWorkspaces.size() + 1 /* Cuz workspaces doesnt have the new one yet and we start with 1 */ : monitorRule.defaultWorkspaceID; - g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); - const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); + 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; + + auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID); + + Debug::log(LOG, "New monitor: WORKSPACEID %d, exists: %d", WORKSPACEID, (int)(PNEWWORKSPACE != nullptr)); + + if (PNEWWORKSPACE) { + // workspace exists, move it to the newly connected monitor + g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, PNEWMONITOR); + } else { + g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); + PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); - // 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()); + // 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()); - PNEWWORKSPACE->m_iID = WORKSPACEID; - PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID); + PNEWWORKSPACE->m_iID = WORKSPACEID; + PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID); + } PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; - PNEWMONITOR->scale = monitorRule.scale; g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); |