diff --git a/src/gui/shell.cpp b/src/gui/shell.cpp index a8ea05025..f9c35c02c 100644 --- a/src/gui/shell.cpp +++ b/src/gui/shell.cpp @@ -103,6 +103,14 @@ Shell::Shell(NeovimConnector *nvim, QWidget *parent) m_nvim->setRequestHandler(new ShellRequestHandler(this)); } +void Shell::ensureVisible() noexcept +{ + if (!m_shown) { + m_shown = true; + setVisible(true); + } +} + void Shell::handleFontError(const QString& msg) { if (m_attached) { @@ -326,6 +334,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, @@ -365,6 +377,17 @@ void Shell::init() // Set initial value m_nvim->api0()->vim_set_var("GuiWindowFrameless", (windowFlags() & Qt::FramelessWindowHint) ? 1: 0); + + // Make the shell visible even when default_colors_set is not received, + // e.g. when using the older cell-based grid protocol. + if (!m_shown) { + constexpr int visibility_timeout{ 850 }; + m_visibility_timer.setInterval(visibility_timeout); + m_visibility_timer.setSingleShot(true); + connect(&m_visibility_timer, &QTimer::timeout, + this, &Shell::ensureVisible); + m_visibility_timer.start(); + } } void Shell::neovimError(NeovimConnector::NeovimError err) @@ -1127,6 +1150,8 @@ void Shell::handleDefaultColorsSet(const QVariantList& opargs) setBackground(backgroundColor); setSpecial(specialColor); + // Display the shell now that the default colors have been set. + ensureVisible(); // 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..d4d9216e7 100644 --- a/src/gui/shell.h +++ b/src/gui/shell.h @@ -190,10 +190,12 @@ protected slots: private slots: void setAttached(bool attached); + void ensureVisible() noexcept; private: bool m_init_called{ false }; bool m_attached{ false }; + bool m_shown{ false }; NeovimConnector* m_nvim{ nullptr }; QList m_deferredOpen; @@ -231,6 +233,8 @@ private slots: Qt::MouseButton m_mouseclick_pending; // Accumulates remainder of steppy scroll QPoint m_scrollDeltaRemainder; + // Ensures that the Shell widget is made visible + QTimer m_visibility_timer; // Properties bool m_neovimBusy{ false };