summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-03-05 13:55:33 +0000
committerVaxry <vaxry@vaxry.net>2024-03-05 13:55:38 +0000
commitbdfa8ab856b889f92240684680cb3fdbdc41fb3d (patch)
treee9f687c1ca39174de783d749775369ca00ffff80 /src/debug
parent08152477dca873fec395d08cf30d27f961556f6e (diff)
hyprctl: print format and modes
fixes #4971
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/HyprCtl.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index f2e4869a..10302b08 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -31,6 +31,38 @@ static std::string getWorkspaceNameFromSpecialID(const int workspaceID) {
return workspace->m_szName;
}
+static std::string formatToString(uint32_t drmFormat) {
+ switch (drmFormat) {
+ case DRM_FORMAT_XRGB2101010: return "XRGB2101010";
+ case DRM_FORMAT_XBGR2101010: return "XBGR2101010";
+ case DRM_FORMAT_XRGB8888: return "XRGB8888";
+ case DRM_FORMAT_XBGR8888: return "XBGR8888";
+ default: break;
+ }
+
+ return "Invalid";
+}
+
+static std::string availableModesForOutput(CMonitor* pMonitor, eHyprCtlOutputFormat format) {
+ std::string result;
+
+ if (!wl_list_empty(&pMonitor->output->modes)) {
+ wlr_output_mode* mode;
+
+ wl_list_for_each(mode, &pMonitor->output->modes, link) {
+
+ if (format == FORMAT_NORMAL)
+ result += std::format("{}x{}@{:.2f}Hz ", mode->width, mode->height, mode->refresh / 1000.0);
+ else
+ result += std::format("\"{}x{}@{:.2f}Hz\",", mode->width, mode->height, mode->refresh / 1000.0);
+ }
+
+ result.pop_back();
+ }
+
+ return result;
+}
+
std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
CVarList vars(request, 0, ' ');
auto allMonitors = false;
@@ -76,7 +108,9 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
"focused": {},
"dpmsStatus": {},
"vrr": {},
- "activelyTearing": {}
+ "activelyTearing": {},
+ "currentFormat": "{}",
+ "availableModes": [{}]
}},)#",
m->ID, escapeJSONStrings(m->szName), escapeJSONStrings(m->szShortDescription), (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""),
(m->output->serial ? m->output->serial : ""), (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y,
@@ -84,7 +118,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
escapeJSONStrings(getWorkspaceNameFromSpecialID(m->specialWorkspaceID)), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y,
(int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"),
(m->dpmsStatus ? "true" : "false"), (m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED ? "true" : "false"),
- m->tearingState.activelyTearing ? "true" : "false");
+ m->tearingState.activelyTearing ? "true" : "false", formatToString(m->drmFormat), availableModesForOutput(m.get(), format));
}
trimTrailingComma(result);
@@ -99,13 +133,14 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
std::format("Monitor {} (ID {}):\n\t{}x{}@{:.5f} at {}x{}\n\tdescription: {}\n\tmake: {}\n\tmodel: {}\n\tserial: {}\n\tactive workspace: {} ({})\n\tspecial "
"workspace: {} ({})\n\treserved: {} "
"{} {} {}\n\tscale: {:.2f}\n\ttransform: "
- "{}\n\tfocused: {}\n\tdpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\n\n",
+ "{}\n\tfocused: {}\n\tdpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\n\tcurrentFormat: {}\n\tavailableModes: {}\n\n",
m->szName, m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->szShortDescription,
(m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""), (m->output->serial ? m->output->serial : ""), m->activeWorkspace,
(m->activeWorkspace == -1 ? "" : g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName), m->specialWorkspaceID,
getWorkspaceNameFromSpecialID(m->specialWorkspaceID), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x,
(int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus,
- (int)(m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED), m->tearingState.activelyTearing);
+ (int)(m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED), m->tearingState.activelyTearing, formatToString(m->drmFormat),
+ availableModesForOutput(m.get(), format));
}
}