summaryrefslogtreecommitdiff
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
authorJunxuan Liao <70618504+MikeWalrus@users.noreply.github.com>2024-03-05 21:41:51 +0800
committerGitHub <noreply@github.com>2024-03-05 13:41:51 +0000
commit08152477dca873fec395d08cf30d27f961556f6e (patch)
treedbe3db1626ad9a230fa6535be3fc436ea271fe3c /src/helpers/Monitor.cpp
parent12985fa0d8e43b1e33326dfb49be681970dfaea5 (diff)
monitor: remove commas from short description (#4970)
Since `hyprctl monitor` shows szShortDescription now, it needs to be sanitized. (See #2457) Also, monitor selectors are now compared against szShortDescription and szDescription to avoid re-striping the string.
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 7e9bc82a..7b694d48 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -56,11 +56,12 @@ void CMonitor::onConnect(bool noRule) {
szDescription = output->description ? output->description : "";
// 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());
+ std::erase(szDescription, ',');
// 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 : ""));
+ std::erase(szShortDescription, ',');
if (!wlr_backend_is_drm(output->backend))
createdByUser = true; // should be true. WL, X11 and Headless backends should be addable / removable
@@ -363,9 +364,8 @@ bool CMonitor::matchesStaticSelector(const std::string& selector) const {
if (selector.starts_with("desc:")) {
// match by description
const auto DESCRIPTIONSELECTOR = selector.substr(5);
- const auto DESCRIPTION = removeBeginEndSpacesTabs(szDescription.substr(0, szDescription.find_first_of('(')));
- return DESCRIPTIONSELECTOR == szDescription || DESCRIPTIONSELECTOR == DESCRIPTION;
+ return DESCRIPTIONSELECTOR == szShortDescription || DESCRIPTIONSELECTOR == szDescription;
} else {
// match by selector
return szName == selector;