From 3c68cb5479663cf72e689840c9a7cecaed6eca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berke=20Kocao=C4=9Flu?= Date: Wed, 21 Aug 2024 08:02:43 +0300 Subject: [PATCH] blank-screens: fix flickering when blanking multiple monitors --- src/cpp/project/blank-screens/src/blind.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpp/project/blank-screens/src/blind.cpp b/src/cpp/project/blank-screens/src/blind.cpp index 9bf38f3c..8d114cf2 100644 --- a/src/cpp/project/blank-screens/src/blind.cpp +++ b/src/cpp/project/blank-screens/src/blind.cpp @@ -139,6 +139,10 @@ void bs::blinds::update_windows(void) void bs::blinds::create_windows(void) { + m_windows.reserve(m_monitors.size()); + while (m_windows.size() < m_monitors.size()) + m_windows.push_back(-1); + const auto screen_resources = XRRGetScreenResources(m_display, m_root_window); xph::die_if(!screen_resources, "unable to get screen resources"); @@ -188,11 +192,7 @@ void bs::blinds::create_windows(void) class_hint->res_class = class_name.data(); XSetClassHint(m_display, window, class_hint); - auto window_idx = m_windows.begin() + (idx - m_monitors.begin()); - if (window_idx > m_windows.end()) - m_windows.push_back(window); - else - m_windows.insert(window_idx, window); + m_windows[std::distance(m_monitors.begin(), idx)] = window; } XRRFreeCrtcInfo(crtc_info);