From c0c75db62188667a4f42aef1ae6bfd8034093af7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:56:24 +0200 Subject: [PATCH] roll VFR for everyone --- src/config/ConfigManager.cpp | 2 -- src/debug/HyprCtl.cpp | 11 ++++----- src/events/Monitors.cpp | 47 +++++++++--------------------------- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 19db65fd..e00270a1 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -46,8 +46,6 @@ void CConfigManager::setDefaultVars() { configValues["debug:damage_blink"].intValue = 0; configValues["debug:disable_logs"].intValue = 0; - configValues["experimental:vfr"].intValue = 0; - configValues["decoration:rounding"].intValue = 1; configValues["decoration:blur"].intValue = 1; configValues["decoration:blur_size"].intValue = 8; diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 7aa0017e..519b0ce8 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -271,12 +271,11 @@ void HyprCtl::tickHyprCtl() { std::string getRequestFromThread(std::string rq) { // we need to do something to wake hyprland up if VFR is enabled - static auto *const VFRENABLED = &g_pConfigManager->getConfigValuePtr("experimental:vfr")->intValue; - if (*VFRENABLED) { - // TODO: is this safe...? - // this might be a race condition - wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output); - } + + // TODO: is this safe...? + // this might be a race condition + // tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes + wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output); while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) { std::this_thread::sleep_for(std::chrono::milliseconds(5)); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 7a0fb358..1b90fbd0 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -15,8 +15,6 @@ // // // --------------------------------------------------------- // -SMonitor* pMostHzMonitor = nullptr; - void Events::listener_change(wl_listener* listener, void* data) { // layout got changed, let's update monitors. const auto CONFIG = wlr_output_configuration_v1_create(); @@ -149,9 +147,6 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); PNEWWORKSPACE->setActive(true); - - if (!pMostHzMonitor || monitorRule.refreshRate > pMostHzMonitor->refreshRate) - pMostHzMonitor = PNEWMONITOR; // if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet @@ -173,7 +168,6 @@ void Events::listener_monitorFrame(void* owner, void* data) { static auto *const PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue; static auto *const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("general:damage_tracking_internal")->intValue; static auto *const PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->intValue; - static auto *const VFRENABLED = &g_pConfigManager->getConfigValuePtr("experimental:vfr")->intValue; static int damageBlinkCleanup = 0; // because double-buffered @@ -182,22 +176,20 @@ void Events::listener_monitorFrame(void* owner, void* data) { g_pDebugOverlay->frameData(PMONITOR); } - // Hack: only check when monitor with top hz refreshes, saves a bit of resources. - // This is for stuff that should be run every frame - if (PMONITOR->ID == pMostHzMonitor->ID || *VFRENABLED) { // unfortunately with VFR we don't have the guarantee mostHz is going to be updated all the time, so we have to ignore that - g_pCompositor->sanityCheckWorkspaces(); - g_pAnimationManager->tick(); - g_pCompositor->cleanupFadingOut(); + // checks // + g_pCompositor->sanityCheckWorkspaces(); + g_pAnimationManager->tick(); + g_pCompositor->cleanupFadingOut(); - HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit + HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit - g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd + g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd - if (g_pConfigManager->m_bWantsMonitorReload) - g_pConfigManager->performMonitorReload(); + if (g_pConfigManager->m_bWantsMonitorReload) + g_pConfigManager->performMonitorReload(); - g_pHyprRenderer->ensureCursorRenderingMode(); // so that the cursor gets hidden/shown if the user requested timeouts - } + g_pHyprRenderer->ensureCursorRenderingMode(); // so that the cursor gets hidden/shown if the user requested timeouts + // // if (PMONITOR->framesToSkip > 0) { PMONITOR->framesToSkip -= 1; @@ -233,7 +225,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { pixman_region32_fini(&damage); wlr_output_rollback(PMONITOR->output); - if (!*VFRENABLED) + if (*PDAMAGEBLINK) wlr_output_schedule_frame(PMONITOR->output); return; @@ -323,7 +315,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { wlr_output_commit(PMONITOR->output); - if (!*VFRENABLED) + if (*PDAMAGEBLINK) wlr_output_schedule_frame(PMONITOR->output); if (*PDEBUGOVERLAY == 1) { @@ -390,19 +382,4 @@ void Events::listener_monitorDestroy(void* owner, void* data) { g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName)); g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::unique_ptr& el) { return el.get() == pMonitor; })); - - // update the pMostHzMonitor - if (pMostHzMonitor == pMonitor) { - int mostHz = 0; - SMonitor* pMonitorMostHz = nullptr; - - for (auto& m : g_pCompositor->m_vMonitors) { - if (m->refreshRate > mostHz) { - pMonitorMostHz = m.get(); - mostHz = m->refreshRate; - } - } - - pMostHzMonitor = pMonitorMostHz; - } }