roll VFR for everyone

This commit is contained in:
vaxerski 2022-07-11 23:56:24 +02:00
parent f461ea3105
commit c0c75db621
3 changed files with 17 additions and 43 deletions

View file

@ -46,8 +46,6 @@ void CConfigManager::setDefaultVars() {
configValues["debug:damage_blink"].intValue = 0; configValues["debug:damage_blink"].intValue = 0;
configValues["debug:disable_logs"].intValue = 0; configValues["debug:disable_logs"].intValue = 0;
configValues["experimental:vfr"].intValue = 0;
configValues["decoration:rounding"].intValue = 1; configValues["decoration:rounding"].intValue = 1;
configValues["decoration:blur"].intValue = 1; configValues["decoration:blur"].intValue = 1;
configValues["decoration:blur_size"].intValue = 8; configValues["decoration:blur_size"].intValue = 8;

View file

@ -271,12 +271,11 @@ void HyprCtl::tickHyprCtl() {
std::string getRequestFromThread(std::string rq) { std::string getRequestFromThread(std::string rq) {
// we need to do something to wake hyprland up if VFR is enabled // 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...? // TODO: is this safe...?
// this might be a race condition // 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); wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output);
}
while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) { while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5)); std::this_thread::sleep_for(std::chrono::milliseconds(5));

View file

@ -15,8 +15,6 @@
// // // //
// --------------------------------------------------------- // // --------------------------------------------------------- //
SMonitor* pMostHzMonitor = nullptr;
void Events::listener_change(wl_listener* listener, void* data) { void Events::listener_change(wl_listener* listener, void* data) {
// layout got changed, let's update monitors. // layout got changed, let's update monitors.
const auto CONFIG = wlr_output_configuration_v1_create(); 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); g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
PNEWWORKSPACE->setActive(true); 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 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 PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue;
static auto *const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("general:damage_tracking_internal")->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 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 static int damageBlinkCleanup = 0; // because double-buffered
@ -182,9 +176,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pDebugOverlay->frameData(PMONITOR); g_pDebugOverlay->frameData(PMONITOR);
} }
// Hack: only check when monitor with top hz refreshes, saves a bit of resources. // checks //
// 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_pCompositor->sanityCheckWorkspaces();
g_pAnimationManager->tick(); g_pAnimationManager->tick();
g_pCompositor->cleanupFadingOut(); g_pCompositor->cleanupFadingOut();
@ -197,7 +189,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pConfigManager->performMonitorReload(); 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) { if (PMONITOR->framesToSkip > 0) {
PMONITOR->framesToSkip -= 1; PMONITOR->framesToSkip -= 1;
@ -233,7 +225,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
wlr_output_rollback(PMONITOR->output); wlr_output_rollback(PMONITOR->output);
if (!*VFRENABLED) if (*PDAMAGEBLINK)
wlr_output_schedule_frame(PMONITOR->output); wlr_output_schedule_frame(PMONITOR->output);
return; return;
@ -323,7 +315,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
wlr_output_commit(PMONITOR->output); wlr_output_commit(PMONITOR->output);
if (!*VFRENABLED) if (*PDAMAGEBLINK)
wlr_output_schedule_frame(PMONITOR->output); wlr_output_schedule_frame(PMONITOR->output);
if (*PDEBUGOVERLAY == 1) { if (*PDEBUGOVERLAY == 1) {
@ -390,19 +382,4 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName)); 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<SMonitor>& el) { return el.get() == pMonitor; })); g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::unique_ptr<SMonitor>& 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;
}
} }