Make sure pty device has right size before terminal process queries it.

Whenever TeminalDisplay is resized, konsole tells the underlying
pty device its new size by calling Pty::setWindowSize(). However,
current code can't guarantee when the terminal process starts and
queries the pty device about its size, the pty device already has the
right info. This has caused some long known bugs, such as #176902.

This patch tries to guarantee that important assumption. It currently
uses a hard-coded small delay, which works pretty well in practice
although not that elegant.

Patch by Jekyll Wu <adaptee@gmail.com>

I think this is better than leaving the situation as it is.  This may
be backported if no issues are found.
BUG: 173999
BUG: 176902
BUG: 203185
BUG: 229058
REVIEW: 102061
FIXED-IN: 4.8
This commit is contained in:
Kurt Hindenburg
2011-08-05 10:40:14 -04:00
parent 51575d6f52
commit 7e00edd516
4 changed files with 38 additions and 7 deletions

View File

@@ -58,7 +58,8 @@ Emulation::Emulation() :
_codec(0),
_decoder(0),
_keyTranslator(0),
_usesMouse(false)
_usesMouse(false),
_imageSizeInitialized(false)
{
// create screens with a default size
_screen[0] = new Screen(40,80);
@@ -347,14 +348,37 @@ void Emulation::setImageSize(int lines, int columns)
QSize newSize(columns,lines);
if (newSize == screenSize[0] && newSize == screenSize[1])
return;
{
// If this method is called for the first time, always emit
// SIGNAL(imageSizeChange()), even if the new size is the same as the
// current size. See #176902
if (!_imageSizeInitialized)
{
emit imageSizeChanged(lines,columns);
}
}
else
{
_screen[0]->resizeImage(lines,columns);
_screen[1]->resizeImage(lines,columns);
_screen[0]->resizeImage(lines,columns);
_screen[1]->resizeImage(lines,columns);
emit imageSizeChanged(lines,columns);
emit imageSizeChanged(lines,columns);
bufferedUpdate();
}
if (!_imageSizeInitialized)
{
_imageSizeInitialized = true;
// FIXME
// a hard-coded, small delay is introduced to gurarantee Session::run()
// does not get triggered by SIGNAL(imageSizeInitialized()) before
// Pty::setWindowSize() is triggered by previously emitted
// SIGNAL(imageSizeChanged()); See #203185
QTimer::singleShot(200, this, SIGNAL(imageSizeInitialized()) );
}
bufferedUpdate();
}
QSize Emulation::imageSize() const