Skip to content

Commit

Permalink
Avoid a flashing window blink during startup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davvid committed Mar 7, 2024
1 parent ef1bec6 commit ddb8697
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QUrl> m_deferredOpen;
Expand Down

0 comments on commit ddb8697

Please sign in to comment.