From 9fd5345e562da42f2df5e9bb28109b47653645c4 Mon Sep 17 00:00:00 2001 From: UjinT34 Date: Sun, 2 Feb 2025 11:16:56 +0300 Subject: [PATCH] fix content type enum naming --- src/Compositor.cpp | 3 ++- src/desktop/Window.cpp | 3 ++- src/helpers/Monitor.cpp | 3 ++- src/protocols/ContentType.hpp | 2 +- src/protocols/types/ContentType.cpp | 23 ++++++++++++----------- src/protocols/types/ContentType.hpp | 8 ++++---- src/render/Renderer.cpp | 5 +++-- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2f4ea15e398..04162c08fb8 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -73,6 +73,7 @@ using namespace Hyprutils::String; using namespace Aquamarine; +using enum NContentType::eContentType; static int handleCritSignal(int signo, void* data) { Debug::log(LOG, "Hyprland received signal {}", signo); @@ -2335,7 +2336,7 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, SFullscreenS // send a scanout tranche if we are entering fullscreen, and send a regular one if we aren't. // ignore if DS is disabled. - if (*PDIRECTSCANOUT == 1 || (*PDIRECTSCANOUT == 2 && PWINDOW->getContentType() == NContentType::GAME)) + if (*PDIRECTSCANOUT == 1 || (*PDIRECTSCANOUT == 2 && PWINDOW->getContentType() == CONTENT_TYPE_GAME)) g_pHyprRenderer->setSurfaceScanoutMode(PWINDOW->m_pWLSurface->resource(), EFFECTIVE_MODE != FSMODE_NONE ? PMONITOR->self.lock() : nullptr); g_pConfigManager->ensureVRR(PMONITOR); diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index c5384d20f00..6a523eec9df 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -30,6 +30,7 @@ using namespace Hyprutils::String; using namespace Hyprutils::Animation; +using enum NContentType::eContentType; PHLWINDOW CWindow::create(SP surface) { PHLWINDOW pWindow = SP(new CWindow(surface)); @@ -1727,7 +1728,7 @@ void CWindow::sendWindowSize(Vector2D size, bool force, std::optional } NContentType::eContentType CWindow::getContentType() { - return m_pWLSurface->resource()->contentType.valid() ? m_pWLSurface->resource()->contentType->value : NContentType::NONE; + return m_pWLSurface->resource()->contentType.valid() ? m_pWLSurface->resource()->contentType->value : CONTENT_TYPE_NONE; } void CWindow::setContentType(NContentType::eContentType contentType) { diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 432fb4e58ad..3ea6d49ba2e 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -33,6 +33,7 @@ using namespace Hyprutils::String; using namespace Hyprutils::Utils; using namespace Hyprutils::OS; +using enum NContentType::eContentType; static int ratHandler(void* data) { g_pHyprRenderer->renderMonitor(((CMonitor*)data)->self.lock()); @@ -800,7 +801,7 @@ bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() { // skip scheduling extra frames for fullsreen apps with vrr const bool shouldSkip = activeWorkspace && activeWorkspace->m_bHasFullscreenWindow && activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN && - (*PNOBREAK == 1 || (*PNOBREAK == 2 && activeWorkspace->getFullscreenWindow()->getContentType() == NContentType::GAME)) && output->state->state().adaptiveSync; + (*PNOBREAK == 1 || (*PNOBREAK == 2 && activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) && output->state->state().adaptiveSync; // keep requested minimum refresh rate if (shouldSkip && *PMINRR && lastPresentationTimer.getMillis() > 1000.0f / *PMINRR) { diff --git a/src/protocols/ContentType.hpp b/src/protocols/ContentType.hpp index 0c16446f0db..c0359bf18f4 100644 --- a/src/protocols/ContentType.hpp +++ b/src/protocols/ContentType.hpp @@ -22,7 +22,7 @@ class CContentType { bool good(); wl_client* client(); - NContentType::eContentType value = NContentType::NONE; + NContentType::eContentType value = NContentType::CONTENT_TYPE_NONE; WP self; diff --git a/src/protocols/types/ContentType.cpp b/src/protocols/types/ContentType.cpp index f7440042230..c0a3d30f439 100644 --- a/src/protocols/types/ContentType.cpp +++ b/src/protocols/types/ContentType.cpp @@ -4,9 +4,10 @@ #include namespace NContentType { - static std::unordered_map const table = {{"none", NONE}, {"photo", PHOTO}, {"video", VIDEO}, {"game", GAME}}; + static std::unordered_map const table = { + {"none", CONTENT_TYPE_NONE}, {"photo", CONTENT_TYPE_PHOTO}, {"video", CONTENT_TYPE_VIDEO}, {"game", CONTENT_TYPE_GAME}}; - eContentType fromString(const std::string name) { + eContentType fromString(const std::string name) { auto it = table.find(name); if (it != table.end()) return it->second; @@ -16,20 +17,20 @@ namespace NContentType { eContentType fromWP(wpContentTypeV1Type contentType) { switch (contentType) { - case WP_CONTENT_TYPE_V1_TYPE_NONE: return NONE; - case WP_CONTENT_TYPE_V1_TYPE_PHOTO: return PHOTO; - case WP_CONTENT_TYPE_V1_TYPE_VIDEO: return VIDEO; - case WP_CONTENT_TYPE_V1_TYPE_GAME: return GAME; - default: return NONE; + case WP_CONTENT_TYPE_V1_TYPE_NONE: return CONTENT_TYPE_NONE; + case WP_CONTENT_TYPE_V1_TYPE_PHOTO: return CONTENT_TYPE_PHOTO; + case WP_CONTENT_TYPE_V1_TYPE_VIDEO: return CONTENT_TYPE_VIDEO; + case WP_CONTENT_TYPE_V1_TYPE_GAME: return CONTENT_TYPE_GAME; + default: return CONTENT_TYPE_NONE; } } uint16_t toDRM(eContentType contentType) { switch (contentType) { - case NONE: return DRM_MODE_CONTENT_TYPE_GRAPHICS; - case PHOTO: return DRM_MODE_CONTENT_TYPE_PHOTO; - case VIDEO: return DRM_MODE_CONTENT_TYPE_CINEMA; - case GAME: return DRM_MODE_CONTENT_TYPE_GAME; + case CONTENT_TYPE_NONE: return DRM_MODE_CONTENT_TYPE_GRAPHICS; + case CONTENT_TYPE_PHOTO: return DRM_MODE_CONTENT_TYPE_PHOTO; + case CONTENT_TYPE_VIDEO: return DRM_MODE_CONTENT_TYPE_CINEMA; + case CONTENT_TYPE_GAME: return DRM_MODE_CONTENT_TYPE_GAME; default: return DRM_MODE_CONTENT_TYPE_NO_DATA; } } diff --git a/src/protocols/types/ContentType.hpp b/src/protocols/types/ContentType.hpp index 347a1d22f62..66fcbca77bf 100644 --- a/src/protocols/types/ContentType.hpp +++ b/src/protocols/types/ContentType.hpp @@ -6,10 +6,10 @@ namespace NContentType { enum eContentType : uint8_t { - NONE = 0, - PHOTO = 1, - VIDEO = 2, - GAME = 3, + CONTENT_TYPE_NONE = 0, + CONTENT_TYPE_PHOTO = 1, + CONTENT_TYPE_VIDEO = 2, + CONTENT_TYPE_GAME = 3, }; eContentType fromString(const std::string name); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 4430594677e..6d7b409ce9f 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -40,6 +40,7 @@ #include using namespace Hyprutils::Utils; using namespace Hyprutils::OS; +using enum NContentType::eContentType; extern "C" { #include @@ -1195,7 +1196,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) { pMonitor->tearingState.activelyTearing = shouldTear; - if ((*PDIRECTSCANOUT == 1 || (*PDIRECTSCANOUT == 2 && pMonitor->activeWorkspace->getFullscreenWindow()->getContentType() == NContentType::GAME)) && !shouldTear) { + if ((*PDIRECTSCANOUT == 1 || (*PDIRECTSCANOUT == 2 && pMonitor->activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) && !shouldTear) { if (pMonitor->attemptDirectScanout()) { return; } else if (!pMonitor->lastScanout.expired()) { @@ -1517,7 +1518,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) { const auto WINDOW = pMonitor->activeWorkspace->getFullscreenWindow(); pMonitor->output->state->setContentType(NContentType::toDRM(WINDOW->getContentType())); } else - pMonitor->output->state->setContentType(NContentType::toDRM(NContentType::NONE)); + pMonitor->output->state->setContentType(NContentType::toDRM(CONTENT_TYPE_NONE)); #endif if (pMonitor->ctmUpdated) {