diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-04-10 21:52:10 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-04-10 21:52:14 +0100 |
| commit | a38b0e736d283543a2ffb8f7faef9f0ca591ac60 (patch) | |
| tree | 65b6ac9fbd1231f024e5ce3a69ef825d109c902d /src/debug/HyprCtl.cpp | |
| parent | 7b43f9f056358667302c17d3da04c20af1e12888 (diff) | |
hyprctl: don't assume output validity in hyprctl workspaces
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index bef7c68e..3307d495 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -194,7 +194,8 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) { result += "["; for (auto& w : g_pCompositor->m_vWorkspaces) { - const auto PLASTW = w->getLastFocusedWindow(); + const auto PLASTW = w->getLastFocusedWindow(); + const auto PMONITOR = g_pCompositor->getMonitorFromID(w->m_iMonitorID); result += getFormat( R"#({ @@ -206,9 +207,8 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) { "lastwindow": "0x%x", "lastwindowtitle": "%s" },)#", - w->m_iID, escapeJSONStrings(w->m_szName).c_str(), escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(), - g_pCompositor->getWindowsOnWorkspace(w->m_iID), ((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"), PLASTW, - PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : ""); + w->m_iID, escapeJSONStrings(w->m_szName).c_str(), escapeJSONStrings(PMONITOR ? PMONITOR->szName : "?").c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), + ((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"), PLASTW, PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : ""); } // remove trailing comma @@ -217,10 +217,11 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) { result += "]"; } else { for (auto& w : g_pCompositor->m_vWorkspaces) { - const auto PLASTW = w->getLastFocusedWindow(); + const auto PLASTW = w->getLastFocusedWindow(); + const auto PMONITOR = g_pCompositor->getMonitorFromID(w->m_iMonitorID); result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\tlastwindow: 0x%x\n\tlastwindowtitle: %s\n\n", w->m_iID, - w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), - (int)w->m_bHasFullscreenWindow, PLASTW, PLASTW ? PLASTW->m_szTitle.c_str() : ""); + w->m_szName.c_str(), PMONITOR ? PMONITOR->szName.c_str() : "?", g_pCompositor->getWindowsOnWorkspace(w->m_iID), (int)w->m_bHasFullscreenWindow, + PLASTW, PLASTW ? PLASTW->m_szTitle.c_str() : ""); } } return result; |
