Use TIOCSWINSZ ioctl to set pty's pixel size, so it will be reported to apps using TIOCGWINSZE

This commit is contained in:
Matan Ziv-Av
2022-01-22 12:44:17 +02:00
committed by Tomaz Canabrava
parent f13ac9ca95
commit 7a27f40722
3 changed files with 22 additions and 1 deletions

View File

@@ -11,6 +11,9 @@
// System
#include <csignal>
#if !defined(Q_OS_WIN)
#include <sys/ioctl.h> //ioctl() and TIOCSWINSZ
#endif
#include <termios.h>
// Qt
@@ -85,9 +88,23 @@ void Pty::setWindowSize(int columns, int lines)
if (pty()->masterFd() >= 0) {
pty()->setWinSize(lines, columns);
#if !defined(Q_OS_WIN)
struct winsize w;
w.ws_xpixel = _windowWidth;
w.ws_ypixel = _windowHeight;
w.ws_col = _windowColumns;
w.ws_row = _windowLines;
ioctl(pty()->masterFd(), TIOCSWINSZ, &w);
#endif
}
}
void Pty::setPixelSize(int width, int height)
{
_windowWidth = width;
_windowHeight = height;
}
QSize Pty::windowSize() const
{
return {_windowColumns, _windowLines};

View File

@@ -90,6 +90,7 @@ public:
* used by this teletype.
*/
void setWindowSize(int columns, int lines);
void setPixelSize(int width, int height);
/** Returns the size of the window used by this teletype. See setWindowSize() */
QSize windowSize() const;
@@ -163,6 +164,8 @@ private:
int _windowColumns;
int _windowLines;
int _windowWidth;
int _windowHeight;
char _eraseChar;
bool _xonXoff;
bool _utf8;

View File

@@ -724,8 +724,9 @@ 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();
}