diff options
| author | Vaxry <vaxry@vaxry.net> | 2025-04-16 01:37:48 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2025-04-16 01:37:48 +0100 |
| commit | 877fb5b93ada9b25b4d2f5ca5f69370fa345f1ac (patch) | |
| tree | 5b52ad19c695590ae50c7adae06b8e3aeccf34c1 /src/helpers/Monitor.cpp | |
| parent | 0e521788bcc414c9cf81648d3167757d83deb60f (diff) | |
time: move to stl's clocks and move timer
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 0a16643e..5e2fedd5 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -24,6 +24,7 @@ #include "../managers/LayoutManager.hpp" #include "../managers/input/InputManager.hpp" #include "sync/SyncTimeline.hpp" +#include "time/Time.hpp" #include "../desktop/LayerSurface.hpp" #include <aquamarine/output/Output.hpp> #include "debug/Log.hpp" @@ -32,6 +33,7 @@ #include <hyprutils/utils/ScopeGuard.hpp> #include <cstring> #include <ranges> + using namespace Hyprutils::String; using namespace Hyprutils::Utils; using namespace Hyprutils::OS; @@ -72,8 +74,15 @@ void CMonitor::onConnect(bool noRule) { output->events.needsFrame.registerListener([this](std::any d) { g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); }); listeners.presented = output->events.present.registerListener([this](std::any d) { - auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d); - PROTO::presentation->onPresented(self.lock(), E.when, E.refresh, E.seq, E.flags); + auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d); + + timespec* ts = E.when; + if (!ts) { + timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + PROTO::presentation->onPresented(self.lock(), Time::fromTimespec(&now), E.refresh, E.seq, E.flags); + } else + PROTO::presentation->onPresented(self.lock(), Time::fromTimespec(E.when), E.refresh, E.seq, E.flags); }); listeners.destroy = output->events.destroy.registerListener([this](std::any d) { @@ -1377,9 +1386,7 @@ bool CMonitor::attemptDirectScanout() { auto PBUFFER = PSURFACE->current.buffer.buffer; if (PBUFFER == output->state->state().buffer) { - timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - PSURFACE->presentFeedback(&now, self.lock()); + PSURFACE->presentFeedback(Time::steadyNow(), self.lock()); if (scanoutNeedsCursorUpdate) { if (!state.test()) { @@ -1420,9 +1427,7 @@ bool CMonitor::attemptDirectScanout() { return false; } - timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - PSURFACE->presentFeedback(&now, self.lock()); + PSURFACE->presentFeedback(Time::steadyNow(), self.lock()); output->state->addDamage(PSURFACE->current.accumulateBufferDamage()); output->state->resetExplicitFences(); |
