Commit c2c2f8a0 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Tomaz Canabrava
Browse files

make the pty's pixel size actually follow the emulation's size

... rather than using a side channel to propagate the window size.

amends 7a27f407.
parent 38b92f35
Pipeline #170756 passed with stage
in 2 minutes and 17 seconds
......@@ -40,6 +40,8 @@ void Pty::init()
{
_windowColumns = 0;
_windowLines = 0;
_windowWidth = 0;
_windowHeight = 0;
_eraseChar = 0;
_xonXoff = true;
_utf8 = true;
......@@ -48,7 +50,7 @@ void Pty::init()
setFlowControlEnabled(_xonXoff);
setUtf8Mode(_utf8);
setWindowSize(_windowColumns, _windowLines);
setWindowSize(_windowColumns, _windowLines, _windowWidth, _windowHeight);
setUseUtmp(true);
setPtyChannels(KPtyProcess::AllChannels);
......@@ -80,10 +82,12 @@ void Pty::dataReceived()
Q_EMIT receivedData(data.constData(), data.count());
}
void Pty::setWindowSize(int columns, int lines)
void Pty::setWindowSize(int columns, int lines, int width, int height)
{
_windowColumns = columns;
_windowLines = lines;
_windowWidth = width;
_windowHeight = height;
if (pty()->masterFd() >= 0) {
#if KPTY_VERSION >= QT_VERSION_CHECK(5, 92, 0)
......@@ -99,15 +103,14 @@ void Pty::setWindowSize(int columns, int lines)
}
}
void Pty::setPixelSize(int width, int height)
QSize Pty::windowSize() const
{
_windowWidth = width;
_windowHeight = height;
return {_windowColumns, _windowLines};
}
QSize Pty::windowSize() const
QSize Pty::pixelSize() const
{
return {_windowColumns, _windowLines};
return {_windowWidth, _windowHeight};
}
void Pty::setFlowControlEnabled(bool enable)
......
......@@ -86,15 +86,17 @@ public:
bool flowControlEnabled() const;
/**
* Sets the size of the window (in columns and lines of characters)
* used by this teletype.
* Sets the size of the window (in columns and lines of characters,
* and width and height in pixels) used by this teletype.
*/
void setWindowSize(int columns, int lines);
void setPixelSize(int width, int height);
void setWindowSize(int columns, int lines, int width, int height);
/** Returns the size of the window used by this teletype. See setWindowSize() */
/** Returns the size of the window used by this teletype in characters. See setWindowSize() */
QSize windowSize() const;
/** Returns the size of the window used by this teletype in pixels. See setWindowSize() */
QSize pixelSize() const;
/**
* Sets the special character for erasing previous not-yet-erased character.
* See termios(3) for detailed description.
......
......@@ -56,9 +56,12 @@ void PtyTest::testWindowSize()
{
Pty pty;
QSize input(80, 40);
pty.setWindowSize(input.width(), input.height());
QSize pxInput(80 * 8, 40 * 16);
pty.setWindowSize(input.width(), input.height(), pxInput.width(), pxInput.height());
QSize output = pty.windowSize();
QCOMPARE(output, input);
QSize pxOutput = pty.pixelSize();
QCOMPARE(pxOutput, pxInput);
}
void PtyTest::testRunProgram()
......
......@@ -47,6 +47,7 @@
#include "profile/ProfileManager.h"
#include "terminalDisplay/TerminalDisplay.h"
#include "terminalDisplay/TerminalFonts.h"
#include "terminalDisplay/TerminalScrollBar.h"
// Linux
......@@ -724,9 +725,8 @@ void Session::sessionAttributeRequest(int id, uint terminator)
}
}
void Session::onViewSizeChange(int height, int width)
void Session::onViewSizeChange(int /* height */, int /* width */)
{
_shellProcess->setPixelSize(width, height);
updateTerminalSize();
}
......@@ -758,7 +758,17 @@ void Session::updateTerminalSize()
void Session::updateWindowSize(int lines, int columns)
{
Q_ASSERT(lines > 0 && columns > 0);
_shellProcess->setWindowSize(columns, lines);
int width = 0;
int height = 0;
if (!_views.isEmpty()) {
// This is somewhat arbitrary. Views having potentially different font sizes is
// irreconcilable with the PTY user having accurate knowledge of the geometry.
QSize cr = _views.at(0)->contentRect().size();
width = cr.width();
height = cr.height();
}
_shellProcess->setWindowSize(columns, lines, width, height);
}
void Session::refresh()
{
......@@ -777,10 +787,13 @@ void Session::refresh()
// send an email with method or patches to konsole-devel@kde.org
const QSize existingSize = _shellProcess->windowSize();
_shellProcess->setWindowSize(existingSize.width() + 1, existingSize.height());
const QSize existingPxSize = _shellProcess->pixelSize();
_shellProcess->setWindowSize(existingSize.width() + 1, existingSize.height(),
existingPxSize.width() + 1, existingPxSize.height());
// introduce small delay to avoid changing size too quickly
QThread::usleep(500);
_shellProcess->setWindowSize(existingSize.width(), existingSize.height());
_shellProcess->setWindowSize(existingSize.width(), existingSize.height(),
existingPxSize.width(), existingPxSize.height());
}
void Session::sendSignal(int signal)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment