Commit 9ffa69e1 authored by Tomas Mecir's avatar Tomas Mecir

don't spam NAWS all the time

parent faa01e04
...@@ -293,6 +293,9 @@ void cTelnet::reset () ...@@ -293,6 +293,9 @@ void cTelnet::reset ()
//reset telnet status //reset telnet status
d->iac = d->iac2 = d->insb = false; d->iac = d->iac2 = d->insb = false;
d->command = ""; d->command = "";
// reset these so that we report dimensions correctly
d->curX = 0;
d->curY = 0;
} }
void cTelnet::socketConnected () void cTelnet::socketConnected ()
...@@ -519,12 +522,11 @@ void cTelnet::windowSizeChanged (int x, int y) ...@@ -519,12 +522,11 @@ void cTelnet::windowSizeChanged (int x, int y)
//remember the size - we'll need it if NAWS is currently disabled but will //remember the size - we'll need it if NAWS is currently disabled but will
//be enabled. Also remember it if no connection exists at the moment; //be enabled. Also remember it if no connection exists at the moment;
//we won't be called again when connecting //we won't be called again when connecting
d->curX = x;
d->curY = y;
if (!(isConnected())) if (!(isConnected()))
return; return;
if (d->myOptionState[OPT_NAWS]) //only if we have negotiated this option if (!d->myOptionState[OPT_NAWS]) return; //only if we have negotiated this option
{ if ((x == d->curX) && (y == d->curY)) return; // don't spam sizes if we have sent the current one already
string s; string s;
s = TN_IAC; s = TN_IAC;
s += TN_SB; s += TN_SB;
...@@ -551,7 +553,6 @@ void cTelnet::windowSizeChanged (int x, int y) ...@@ -551,7 +553,6 @@ void cTelnet::windowSizeChanged (int x, int y)
s += TN_IAC; s += TN_IAC;
s += TN_SE; s += TN_SE;
doSendData (s); doSendData (s);
}
} }
void cTelnet::sendTelnetOption (unsigned char type, unsigned char option) void cTelnet::sendTelnetOption (unsigned char type, unsigned char option)
......
...@@ -218,7 +218,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) { ...@@ -218,7 +218,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
viewport()->setCursor (Qt::IBeamCursor); viewport()->setCursor (Qt::IBeamCursor);
forceBeginOfLine (); forceBeginOfLine ();
fixupOutput(); fixupOutput(true);
} }
cConsole::~cConsole() { cConsole::~cConsole() {
...@@ -242,7 +242,7 @@ void cConsole::setFont (QFont f) { ...@@ -242,7 +242,7 @@ void cConsole::setFont (QFont f) {
d->charWidth = fm.width ("m"); d->charWidth = fm.width ("m");
d->charHeight = fm.lineSpacing() + 2; d->charHeight = fm.lineSpacing() + 2;
fixupOutput(); fixupOutput(true);
} }
QFont cConsole::font () { QFont cConsole::font () {
...@@ -415,7 +415,7 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine) ...@@ -415,7 +415,7 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
if (!d->atBottom) bar->setValue (bar->value() - fheight); if (!d->atBottom) bar->setValue (bar->value() - fheight);
} }
fixupOutput(); fixupOutput(false);
} }
void cConsole::forceBeginOfLine () { void cConsole::forceBeginOfLine () {
...@@ -459,14 +459,14 @@ void cConsole::pageDown () { ...@@ -459,14 +459,14 @@ void cConsole::pageDown () {
void cConsole::resizeEvent (QResizeEvent *) void cConsole::resizeEvent (QResizeEvent *)
{ {
fixupOutput(); fixupOutput(true);
} }
// this is needed to resize the text display at startup // this is needed to resize the text display at startup
bool cConsole::viewportEvent(QEvent *event) bool cConsole::viewportEvent(QEvent *event)
{ {
if (event->type() == QEvent::Resize) if (event->type() == QEvent::Resize)
fixupOutput(); fixupOutput(true);
return QGraphicsView::viewportEvent (event); return QGraphicsView::viewportEvent (event);
} }
...@@ -493,7 +493,7 @@ void cConsole::scrollContentsBy (int dx, int dy) ...@@ -493,7 +493,7 @@ void cConsole::scrollContentsBy (int dx, int dy)
adjustScrollBack(); adjustScrollBack();
} }
void cConsole::fixupOutput () void cConsole::fixupOutput (bool sizeChanged)
{ {
double h = max ((qreal) viewport()->height(), d->text->documentLayout()->documentSize().height()); double h = max ((qreal) viewport()->height(), d->text->documentLayout()->documentSize().height());
scene()->setSceneRect (0, 0, viewport()->width(), h); scene()->setSceneRect (0, 0, viewport()->width(), h);
...@@ -503,6 +503,7 @@ void cConsole::fixupOutput () ...@@ -503,6 +503,7 @@ void cConsole::fixupOutput ()
d->scrollText->updateSize(); d->scrollText->updateSize();
adjustScrollBack (); adjustScrollBack ();
if (sizeChanged)
forceEmitSize (); forceEmitSize ();
} }
......
...@@ -116,7 +116,7 @@ protected: ...@@ -116,7 +116,7 @@ protected:
bool viewportEvent(QEvent *event) override; bool viewportEvent(QEvent *event) override;
virtual void scrollContentsBy (int dx, int dy) override; virtual void scrollContentsBy (int dx, int dy) override;
/** called when resizing and when changing font */ /** called when resizing and when changing font */
void fixupOutput (); void fixupOutput (bool sizeChanged = false);
void adjustScrollBack (); void adjustScrollBack ();
void addNewText (cTextChunk *chunk, bool endTheLine); void addNewText (cTextChunk *chunk, bool endTheLine);
......
Markdown is supported
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