From ddb8697c050963f852302926f2c9eb2f3e06de04 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 15 Feb 2024 00:19:43 -0800 Subject: [PATCH] Avoid a flashing window blink during startup The very first paint events cause a bright flash of unstyled shell content to appear before the configured colors are applied. Defer displaying the shell widget until nvim sends us colors. Instead of seeing the shell with its constructor-provided colors we will instead see Qt's default window background color, which follows the user's desktop theme and dark mode settings. The shell becomes visible once nvim sends a color message and the colors are applied. --- src/gui/shell.cpp | 15 +++++++++++++-- src/gui/shell.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/shell.cpp b/src/gui/shell.cpp index a8ea05025..efc784da3 100644 --- a/src/gui/shell.cpp +++ b/src/gui/shell.cpp @@ -326,6 +326,10 @@ void Shell::init() return; } + // Pull Request#1101: Defer displaying the shell until colors have been set + if (!m_shown) { + setVisible(false); + } connect(m_nvim->api0(), &NeovimApi0::neovimNotification, this, &Shell::handleNeovimNotification); connect(m_nvim->api0(), &NeovimApi0::on_ui_try_resize, @@ -1127,8 +1131,15 @@ void Shell::handleDefaultColorsSet(const QVariantList& opargs) setBackground(backgroundColor); setSpecial(specialColor); - // Cells drawn with the default colors require a re-paint - update(); + // Display the shell now that the default colors have been set. + if (!m_shown) { + setVisible(true); + m_shown = true; + } + else { + // Cells drawn with the default colors require a re-paint + update(); + } emit colorsChanged(); } diff --git a/src/gui/shell.h b/src/gui/shell.h index 69562dc70..90a9cce4a 100644 --- a/src/gui/shell.h +++ b/src/gui/shell.h @@ -194,6 +194,7 @@ private slots: private: bool m_init_called{ false }; bool m_attached{ false }; + bool m_shown{ false }; NeovimConnector* m_nvim{ nullptr }; QList m_deferredOpen;