mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-09-11 21:27:20 +03:00
move helper functions to class
This commit is contained in:
parent
6aa6e55f87
commit
d4a464dfd3
@ -70,7 +70,7 @@ static std::string availableModesForOutput(CMonitor* pMonitor, eHyprCtlOutputFor
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string HyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor> m, eHyprCtlOutputFormat format) {
|
||||
std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor> m, eHyprCtlOutputFormat format) {
|
||||
std::string result;
|
||||
if (!m->output || m->ID == -1ull)
|
||||
return "";
|
||||
@ -133,7 +133,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||
result += "[";
|
||||
|
||||
for (auto& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) {
|
||||
result += HyprCtl::getMonitorData(m, format);
|
||||
result += CHyprCtl::getMonitorData(m, format);
|
||||
}
|
||||
|
||||
trimTrailingComma(result);
|
||||
@ -194,7 +194,7 @@ static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||
return result.str();
|
||||
}
|
||||
|
||||
std::string HyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||
std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||
auto getFocusHistoryID = [](PHLWINDOW wnd) -> int {
|
||||
for (size_t i = 0; i < g_pCompositor->m_vWindowFocusHistory.size(); ++i) {
|
||||
if (g_pCompositor->m_vWindowFocusHistory[i].lock() == wnd)
|
||||
@ -263,7 +263,7 @@ std::string clientsRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||
if (!w->m_bIsMapped && !g_pHyprCtl->m_sCurrentRequestParams.all)
|
||||
continue;
|
||||
|
||||
result += HyprCtl::getWindowData(w, format);
|
||||
result += CHyprCtl::getWindowData(w, format);
|
||||
}
|
||||
|
||||
trimTrailingComma(result);
|
||||
@ -274,13 +274,13 @@ std::string clientsRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||
if (!w->m_bIsMapped && !g_pHyprCtl->m_sCurrentRequestParams.all)
|
||||
continue;
|
||||
|
||||
result += HyprCtl::getWindowData(w, format);
|
||||
result += CHyprCtl::getWindowData(w, format);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string HyprCtl::getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format) {
|
||||
std::string CHyprCtl::getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format) {
|
||||
const auto PLASTW = w->getLastFocusedWindow();
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(w->m_iMonitorID);
|
||||
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||
@ -360,7 +360,7 @@ std::string activeWorkspaceRequest(eHyprCtlOutputFormat format, std::string requ
|
||||
if (!valid(w))
|
||||
return "internal error";
|
||||
|
||||
return HyprCtl::getWorkspaceData(w, format);
|
||||
return CHyprCtl::getWorkspaceData(w, format);
|
||||
}
|
||||
|
||||
std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||
@ -369,7 +369,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request)
|
||||
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||
result += "[";
|
||||
for (auto& w : g_pCompositor->m_vWorkspaces) {
|
||||
result += HyprCtl::getWorkspaceData(w, format);
|
||||
result += CHyprCtl::getWorkspaceData(w, format);
|
||||
result += ",";
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request)
|
||||
result += "]";
|
||||
} else {
|
||||
for (auto& w : g_pCompositor->m_vWorkspaces) {
|
||||
result += HyprCtl::getWorkspaceData(w, format);
|
||||
result += CHyprCtl::getWorkspaceData(w, format);
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ std::string activeWindowRequest(eHyprCtlOutputFormat format, std::string request
|
||||
if (!validMapped(PWINDOW))
|
||||
return format == eHyprCtlOutputFormat::FORMAT_JSON ? "{}" : "Invalid";
|
||||
|
||||
auto result = HyprCtl::getWindowData(PWINDOW, format);
|
||||
auto result = CHyprCtl::getWindowData(PWINDOW, format);
|
||||
|
||||
if (format == eHyprCtlOutputFormat::FORMAT_JSON)
|
||||
result.pop_back();
|
||||
|
@ -22,6 +22,10 @@ class CHyprCtl {
|
||||
bool sysInfoConfig = false;
|
||||
} m_sCurrentRequestParams;
|
||||
|
||||
static std::string getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format);
|
||||
static std::string getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format);
|
||||
static std::string getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor> m, eHyprCtlOutputFormat format);
|
||||
|
||||
private:
|
||||
void startHyprCtlSocket();
|
||||
|
||||
@ -29,11 +33,4 @@ class CHyprCtl {
|
||||
wl_event_source* m_eventSource = nullptr;
|
||||
};
|
||||
|
||||
namespace HyprCtl {
|
||||
std::string getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format);
|
||||
std::string getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format);
|
||||
std::string getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor> m, eHyprCtlOutputFormat format);
|
||||
|
||||
} // namespace HyprCtl
|
||||
|
||||
inline std::unique_ptr<CHyprCtl> g_pHyprCtl;
|
||||
|
Loading…
Reference in New Issue
Block a user