forked from qt-creator/qt-creator
Terminal: Fix resize logic
When a terminal window is resized (e.g. on first show) it needs to communicate its size to the PTY process. If the process is not yet running we need to make sure that the size is set again once it is running. Adding a bool return value to "resizePty" allows us to detect if the size change was applied, which allows us to update the surface size only if the pty was also changed. With this we can use the "liveSize" of the surface to check if a resizeEvent needs to be passed on to the PTY, which will be triggered by the Process::started signal once the process is started. Fixes: QTCREATORBUG-32290 Change-Id: I613275e75d343ccb357c2a797d096f0e1f96fed7 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -977,10 +977,11 @@ void TerminalView::applySizeChange()
|
|||||||
if (d->m_surface->liveSize() == newLiveSize)
|
if (d->m_surface->liveSize() == newLiveSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
resizePty(newLiveSize);
|
if (resizePty(newLiveSize)) {
|
||||||
d->m_surface->resize(newLiveSize);
|
d->m_surface->resize(newLiveSize);
|
||||||
flushVTerm(true);
|
flushVTerm(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TerminalView::updateScrollBars()
|
void TerminalView::updateScrollBars()
|
||||||
{
|
{
|
||||||
|
@@ -123,7 +123,12 @@ public:
|
|||||||
return noHits;
|
return noHits;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void resizePty(QSize newSize) { Q_UNUSED(newSize); }
|
virtual bool resizePty(QSize newSize)
|
||||||
|
{
|
||||||
|
Q_UNUSED(newSize);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void setClipboard(const QString &text) { Q_UNUSED(text); }
|
virtual void setClipboard(const QString &text) { Q_UNUSED(text); }
|
||||||
virtual std::optional<Link> toLink(const QString &text)
|
virtual std::optional<Link> toLink(const QString &text)
|
||||||
{
|
{
|
||||||
|
@@ -336,10 +336,13 @@ qint64 TerminalWidget::writeToPty(const QByteArray &data)
|
|||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalWidget::resizePty(QSize newSize)
|
bool TerminalWidget::resizePty(QSize newSize)
|
||||||
{
|
{
|
||||||
if (m_process && m_process->ptyData() && m_process->isRunning())
|
if (!m_process || !m_process->ptyData() || !m_process->isRunning())
|
||||||
|
return false;
|
||||||
|
|
||||||
m_process->ptyData()->resize(newSize);
|
m_process->ptyData()->resize(newSize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalWidget::surfaceChanged()
|
void TerminalWidget::surfaceChanged()
|
||||||
|
@@ -77,7 +77,7 @@ protected:
|
|||||||
void contextMenuRequested(const QPoint &pos) override;
|
void contextMenuRequested(const QPoint &pos) override;
|
||||||
|
|
||||||
qint64 writeToPty(const QByteArray &data) override;
|
qint64 writeToPty(const QByteArray &data) override;
|
||||||
void resizePty(QSize newSize) override;
|
bool resizePty(QSize newSize) override;
|
||||||
void setClipboard(const QString &text) override;
|
void setClipboard(const QString &text) override;
|
||||||
std::optional<TerminalView::Link> toLink(const QString &text) override;
|
std::optional<TerminalView::Link> toLink(const QString &text) override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user