summaryrefslogtreecommitdiff
path: root/src/protocols/ToplevelExport.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-04-16 01:37:48 +0100
committerVaxry <vaxry@vaxry.net>2025-04-16 01:37:48 +0100
commit877fb5b93ada9b25b4d2f5ca5f69370fa345f1ac (patch)
tree5b52ad19c695590ae50c7adae06b8e3aeccf34c1 /src/protocols/ToplevelExport.cpp
parent0e521788bcc414c9cf81648d3167757d83deb60f (diff)
time: move to stl's clocks and move timer
Diffstat (limited to 'src/protocols/ToplevelExport.cpp')
-rw-r--r--src/protocols/ToplevelExport.cpp22
1 files changed, 10 insertions, 12 deletions
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();