From 877fb5b93ada9b25b4d2f5ca5f69370fa345f1ac Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 16 Apr 2025 01:37:48 +0100 Subject: time: move to stl's clocks and move timer --- src/protocols/ToplevelExport.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/protocols/ToplevelExport.cpp') diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 8f18afbc..fc0dc9d5 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -205,16 +205,13 @@ void CToplevelExportFrame::share() { if (!buffer || !validMapped(pWindow)) return; - timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - if (bufferDMA) { - if (!copyDmabuf(&now)) { + if (!copyDmabuf(Time::steadyNow())) { resource->sendFailed(); return; } } else { - if (!copyShm(&now)) { + if (!copyShm(Time::steadyNow())) { resource->sendFailed(); return; } @@ -222,16 +219,17 @@ void CToplevelExportFrame::share() { resource->sendFlags((hyprlandToplevelExportFrameV1Flags)0); - if (!m_ignoreDamage) { + if (!m_ignoreDamage) resource->sendDamage(0, 0, box.width, box.height); - } - uint32_t tvSecHi = (sizeof(now.tv_sec) > 4) ? now.tv_sec >> 32 : 0; - uint32_t tvSecLo = now.tv_sec & 0xFFFFFFFF; - resource->sendReady(tvSecHi, tvSecLo, now.tv_nsec); + const auto [sec, nsec] = Time::secNsec(Time::steadyNow()); + + uint32_t tvSecHi = (sizeof(sec) > 4) ? sec >> 32 : 0; + uint32_t tvSecLo = sec & 0xFFFFFFFF; + resource->sendReady(tvSecHi, tvSecLo, nsec); } -bool CToplevelExportFrame::copyShm(timespec* now) { +bool CToplevelExportFrame::copyShm(const Time::steady_tp& now) { const auto PERM = g_pDynamicPermissionManager->clientPermissionMode(resource->client(), PERMISSION_TYPE_SCREENCOPY); auto shm = buffer->shm(); auto [pixelData, fmt, bufLen] = buffer->beginDataPtr(0); // no need for end, cuz it's shm @@ -329,7 +327,7 @@ bool CToplevelExportFrame::copyShm(timespec* now) { return true; } -bool CToplevelExportFrame::copyDmabuf(timespec* now) { +bool CToplevelExportFrame::copyDmabuf(const Time::steady_tp& now) { const auto PERM = g_pDynamicPermissionManager->clientPermissionMode(resource->client(), PERMISSION_TYPE_SCREENCOPY); const auto PMONITOR = pWindow->m_pMonitor.lock(); -- cgit v1.2.3