Commit c3bed045 authored by Robert Knight's avatar Robert Knight
Browse files

* Give keyboard focus to initial terminal window after startup

* Fix sending of certain keyboard input to terminal (fixes PageUp / PageDown / function 
keys etc.)
* Performance tweak - When updating the terminal window, only avoid repainting whole 
lines that have not changed, rather than checking every single character.  
Note - QRegion is not designed to handle a large number of very small regions.


svn path=/trunk/KDE/kdebase/apps/konsole/; revision=566172
parent 420f5cdb
......@@ -214,9 +214,10 @@ void TEPty::doSendJobs() {
}
SendJob& job = pendingSendJobs.first();
if (!writeStdin(job.buffer.data(), job.length))
if (!writeStdin( job.data(), job.length() ))
{
qWarning("Uh oh.. can't write data..");
qWarning("TEPty::doSendJobs - Could not send input data to terminal process.");
return;
}
m_bufferFull = true;
......
......@@ -99,15 +99,18 @@ Q_OBJECT
QString m_strError;
struct SendJob {
SendJob() {}
SendJob(const char* b, int len) {
buffer.resize(len);
qCopy(b, b+len, buffer.begin());
length = len;
}
QVector<char> buffer;
int length;
class SendJob {
public:
SendJob() {}
SendJob(const char* b, int len) : buffer(len)
{
memcpy( buffer.data() , b , len );
}
const char* data() const { return buffer.constData(); }
int length() const { return buffer.size(); }
private:
QVector<char> buffer;
};
QList<SendJob> pendingSendJobs;
bool m_bufferFull;
......
......@@ -586,7 +586,7 @@ static void drawLineChar(QPainter& paint, int x, int y, int w, int h, uchar code
void TEWidget::drawTextFixed(QPainter& paint, int x, int y, QString& str, const ca* attributes)
{
paint.drawText( QRect( x, y, font_w*str.length(), font_h ), Qt::AlignHCenter | Qt::TextDontClip, str );
paint.drawText( QRect( x, y, font_w*str.length(), font_h ), /*Qt::AlignHCenter |*/ Qt::TextDontClip, str );
}
//OLD VERSION
......@@ -886,6 +886,8 @@ void TEWidget::setImage(const ca* const newimg, int lines, int columns)
const ca* lcl = &image[y*this->columns];
const ca* const ext = &newimg[y*columns];
bool updateLine = false;
// The dirty mask indicates which characters need repainting. We also
// mark surrounding neighbours dirty, in case the character exceeds
// its cell boundaries
......@@ -961,24 +963,24 @@ void TEWidget::setImage(const ca* const newimg, int lines, int columns)
if (doubleWidth)
fixed_font = false;
dirtyRegion |= QRect(bX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h);
/*
#warning pm (backgroundPixmap) is always NULL
drawAttrStr(paint,
QRect(bX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
unistr, &ext[x], pm != NULL, true);
*/
fixed_font = save_fixed_font;
updateLine = true;
fixed_font = save_fixed_font;
x += len - 1;
}
}
if (updateLine)
{
dirtyRegion |= QRect( bX+tLx , bY+tLy+font_h*y , font_w * cols , font_h );
}
dirtyMask--; // Set back
// finally, make `image' become `newimg'.
memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
}
repaint(dirtyRegion);
update(dirtyRegion);
if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = false; }
......
......@@ -414,7 +414,9 @@ void TEmuVt102::updateTitle()
while (iter.hasNext()) {
int arg = iter.next();
emit changeTitle( arg , pendingTitleUpdates[arg] );
}
}
pendingTitleUpdates.clear();
}
// Interpreting Codes ---------------------------------------------------------
......
......@@ -292,7 +292,8 @@ void TEmulation::onKeyPress( QKeyEvent* ev )
// Note that the text is proper unicode.
// We should do a conversion here, but since this
// routine will never be used, we simply emit plain ascii.
emit sndBlock(ev->text().toAscii(),ev->text().length());
//emit sndBlock(ev->text().toAscii(),ev->text().length());
emit sndBlock(ev->text().toUtf8(),ev->text().length());
}
else if (ev->text().toAscii().constData()>0)
{ unsigned char c[1];
......
......@@ -300,7 +300,6 @@ Konsole::Konsole(const char* name, int histon, bool menubaron, bool tabbaron, bo
colors = new ColorSchemaList();
colors->checkSchemas();
colors->sort();
KeyTrans::loadAll();
......@@ -1054,10 +1053,7 @@ void Konsole::makeBasicGUI()
if (m_help)
menubar->insertItem(i18n("Help"), m_help);
#ifdef __GNUC__
# warning "Please verify the casting to QWidget* for KActionCollection"
#endif
m_shortcuts = new KActionCollection((QWidget*)(this));
m_shortcuts = new KActionCollection( (QObject*) this);
m_copyClipboard = new KAction(KIcon("editcopy"), i18n("&Copy"), m_shortcuts, "edit_copy");
connect(m_copyClipboard, SIGNAL(triggered(bool) ), SLOT(slotCopyClipboard()));
......@@ -2423,13 +2419,13 @@ void Konsole::addSession(TESession* s)
s->setTitle(newTitle);
// create an action for the session
// create a new toggle action for the session
KToggleAction *ra = new KToggleAction(KIcon(s->IconName()), newTitle.replace('&',"&&"),
m_shortcuts, QString());
connect(ra, SIGNAL(toggled(bool)), SLOT(activateSession()));
ra->setActionGroup(m_sessionGroup);
ra->setChecked(true);
//ra->setChecked(true);
connect(ra, SIGNAL(toggled(bool)), SLOT(activateSession()));
action2session.insert(ra, s);
session2action.insert(s,ra);
sessions.append(s);
......@@ -2927,7 +2923,9 @@ QString Konsole::newSession(KSimpleConfig *co, QString program, const QStringLis
connect( s, SIGNAL(changeTabTextColor(TESession*, int)),
this,SLOT(changeTabTextColor(TESession*, int)) );
s->widget()->setVTFont(defaultFont);// Hack to set font again after newSession
//REMOVEME
//s->widget()->setVTFont(defaultFont);// Hack to set font again after newSession
s->setSchemaNo(schmno);
if (key.isEmpty())
s->setKeymapNo(n_defaultKeytab);
......@@ -4288,6 +4286,13 @@ void Konsole::enableFixedSize(bool b)
}
}
void Konsole::showEvent( QShowEvent* event )
{
assert( tabwidget && tabwidget->currentWidget() );
tabwidget->currentWidget()->setFocus();
}
Q3PtrList<TEWidget> Konsole::activeTEs()
{
Q3PtrList<TEWidget> ret;
......
......@@ -142,6 +142,9 @@ protected:
void saveProperties(KConfig* config);
void readProperties(KConfig* config);
//virtual void focusInEvent(QFocusEvent* event);
virtual void showEvent(QShowEvent* event);
private Q_SLOTS:
void configureRequest(TEWidget*,int,int,int);
void activateSession();
......
......@@ -632,29 +632,5 @@ extern "C" int KDE_EXPORT kdemain(int argc, char* argv[])
int ret = a.exec();
//// Temporary code, waiting for Qt to do this properly
#ifdef __GNUC__
#warning "I ported this hack directly: may be it's no longer needed?"
#endif
// Delete all toplevel widgets that have WDestructiveClose
QList<QWidget*> list = QApplication::topLevelWidgets();
// remove all toplevel widgets that have a parent (i.e. they
// got WTopLevel explicitly), they'll be deleted by the parent
QMutableListIterator<QWidget*> it(list);
while(it.hasNext())
{
QWidget* widget = it.next();
if( widget->parentWidget() != NULL || !widget->testAttribute(Qt::WA_DeleteOnClose) )
{
it.remove();
continue;
}
}
foreach(QWidget* w, list)
delete w;
return ret;
}
......@@ -202,6 +202,13 @@ void TESession::changeTabTextColor( int color )
emit changeTabTextColor( this, color );
}
// NOTE: TESession::hasChildren() was originally written so that the 'do you really want to close?'
// prompt delivered when closing a session would only be shown if the session had running processes.
// However, it was decided that stat-ing everything in /proc was very expensive, and others
// disagreed with the basic idea.
//
// This code is left here in case anyone wants to know a way of figuring out
// the PIDs of processes running in the terminal sessions :)
bool TESession::hasChildren()
{
int sessionPID=sh->pid();
......@@ -284,6 +291,7 @@ void TESession::setUserTitle( int what, const QString &caption )
if (what == 11) {
QString colorString = caption.section(';',0,0);
kDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString << endl;
QColor backColor = QColor(colorString);
if (backColor.isValid()){// change color via \033]11;Color\007
if (backColor != modifiedBackground) {
......
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