Skip to content

Commit

Permalink
fix content type enum naming
Browse files Browse the repository at this point in the history
  • Loading branch information
UjinT34 committed Feb 2, 2025
1 parent 17d966d commit 9fd5345
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

using namespace Hyprutils::String;
using namespace Hyprutils::Animation;
using enum NContentType::eContentType;

PHLWINDOW CWindow::create(SP<CXWaylandSurface> surface) {
PHLWINDOW pWindow = SP<CWindow>(new CWindow(surface));
Expand Down Expand Up @@ -1727,7 +1728,7 @@ void CWindow::sendWindowSize(Vector2D size, bool force, std::optional<Vector2D>
}

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) {
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/ContentType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CContentType {

bool good();
wl_client* client();
NContentType::eContentType value = NContentType::NONE;
NContentType::eContentType value = NContentType::CONTENT_TYPE_NONE;

WP<CContentType> self;

Expand Down
23 changes: 12 additions & 11 deletions src/protocols/types/ContentType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <format>

namespace NContentType {
static std::unordered_map<std::string, eContentType> const table = {{"none", NONE}, {"photo", PHOTO}, {"video", VIDEO}, {"game", GAME}};
static std::unordered_map<std::string, eContentType> 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;
Expand All @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/protocols/types/ContentType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <hyprutils/utils/ScopeGuard.hpp>
using namespace Hyprutils::Utils;
using namespace Hyprutils::OS;
using enum NContentType::eContentType;

extern "C" {
#include <xf86drm.h>
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9fd5345

Please sign in to comment.