summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Birkett <jacob@birkett.dev>2024-02-15 07:22:20 -0700
committerGitHub <noreply@github.com>2024-02-15 14:22:20 +0000
commita8dae8f5e198327e5de8508d860234089f31e272 (patch)
treededd70312674fd4c6b963130dfc20340f62bb5c3 /src
parenta42b984f51a00e88a13a45e1b5e9e3d4ec470254 (diff)
socket2: `monitoraddedv2` IPC event for monitor description and id (#4646)
* add monitor szShortDescription without DRM node name * change hyprctl to use szShortDescription * add monitoraddedv2 event * add monitor ID as first param of monitoraddedv2
Diffstat (limited to 'src')
-rw-r--r--src/debug/HyprCtl.cpp4
-rw-r--r--src/helpers/Monitor.cpp7
-rw-r--r--src/helpers/Monitor.hpp5
3 files changed, 12 insertions, 4 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 08957750..e805bca6 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -76,7 +76,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
"vrr": {},
"activelyTearing": {}
}},)#",
- m->ID, escapeJSONStrings(m->szName), escapeJSONStrings(m->szDescription), (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""),
+ 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,
m->activeWorkspace, (m->activeWorkspace == -1 ? "" : escapeJSONStrings(g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName)), m->specialWorkspaceID,
escapeJSONStrings(getWorkspaceNameFromSpecialID(m->specialWorkspaceID)), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y,
@@ -98,7 +98,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
"workspace: {} ({})\n\treserved: {} "
"{} {} {}\n\tscale: {:.2f}\n\ttransform: "
"{}\n\tfocused: {}\n\tdpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\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->szDescription,
+ 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,
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index cb69318f..08ccb05d 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -1,5 +1,7 @@
#include "Monitor.hpp"
+#include "MiscFunctions.hpp"
+
#include "../Compositor.hpp"
int ratHandler(void* data) {
@@ -54,6 +56,10 @@ void CMonitor::onConnect(bool noRule) {
// remove comma character from description. This allow monitor specific rules to work on monitor with comma on their description
szDescription.erase(std::remove(szDescription.begin(), szDescription.end(), ','), szDescription.end());
+ // field is backwards-compatible with intended usage of `szDescription` but excludes the parenthesized DRM node name suffix
+ szShortDescription =
+ removeBeginEndSpacesTabs(std::format("{} {} {}", output->make ? output->make : "", output->model ? output->model : "", output->serial ? output->serial : ""));
+
if (!wlr_backend_is_drm(output->backend))
createdByUser = true; // should be true. WL, X11 and Headless backends should be addable / removable
@@ -163,6 +169,7 @@ void CMonitor::onConnect(bool noRule) {
//
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
+ g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)});
EMIT_HOOK_EVENT("monitorAdded", this);
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp
index c5eb70a0..c08cdea4 100644
--- a/src/helpers/Monitor.hpp
+++ b/src/helpers/Monitor.hpp
@@ -62,8 +62,9 @@ class CMonitor {
float setScale = 1; // scale set by cfg
float scale = 1; // real scale
- std::string szName = "";
- std::string szDescription = "";
+ std::string szName = "";
+ std::string szDescription = "";
+ std::string szShortDescription = "";
Vector2D vecReservedTopLeft = Vector2D(0, 0);
Vector2D vecReservedBottomRight = Vector2D(0, 0);