mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 01:46:00 +01:00
roll VFR for everyone
This commit is contained in:
parent
f461ea3105
commit
c0c75db621
3 changed files with 17 additions and 43 deletions
|
@ -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;
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -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,22 +176,20 @@ 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
|
g_pCompositor->sanityCheckWorkspaces();
|
||||||
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_pAnimationManager->tick();
|
||||||
g_pCompositor->sanityCheckWorkspaces();
|
g_pCompositor->cleanupFadingOut();
|
||||||
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)
|
if (g_pConfigManager->m_bWantsMonitorReload)
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue