From ff49f2244069124d366e2eba5e5474398a14281a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:13:13 +0200 Subject: [PATCH] fix rapid blinking on launch --- src/events/Monitors.cpp | 9 +++++++-- src/helpers/Monitor.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index e5fa7c55..25756548 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -140,6 +140,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; PNEWMONITOR->scale = monitorRule.scale; + PNEWMONITOR->forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. + g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); PNEWWORKSPACE->setActive(true); @@ -216,7 +218,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { return; } - if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE) { + if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE && PMONITOR->forceFullFrames == 0) { pixman_region32_fini(&damage); wlr_output_rollback(PMONITOR->output); wlr_output_schedule_frame(PMONITOR->output); // we update shit at the monitor's Hz so we need to schedule frames because rollback wont @@ -224,7 +226,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { } // if we have no tracking or full tracking, invalidate the entire monitor - if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR) { + if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0) { pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); @@ -247,6 +249,9 @@ void Events::listener_monitorFrame(void* owner, void* data) { } } + if (PMONITOR->forceFullFrames > 0) + PMONITOR->forceFullFrames -= 1; + // TODO: this is getting called with extents being 0,0,0,0 should it be? // potentially can save on resources. diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 4767fd78..24e555f9 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -28,6 +28,7 @@ struct SMonitor { float refreshRate = 60; wlr_output_damage* damage = nullptr; int framesToSkip = 0; + int forceFullFrames = 0; bool noFrameSchedule = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;