summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
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
+}