From 94bd4123c6e8fd3162e245b0d568c9d6dfd75780 Mon Sep 17 00:00:00 2001 From: ItsOhen Date: Sun, 15 Mar 2026 20:32:05 +0100 Subject: 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. --- src/protocols/types/ContentType.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/protocols') 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 #include -#include #include 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(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 +} -- cgit v1.2.3