Kernel/LibC: Rework TIOC{G,S}WINSZ more linux like
Userspace can freely set terminal size, kernel just updates it when for example new font is loaded. Also SIGWINCH is now sent by kernel instead of userspace.
This commit is contained in:
@@ -41,6 +41,8 @@ struct winsize
|
||||
{
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel; /* unused by kernel */
|
||||
unsigned short ws_ypixel; /* unused by kernel */
|
||||
};
|
||||
#define TIOCGWINSZ 50
|
||||
#define TIOCSWINSZ 51
|
||||
|
||||
@@ -128,9 +128,12 @@ void Terminal::run()
|
||||
m_window->set_min_size(m_font.width() * 8, m_font.height() * 2);
|
||||
|
||||
{
|
||||
winsize winsize;
|
||||
winsize.ws_col = cols();
|
||||
winsize.ws_row = rows();
|
||||
winsize winsize {
|
||||
.ws_row = static_cast<unsigned short>(rows()),
|
||||
.ws_col = static_cast<unsigned short>(cols()),
|
||||
.ws_xpixel = static_cast<unsigned short>(m_window->width()),
|
||||
.ws_ypixel = static_cast<unsigned short>(m_window->height()),
|
||||
};
|
||||
if (ioctl(m_shell_info.pts_master, TIOCSWINSZ, &winsize) == -1)
|
||||
perror("ioctl");
|
||||
}
|
||||
@@ -170,6 +173,8 @@ void Terminal::run()
|
||||
const winsize winsize {
|
||||
.ws_row = static_cast<unsigned short>(rows()),
|
||||
.ws_col = static_cast<unsigned short>(cols()),
|
||||
.ws_xpixel = static_cast<unsigned short>(m_window->width()),
|
||||
.ws_ypixel = static_cast<unsigned short>(m_window->height()),
|
||||
};
|
||||
if (ioctl(m_shell_info.pts_master, TIOCSWINSZ, &winsize) == -1)
|
||||
{
|
||||
@@ -183,12 +188,6 @@ void Terminal::run()
|
||||
perror("tcgetpgrp");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kill(-fgpgrp, SIGWINCH) == -1)
|
||||
{
|
||||
perror("kill");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
const int max_fd = BAN::Math::max(m_shell_info.pts_master, m_window->server_fd());
|
||||
|
||||
@@ -328,7 +328,7 @@ int main(int argc, char** argv)
|
||||
tcsetattr(kb_fd, TCSANOW, &termios);
|
||||
}
|
||||
|
||||
winsize ws { .ws_row = 0, .ws_col = 0 };
|
||||
winsize ws {};
|
||||
if (isatty(STDOUT_FILENO))
|
||||
{
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
|
||||
Reference in New Issue
Block a user