From f6ecef0959163d10dd6597037192456977aa5bc2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 4 Sep 2022 18:32:03 +0200 Subject: [PATCH] add lastwindow info to hyprctl workspaces --- src/debug/HyprCtl.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 2cf2781e..1df8e443 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -124,19 +124,25 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) { result += "["; for (auto& w : g_pCompositor->m_vWorkspaces) { + const auto PLASTW = w->getLastFocusedWindow(); + result += getFormat( R"#({ "id": %i, "name": "%s", "monitor": "%s", "windows": %i, - "hasfullscreen": %s + "hasfullscreen": %s, + "lastwindow": %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") + ((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"), + PLASTW, + PLASTW ? PLASTW->m_szTitle.c_str() : "" ); } @@ -146,8 +152,9 @@ R"#({ result += "]"; } else { for (auto& w : g_pCompositor->m_vWorkspaces) { - result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\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); + const auto PLASTW = w->getLastFocusedWindow(); + result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\tlastwindow: %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() : ""); } } return result;