summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authorItsOhen <TNordfeldt@gmail.com>2026-03-15 20:32:05 +0100
committerGitHub <noreply@github.com>2026-03-15 14:32:05 -0500
commit94bd4123c6e8fd3162e245b0d568c9d6dfd75780 (patch)
tree764d69857d566a44939394960b05731c709ae973 /src/protocols
parent3fd2a95475d9a954305eeede59fe2b345a4d8098 (diff)
desktop/rules: fix static rules and content type. (#13725)
Hopefully for the last time in a while. Also a lot easier to add in new static types with the recheck done in window map instead of the rule.
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/types/ContentType.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/protocols/types/ContentType.cpp b/src/protocols/types/ContentType.cpp
index b5b0041c..e2e58f3e 100644
--- a/src/protocols/types/ContentType.cpp
+++ b/src/protocols/types/ContentType.cpp
@@ -1,6 +1,7 @@
#include "ContentType.hpp"
+#include "debug/log/Logger.hpp"
+#include <hyprutils/string/String.hpp>
#include <drm_mode.h>
-#include <stdexcept>
#include <format>
namespace NContentType {
@@ -8,6 +9,13 @@ namespace NContentType {
{"none", CONTENT_TYPE_NONE}, {"photo", CONTENT_TYPE_PHOTO}, {"video", CONTENT_TYPE_VIDEO}, {"game", CONTENT_TYPE_GAME}};
eContentType fromString(const std::string name) {
+ if (Hyprutils::String::isNumber(name)) {
+ try {
+ auto n = std::stoi(name);
+ if (n >= 0 && n <= 3)
+ return sc<eContentType>(n);
+ } catch (std::exception& e) { Log::logger->log(Log::ERR, "NContentType::fromString: invalid number {}, need to be between 0 and 3", name); }
+ }
auto it = table.find(name);
if (it != table.end())
return it->second;
@@ -42,4 +50,4 @@ namespace NContentType {
default: return DRM_MODE_CONTENT_TYPE_NO_DATA;
}
}
-} \ No newline at end of file
+}