From 3e568652603f54b8e105aa96ef78d1b6c8931c44 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. Once nvim sends a color event then the shell widget is made visible after the colors are applied. --- src/gui/shell.cpp | 10 ++++++++-- src/gui/shell.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/shell.cpp b/src/gui/shell.cpp index a8ea05025..b9d042ea6 100644 --- a/src/gui/shell.cpp +++ b/src/gui/shell.cpp @@ -326,6 +326,9 @@ void Shell::init() return; } + if (!m_shown) { // Defer displaying the shell until colors have been set. + setVisible(false); + } connect(m_nvim->api0(), &NeovimApi0::neovimNotification, this, &Shell::handleNeovimNotification); connect(m_nvim->api0(), &NeovimApi0::on_ui_try_resize, @@ -1127,8 +1130,11 @@ 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; + } emit colorsChanged(); } diff --git a/src/gui/shell.h b/src/gui/shell.h index 69562dc70..b8c8126ce 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;