mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 05:25:58 +01:00
Use existing default mon workspace if available on connect
This commit is contained in:
parent
48a3b1c514
commit
68f7e565e6
1 changed files with 17 additions and 8 deletions
|
@ -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);
|
wlr_ext_workspace_group_handle_v1_output_enter(PNEWMONITOR->pWLRWorkspaceGroupHandle, PNEWMONITOR->output);
|
||||||
|
|
||||||
// Workspace
|
// 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;
|
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);
|
g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID);
|
||||||
const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
|
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, std::to_string(WORKSPACEID).c_str());
|
||||||
|
|
||||||
PNEWWORKSPACE->m_iID = WORKSPACEID;
|
PNEWWORKSPACE->m_iID = WORKSPACEID;
|
||||||
PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID);
|
PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID);
|
||||||
|
}
|
||||||
|
|
||||||
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
|
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
|
||||||
|
|
||||||
PNEWMONITOR->scale = monitorRule.scale;
|
PNEWMONITOR->scale = monitorRule.scale;
|
||||||
|
|
||||||
g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
|
g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
|
||||||
|
|
Loading…
Reference in a new issue