From c7a9fafe524bdb6549860057d3ecd92f4c931a4d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 19 Apr 2014 23:19:49 +0900 Subject: [PATCH 01/11] Added support for handling Meta key as Alt key in terminal emulation. This relates to bug 1026. --- konsole/konsole/TEmuVt102.cpp | 29 +++++++++++++++++------------ konsole/konsole/TEmulation.cpp | 1 + konsole/konsole/TEmulation.h | 2 ++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp index c460693cd..ebe090fda 100644 --- a/konsole/konsole/TEmuVt102.cpp +++ b/konsole/konsole/TEmuVt102.cpp @@ -936,18 +936,21 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) // lookup in keyboard translation table ... int cmd = CMD_none; - const char* txt; + const char *txt; int len; bool metaspecified; - if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, - encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, - encodeMode(MODE_AppCuKeys , BITS_AppCuKeys ) + // VT100 stuff - encodeMode(MODE_AppScreen , BITS_AppScreen ) + // VT100 stuff - encodeStat(TQt::ControlButton , BITS_Control ) + - encodeStat(TQt::ShiftButton , BITS_Shift ) + - encodeStat(TQt::AltButton , BITS_Alt ), - &cmd, &txt, &len, &metaspecified )) -//printf("cmd: %d, %s, %d\n",cmd,txt,len); + int bits = encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, + encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, + encodeMode(MODE_AppCuKeys , BITS_AppCuKeys ) + // VT100 stuff + encodeMode(MODE_AppScreen , BITS_AppScreen ) + // VT100 stuff + encodeStat(TQt::ControlButton, BITS_Control ) + + encodeStat(TQt::ShiftButton , BITS_Shift ) + + encodeStat(TQt::AltButton , BITS_Alt ); + if (metaKeyMode) + bits += encodeStat(TQt::MetaButton , BITS_Alt); + bool transRes = keytrans->findEntry(ev->key(), bits, &cmd, &txt, &len, &metaspecified); +//if (transRes) +// printf("cmd: %d, %s, %d\n",cmd,txt,len); if (connected) { switch(cmd) // ... and execute if found. @@ -976,8 +979,10 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) || ev->key()==Qt::Key_PageUp || ev->key()==Qt::Key_PageDown)) scr->setHistCursor(scr->getHistLines()); - if (cmd==CMD_send) { - if ((ev->state() & TQt::AltButton) && !metaspecified ) sendString("\033"); + if (cmd==CMD_send) + { + if (((ev->state() & TQt::AltButton) || (metaKeyMode && (ev->state() & TQt::MetaButton))) && !metaspecified) + sendString("\033"); emit sndBlock(txt,len); return; } diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp index 939139d03..3aa1cfad4 100644 --- a/konsole/konsole/TEmulation.cpp +++ b/konsole/konsole/TEmulation.cpp @@ -98,6 +98,7 @@ TEmulation::TEmulation(TEWidget* w) scr(0), connected(false), listenToKeyPress(false), + metaKeyMode(false), m_codec(0), decoder(0), keytrans(0), diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h index a5f432175..6eac5f91b 100644 --- a/konsole/konsole/TEmulation.h +++ b/konsole/konsole/TEmulation.h @@ -89,6 +89,7 @@ public: virtual void setMode (int) = 0; virtual void resetMode(int) = 0; + void setMetaKeyMode(bool mode) { metaKeyMode = mode; } virtual void sendString(const char*) = 0; @@ -119,6 +120,7 @@ protected: bool connected; // communicate with widget bool listenToKeyPress; // listen to input + bool metaKeyMode; // true -> meta key is handled as Alt void setCodec(int c); // codec number, 0 = locale, 1=utf8 From f69bb8df1debfec9d20dd6069f8034263ca31049 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 20 Apr 2014 00:31:22 +0900 Subject: [PATCH 02/11] Added support for handling Meta key as Alt key in konsolePart. This relates to bug 1026. --- konsole/konsole/konsole.cpp | 20 ++++++++++---------- konsole/konsole/konsole_part.cpp | 23 +++++++++++++++++++---- konsole/konsole/konsole_part.h | 9 ++++++--- konsole/konsole/session.cpp | 6 ++++++ konsole/konsole/session.h | 1 + 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index a7d3d7333..26d35602e 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -2953,21 +2953,21 @@ TQString Konsole::newSession(KSimpleConfig *co, TQString program, const TQStrLis s->enableFullScripting(b_fullScripting); // If you add any new signal-slot connection below, think about doing it in konsolePart too connect( s,TQT_SIGNAL(done(TESession*)), - this,TQT_SLOT(doneSession(TESession*)) ); - connect( s, TQT_SIGNAL( updateTitle(TESession*) ), - this, TQT_SLOT( updateTitle(TESession*) ) ); - connect( s, TQT_SIGNAL( notifySessionState(TESession*, int) ), - this, TQT_SLOT( notifySessionState(TESession*, int)) ); + this,TQT_SLOT(doneSession(TESession*))); + connect( s, TQT_SIGNAL(updateTitle(TESession*)), + this, TQT_SLOT(updateTitle(TESession*))); + connect( s, TQT_SIGNAL(notifySessionState(TESession*, int)), + this, TQT_SLOT(notifySessionState(TESession*, int))); connect( s, TQT_SIGNAL(disableMasterModeConnections()), - this, TQT_SLOT(disableMasterModeConnections()) ); + this, TQT_SLOT(disableMasterModeConnections())); connect( s, TQT_SIGNAL(enableMasterModeConnections()), - this, TQT_SLOT(enableMasterModeConnections()) ); + this, TQT_SLOT(enableMasterModeConnections())); connect( s, TQT_SIGNAL(renameSession(TESession*,const TQString&)), - this, TQT_SLOT(slotRenameSession(TESession*, const TQString&)) ); + this, TQT_SLOT(slotRenameSession(TESession*, const TQString&))); connect( s->getEmulation(), TQT_SIGNAL(changeColumns(int)), this, TQT_SLOT(changeColumns(int)) ); connect( s->getEmulation(), TQT_SIGNAL(changeColLin(int,int)), - this, TQT_SLOT(changeColLin(int,int)) ); + this, TQT_SLOT(changeColLin(int,int))); connect( s->getEmulation(), TQT_SIGNAL(ImageSizeChanged(int,int)), this, TQT_SLOT(notifySize(int,int))); connect( s, TQT_SIGNAL(zmodemDetected(TESession*)), @@ -2983,7 +2983,7 @@ TQString Konsole::newSession(KSimpleConfig *co, TQString program, const TQStrLis connect( s, TQT_SIGNAL(setSessionSchema(TESession*, const TQString &)), this, TQT_SLOT(slotSetSessionSchema(TESession*, const TQString &))); connect( s, TQT_SIGNAL(changeTabTextColor(TESession*, int)), - this,TQT_SLOT(changeTabTextColor(TESession*, int)) ); + this,TQT_SLOT(changeTabTextColor(TESession*, int))); s->widget()->setVTFont(defaultFont);// Hack to set font again after newSession s->setSchemaNo(schmno); diff --git a/konsole/konsole/konsole_part.cpp b/konsole/konsole/konsole_part.cpp index f1b2f28d8..87cd2b373 100644 --- a/konsole/konsole/konsole_part.cpp +++ b/konsole/konsole/konsole_part.cpp @@ -105,6 +105,7 @@ konsolePart::konsolePart(TQWidget *_parentWidget, const char *widgetName, TQObje ,rootxpm(0) ,blinkingCursor(0) ,showFrame(0) +,metaAsAlt(0) ,m_useKonsoleSettings(0) ,selectBell(0) ,selectLineSpacing(0) @@ -431,6 +432,11 @@ void konsolePart::makeGUI() showFrame->setCheckedState(i18n("Hide Fr&ame")); showFrame->plug(m_options); + // Meta key as Alt key + metaAsAlt = new TDEToggleAction(i18n("Me&ta key as Alt key"), 0, + this, TQT_SLOT(slotToggleMetaAsAltMode()), settingsActions); + metaAsAlt->plug(m_options); + // Word Connectors TDEAction *WordSeps = new TDEAction(i18n("Wor&d Connectors..."), 0, this, TQT_SLOT(slotWordSeps()), settingsActions); @@ -505,6 +511,8 @@ void konsolePart::applySettingsToGUI() selectLineSpacing->setCurrentItem(te->lineSpacing()); if (blinkingCursor) blinkingCursor->setChecked(te->blinkingCursor()); + if (metaAsAlt) + metaAsAlt->setChecked(b_metaAsAlt); if (m_schema) m_schema->setItemChecked(curr_schema,true); if (selectSetEncoding) @@ -532,6 +540,8 @@ void konsolePart::applyProperties() se->widget()->setVTFont( defaultFont ); se->setSchemaNo( curr_schema ); slotSetEncoding(); + + se->setMetaAsAltMode(b_metaAsAlt); } void konsolePart::setSettingsMenuEnabled( bool enable ) @@ -560,13 +570,13 @@ void konsolePart::readProperties() config->setDesktopGroup(); b_framevis = config->readBoolEntry("has frame",false); + b_metaAsAlt = config->readBoolEntry("metaAsAltMode",false); b_histEnabled = config->readBoolEntry("historyenabled",true); n_bell = TQMIN(config->readUnsignedNumEntry("bellmode",TEWidget::BELLSYSTEM),3); n_keytab=config->readNumEntry("keytab",0); // act. the keytab for this session n_scroll = TQMIN(config->readUnsignedNumEntry("scrollbar",TEWidget::SCRRIGHT),2); m_histSize = config->readNumEntry("history",DEFAULT_HISTORY_SIZE); s_word_seps= config->readEntry("wordseps",":@-./_~"); - n_encoding = config->readNumEntry("encoding",0); TQFont tmpFont = TDEGlobalSettings::fixedFont(); @@ -637,6 +647,7 @@ void konsolePart::saveProperties() config->writeEntry("historyenabled", b_histEnabled); config->writeEntry("keytab",n_keytab); config->writeEntry("has frame",b_framevis); + config->writeEntry("metaAsAltMode",b_metaAsAlt); config->writeEntry("LineSpacing", te->lineSpacing()); config->writeEntry("schema",s_tdeconfigSchema); config->writeEntry("scrollbar",n_scroll); @@ -914,14 +925,18 @@ void konsolePart::slotBlinkingCursor() te->setBlinkingCursor(blinkingCursor->isChecked()); } +void konsolePart::slotToggleMetaAsAltMode() +{ + b_metaAsAlt ^= true; + if (!se) return; + se->setMetaAsAltMode(b_metaAsAlt); +} + void konsolePart::slotUseKonsoleSettings() { b_useKonsoleSettings = m_useKonsoleSettings->isChecked(); - setSettingsMenuEnabled( !b_useKonsoleSettings ); - readProperties(); - applySettingsToGUI(); } diff --git a/konsole/konsole/konsole_part.h b/konsole/konsole/konsole_part.h index 1fd2ac95f..766e4e5d5 100644 --- a/konsole/konsole/konsole_part.h +++ b/konsole/konsole/konsole_part.h @@ -118,6 +118,7 @@ signals: void slotSelectBell(); void slotSelectLineSpacing(); void slotBlinkingCursor(); + void slotToggleMetaAsAltMode(); void slotUseKonsoleSettings(); void slotWordSeps(); void slotSetEncoding(); @@ -136,9 +137,9 @@ signals: void setSchema(ColorSchema* s); void updateKeytabMenu(); - bool doOpenStream( const TQString& ); - bool doWriteStream( const TQByteArray& ); - bool doCloseStream(); + bool doOpenStream( const TQString& ); + bool doWriteStream( const TQByteArray& ); + bool doCloseStream(); TQWidget* parentWidget; TEWidget* te; @@ -151,6 +152,7 @@ signals: TDEToggleAction* blinkingCursor; TDEToggleAction* showFrame; + TDEToggleAction* metaAsAlt; TDEToggleAction* m_useKonsoleSettings; TDESelectAction* selectBell; @@ -174,6 +176,7 @@ signals: TQString s_word_seps; // characters that are considered part of a word bool b_framevis:1; + bool b_metaAsAlt:1; bool b_histEnabled:1; bool b_useKonsoleSettings:1; bool b_autoDestroy:1; diff --git a/konsole/konsole/session.cpp b/konsole/konsole/session.cpp index 8ecf469af..a6103da4f 100644 --- a/konsole/konsole/session.cpp +++ b/konsole/konsole/session.cpp @@ -464,6 +464,12 @@ void TESession::setFontNo(int fn) font_no = fn; } +void TESession::setMetaAsAltMode(bool mode) +{ + if (em) + em->setMetaKeyMode(mode); +} + void TESession::setTitle(const TQString& _title) { title = _title; diff --git a/konsole/konsole/session.h b/konsole/konsole/session.h index d15b8b5bd..bfcafdf47 100644 --- a/konsole/konsole/session.h +++ b/konsole/konsole/session.h @@ -123,6 +123,7 @@ public: void setSize(TQSize size); void setFont(const TQString &font); TQString font(); + void setMetaAsAltMode(bool mode); public slots: From dfa62cdbea831ee3fcc29ca884c779a5459d5e08 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 21 Apr 2014 17:49:25 +0900 Subject: [PATCH 03/11] Added support for handling Meta key as Alt key in Konsole. This relates to bug 1026. --- konsole/konsole/konsole.cpp | 11 ++++++++++- konsole/konsole/konsole.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index 26d35602e..f59ae83da 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -273,6 +273,7 @@ Konsole::Konsole(const char* name, int histon, bool menubaron, bool tabbaron, bo ,b_autoResizeTabs(false) ,b_installBitmapFonts(false) ,b_framevis(true) +,b_metaAsAlt(false) ,b_fullscreen(false) ,m_menuCreated(false) ,b_warnQuit(false) @@ -1622,6 +1623,7 @@ void Konsole::readProperties(TDEConfig* config, const TQString &schema, bool glo b_bidiEnabled = config->readBoolEntry("EnableBidi",false); s_word_seps= config->readEntry("wordseps",":@-./_~"); b_framevis = config->readBoolEntry("has frame",true); + b_metaAsAlt = config->readBoolEntry("metaAsAltMode",false); TQPtrList tes = activeTEs(); for (TEWidget *_te = tes.first(); _te; _te = tes.next()) { _te->setWordCharacters(s_word_seps); @@ -1636,7 +1638,10 @@ void Konsole::readProperties(TDEConfig* config, const TQString &schema, bool glo monitorSilenceSeconds=config->readUnsignedNumEntry("SilenceSeconds", 10); for (TESession *ses = sessions.first(); ses; ses = sessions.next()) + { + ses->setMetaAsAltMode(b_metaAsAlt); ses->setMonitorSilenceSeconds(monitorSilenceSeconds); + } b_xonXoff = config->readBoolEntry("XonXoff",false); b_matchTabWinTitle = config->readBoolEntry("MatchTabWinTitle",false); @@ -2187,7 +2192,9 @@ void Konsole::reparseConfiguration() curr_schema = sch->numb(); pmPath = sch->imagePath(); - for (TESession *_se = sessions.first(); _se; _se = sessions.next()) { + for (TESession *_se = sessions.first(); _se; _se = sessions.next()) + { + _se->setMetaAsAltMode(b_metaAsAlt); ColorSchema* s = colors->find( _se->schemaNo() ); if (s) { if (s->hasSchemaFileChanged()) @@ -2951,6 +2958,8 @@ TQString Konsole::newSession(KSimpleConfig *co, TQString program, const TQStrLis s->setProgram(TQFile::encodeName(program),cmdArgs); s->setMonitorSilenceSeconds(monitorSilenceSeconds); s->enableFullScripting(b_fullScripting); + s->setMetaAsAltMode(b_metaAsAlt); + // If you add any new signal-slot connection below, think about doing it in konsolePart too connect( s,TQT_SIGNAL(done(TESession*)), this,TQT_SLOT(doneSession(TESession*))); diff --git a/konsole/konsole/konsole.h b/konsole/konsole/konsole.h index 6bd3a2e81..976ac5cf8 100644 --- a/konsole/konsole/konsole.h +++ b/konsole/konsole/konsole.h @@ -435,6 +435,7 @@ private: bool b_installBitmapFonts; bool b_framevis:1; + bool b_metaAsAlt:1; bool b_fullscreen:1; bool m_menuCreated:1; bool b_warnQuit:1; From 8b69d90d3fbacd82efff43e5ecbe64fdb2c23882 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 21 Apr 2014 18:14:10 +0900 Subject: [PATCH 04/11] Added Meta key as Alt key option in Kcontrol/Konsole. This relates to bug 1026. Also improved options arrangement in the same configuration page. --- kcontrol/konsole/kcmkonsole.cpp | 3 ++ kcontrol/konsole/kcmkonsoledialog.ui | 69 +++++++++++++--------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/kcontrol/konsole/kcmkonsole.cpp b/kcontrol/konsole/kcmkonsole.cpp index 8c7892083..97d3d0db0 100644 --- a/kcontrol/konsole/kcmkonsole.cpp +++ b/kcontrol/konsole/kcmkonsole.cpp @@ -73,6 +73,7 @@ KCMKonsole::KCMKonsole(TQWidget * parent, const char *name, const TQStringList&) connect(dialog->matchTabWinTitleCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->tabsCycleWheel,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->menuAccelerators,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->metaAsAltModeCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->silence_secondsSB,TQT_SIGNAL(valueChanged(int)), TQT_SLOT( changed() )); connect(dialog->word_connectorLE,TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT( changed() )); connect(dialog->SchemaEditor1, TQT_SIGNAL(changed()), TQT_SLOT( changed() )); @@ -110,6 +111,7 @@ void KCMKonsole::load(bool useDefaults) dialog->line_spacingSB->setValue(config.readUnsignedNumEntry( "LineSpacing", 0 )); dialog->silence_secondsSB->setValue(config.readUnsignedNumEntry( "SilenceSeconds", 10 )); dialog->word_connectorLE->setText(config.readEntry("wordseps",":@-./_~")); + dialog->metaAsAltModeCB->setChecked(config.readBoolEntry("metaAsAltMode",false)); dialog->SchemaEditor1->setSchema(config.readEntry("schema")); @@ -150,6 +152,7 @@ void KCMKonsole::save() config.writeEntry("LineSpacing" , dialog->line_spacingSB->value()); config.writeEntry("SilenceSeconds" , dialog->silence_secondsSB->value()); config.writeEntry("wordseps", dialog->word_connectorLE->text()); + config.writeEntry("metaAsAltMode", dialog->metaAsAltModeCB->isChecked()); config.writeEntry("schema", dialog->SchemaEditor1->schema()); diff --git a/kcontrol/konsole/kcmkonsoledialog.ui b/kcontrol/konsole/kcmkonsoledialog.ui index 1ce6b2f8f..6e06747c3 100644 --- a/kcontrol/konsole/kcmkonsoledialog.ui +++ b/kcontrol/konsole/kcmkonsoledialog.ui @@ -66,9 +66,6 @@ GroupBox2 - - Misc - unnamed @@ -186,7 +183,34 @@ Enable main menu accelerator keys - + + + metaAsAltModeCB + + + Handle Meta key as Alt Key + + + + + TextLabel1_4 + + + + 1 + 5 + 0 + 0 + + + + &Line spacing: + + + line_spacingSB + + + line_spacingSB @@ -205,25 +229,6 @@ 8 - - - TextLabel1_4 - - - - 1 - 5 - 0 - 0 - - - - &Line spacing: - - - line_spacingSB - - Spacer2 @@ -241,7 +246,7 @@ - + SilenceLabel @@ -260,7 +265,7 @@ silence_secondsSB - + silence_secondsSB @@ -276,20 +281,10 @@ 1 - - - - - GroupBox3 - - - Double Click - - unnamed - + TextLabel1_3 @@ -300,7 +295,7 @@ word_connectorLE - + word_connectorLE From 115138a5a0e7e00c2092345972d9a003384af8a7 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 21 Apr 2014 18:16:50 +0900 Subject: [PATCH 05/11] Renamed two check box objects in KControl/Konsole to maintain name consistency with other check boxes. --- kcontrol/konsole/kcmkonsole.cpp | 12 ++++++------ kcontrol/konsole/kcmkonsoledialog.ui | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kcontrol/konsole/kcmkonsole.cpp b/kcontrol/konsole/kcmkonsole.cpp index 97d3d0db0..e2b280dfa 100644 --- a/kcontrol/konsole/kcmkonsole.cpp +++ b/kcontrol/konsole/kcmkonsole.cpp @@ -71,8 +71,8 @@ KCMKonsole::KCMKonsole(TQWidget * parent, const char *name, const TQStringList&) connect(dialog->frameCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->line_spacingSB,TQT_SIGNAL(valueChanged(int)), TQT_SLOT( changed() )); connect(dialog->matchTabWinTitleCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); - connect(dialog->tabsCycleWheel,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); - connect(dialog->menuAccelerators,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->tabsCycleWheelCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->menuAcceleratorsCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->metaAsAltModeCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->silence_secondsSB,TQT_SIGNAL(valueChanged(int)), TQT_SLOT( changed() )); connect(dialog->word_connectorLE,TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT( changed() )); @@ -98,8 +98,8 @@ void KCMKonsole::load(bool useDefaults) bidiOrig = config.readBoolEntry("EnableBidi",false); dialog->bidiCB->setChecked(bidiOrig); dialog->matchTabWinTitleCB->setChecked(config.readBoolEntry("MatchTabWinTitle",false)); - dialog->tabsCycleWheel->setChecked(config.readBoolEntry("TabsCycleWheel",true)); - dialog->menuAccelerators->setChecked(config.readBoolEntry("MenuAccelerators",false)); + dialog->tabsCycleWheelCB->setChecked(config.readBoolEntry("TabsCycleWheel",true)); + dialog->menuAcceleratorsCB->setChecked(config.readBoolEntry("MenuAccelerators",false)); dialog->warnCB->setChecked(config.readBoolEntry("WarnQuit",true)); dialog->ctrldragCB->setChecked(config.readBoolEntry("CtrlDrag",true)); dialog->cutToBeginningOfLineCB->setChecked(config.readBoolEntry("CutToBeginningOfLine",false)); @@ -139,8 +139,8 @@ void KCMKonsole::save() bool bidiNew = dialog->bidiCB->isChecked(); config.writeEntry("EnableBidi", bidiNew); config.writeEntry("MatchTabWinTitle", dialog->matchTabWinTitleCB->isChecked()); - config.writeEntry("TabsCycleWheel", dialog->tabsCycleWheel->isChecked()); - config.writeEntry("MenuAccelerators", dialog->menuAccelerators->isChecked()); + config.writeEntry("TabsCycleWheel", dialog->tabsCycleWheelCB->isChecked()); + config.writeEntry("MenuAccelerators", dialog->menuAcceleratorsCB->isChecked()); config.writeEntry("WarnQuit", dialog->warnCB->isChecked()); config.writeEntry("CtrlDrag", dialog->ctrldragCB->isChecked()); config.writeEntry("CutToBeginningOfLine", dialog->cutToBeginningOfLineCB->isChecked()); diff --git a/kcontrol/konsole/kcmkonsoledialog.ui b/kcontrol/konsole/kcmkonsoledialog.ui index 6e06747c3..ec01401cf 100644 --- a/kcontrol/konsole/kcmkonsoledialog.ui +++ b/kcontrol/konsole/kcmkonsoledialog.ui @@ -169,7 +169,7 @@ - tabsCycleWheel + tabsCycleWheelCB Cycle tabs with mouse wheel @@ -177,7 +177,7 @@ - menuAccelerators + menuAcceleratorsCB Enable main menu accelerator keys From c5a0a7cec07dee8b52c7add7822d25a137137df2 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 21 Apr 2014 18:22:55 +0900 Subject: [PATCH 06/11] Added explicit keyboard shortcuts to missing options in KControl/Konsole. --- kcontrol/konsole/kcmkonsoledialog.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kcontrol/konsole/kcmkonsoledialog.ui b/kcontrol/konsole/kcmkonsoledialog.ui index ec01401cf..7b5894158 100644 --- a/kcontrol/konsole/kcmkonsoledialog.ui +++ b/kcontrol/konsole/kcmkonsoledialog.ui @@ -131,7 +131,7 @@ xonXoffCB - Use Ctrl+S/Ctrl+Q flow control + &Use Ctrl+S/Ctrl+Q flow control @@ -156,7 +156,7 @@ bidiCB - Enable bidirectional text rendering + E&nable bidirectional text rendering @@ -164,7 +164,7 @@ matchTabWinTitleCB - Set tab title to match window title + Set &tab title to match window title @@ -172,7 +172,7 @@ tabsCycleWheelCB - Cycle tabs with mouse wheel + Cycle tabs &with mouse wheel @@ -180,7 +180,7 @@ menuAcceleratorsCB - Enable main menu accelerator keys + Enable main &menu accelerator keys @@ -188,7 +188,7 @@ metaAsAltModeCB - Handle Meta key as Alt Key + Handle Meta &key as Alt Key From cb7702286517c5483b2a4340538c0747030945b9 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 22 Apr 2014 15:22:23 +0900 Subject: [PATCH 07/11] Fixed support for handling Meta key as Alt key in terminal emulation. This resolves bug 1026. --- konsole/konsole/TEmuVt102.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp index ebe090fda..8eeb25d54 100644 --- a/konsole/konsole/TEmuVt102.cpp +++ b/konsole/konsole/TEmuVt102.cpp @@ -948,19 +948,17 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) encodeStat(TQt::AltButton , BITS_Alt ); if (metaKeyMode) bits += encodeStat(TQt::MetaButton , BITS_Alt); - bool transRes = keytrans->findEntry(ev->key(), bits, &cmd, &txt, &len, &metaspecified); -//if (transRes) -// printf("cmd: %d, %s, %d\n",cmd,txt,len); + keytrans->findEntry(ev->key(), bits, &cmd, &txt, &len, &metaspecified); if (connected) { - switch(cmd) // ... and execute if found. - { - case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; - case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; - case CMD_scrollLineUp : gui->doScroll(-1 ); return; - case CMD_scrollLineDown : gui->doScroll(+1 ); return; - case CMD_scrollLock : onScrollLock( ); return; - } + switch(cmd) // ... and execute if found. + { + case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; + case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; + case CMD_scrollLineUp : gui->doScroll(-1 ); return; + case CMD_scrollLineDown : gui->doScroll(+1 ); return; + case CMD_scrollLock : onScrollLock( ); return; + } } if (holdScreen) { @@ -990,7 +988,8 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) // fall back handling if (!ev->text().isEmpty()) { - if (ev->state() & TQt::AltButton) sendString("\033"); // ESC, this is the ALT prefix + if ((ev->state() & TQt::AltButton) || (metaKeyMode && (ev->state() & TQt::MetaButton))) + sendString("\033"); // ESC, this is the ALT prefix TQCString s = m_codec->fromUnicode(ev->text()); // encode for application // FIXME: In Qt 2, TQKeyEvent::text() would return "\003" for Ctrl-C etc. // while in Qt 3 it returns the actual key ("c" or "C") which caused From 4c12a981b01c2c40346b1ebf35ec82ff944b35e4 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 22 Apr 2014 16:38:41 +0900 Subject: [PATCH 08/11] Updated documentation for Konsole -> Settings -> General page. Several options were missing. This also relates to bugs 909, 1026 and 1701. --- doc/kcontrol/kcmkonsole/index.docbook | 93 +++++++++++++++++++++++---- kcontrol/konsole/kcmkonsoledialog.ui | 34 +++++----- 2 files changed, 98 insertions(+), 29 deletions(-) diff --git a/doc/kcontrol/kcmkonsole/index.docbook b/doc/kcontrol/kcmkonsole/index.docbook index 4d730e59c..a09384ea3 100644 --- a/doc/kcontrol/kcmkonsole/index.docbook +++ b/doc/kcontrol/kcmkonsole/index.docbook @@ -44,16 +44,6 @@ Daemon. functions. It contains the following options: - -Use Konsole as default terminal -application - -If you wish to have &tde; use another terminal application by -default, uncheck this box and enter the preferred application -(wterm, rxvt, -&etc;) in the text field below. - - Show Terminal Size when Resizing @@ -72,9 +62,9 @@ behavior. -Confirm quit with open sessions +Confirm quit when closing more than one session -When set, a warning appears when you try to close a &konsole; +When set, a warning appears when you try to close a &konsole; window with multiple sessions. @@ -86,12 +76,91 @@ window with multiple sessions. attention. + +Require Ctrl key for drag and drop +If unchecked, you can drag and drop selected text by using the mouse. +If checked, the Ctrl key needs to be held down to allow drag and drop (this is +a good way to avoid erroneous drag and drop operations). + + + + +Triple click selects only from the current word forward +If checked, a mouse triple click will select everything from the +current cursor position to the end of the lime. If unchecked, a mouse triple click will select +the entire current row. + + + + +Allow programs to resize terminal window +If checked, programs can resize the terminal window. + + + + +Use Ctrl+S/Ctrl+Q flow control +If checked, Ctrl+S/Ctrl+Q can be used to control the flow of output +characters sent to the terminal. After pressing CTRL-S, the system will not send any +more data to the screen until a CTRL-Q is pressed. + + + + +Enable bidirectional text rendering +If checked, text can be rendered from left to right or from right to left. +This is useful to support languages which are written in the second way. + + + + +Set tab title to match window title +If checked, the title of the tab representing the current session will match +the text displayed on the window title bar. Whenever the window title changes, the tab +tile changes as well. + + + + +Cycle tabs with mouse wheel +If checked, you can move through the different session tabs +using the mouse wheel over the tabbar control. If unchecked, the action is disabled. + + + + +Enable main menu accelerator keys +If checked, the main menu shortcut keys are enabled, otherwise +they are disabled. + +If menu accelerators are enabled, some Alt-key combinations may not +be handled correctly any longer in Konsole applications. + + + + +Handle Meta key as Alt Key +If checked, the Meta key will be handled as if it was an Alt key. + +This is a useful option if you have enabled the main menu shortcut keys. +You can use the Meta key to activate those Alt-key combinations that otherwise +would not work any longer in Konsole. + + + Line Spacing Change the space between lines of text. + +Seconds to detect silence +Allows to specify the time interval used for monitoring the +Konsole for silence, + + + Consider the following characters part of a word when double clicking diff --git a/kcontrol/konsole/kcmkonsoledialog.ui b/kcontrol/konsole/kcmkonsoledialog.ui index 7b5894158..5034b42c4 100644 --- a/kcontrol/konsole/kcmkonsoledialog.ui +++ b/kcontrol/konsole/kcmkonsoledialog.ui @@ -134,23 +134,6 @@ &Use Ctrl+S/Ctrl+Q flow control - - - Spacer3 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - bidiCB @@ -210,6 +193,23 @@ line_spacingSB + + + Spacer3 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + line_spacingSB From 335d526a0044373592b307d91f52c9f1c2d42980 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 22 Apr 2014 18:54:29 +0900 Subject: [PATCH 09/11] Fixed typo in docbook. --- doc/kcontrol/kcmkonsole/index.docbook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/kcontrol/kcmkonsole/index.docbook b/doc/kcontrol/kcmkonsole/index.docbook index a09384ea3..24208ded2 100644 --- a/doc/kcontrol/kcmkonsole/index.docbook +++ b/doc/kcontrol/kcmkonsole/index.docbook @@ -157,7 +157,7 @@ would not work any longer in Konsole. Seconds to detect silence Allows to specify the time interval used for monitoring the -Konsole for silence, +Konsole for silence. From 83708272fbd48b9a65342cc66af5c0a3837d7a13 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 14 May 2014 22:06:08 +0900 Subject: [PATCH 10/11] Workaround Qt/Tde/X? bug for handling Meta key as Alt key in terminal emulation after restored sessions. This resolves bug 1026 for good. --- konsole/konsole/TEWidget.cpp | 16 +++++------ konsole/konsole/TEWidget.h | 1 + konsole/konsole/TEmuVt102.cpp | 12 ++++---- konsole/konsole/TEmuVt102.h | 3 +- konsole/konsole/TEmulation.cpp | 50 +++++++++++++++++++++++++++++++++- konsole/konsole/TEmulation.h | 8 +++++- konsole/konsole/konsole.cpp | 15 ++++++++-- 7 files changed, 86 insertions(+), 19 deletions(-) diff --git a/konsole/konsole/TEWidget.cpp b/konsole/konsole/TEWidget.cpp index 75545a1e0..71db16143 100644 --- a/konsole/konsole/TEWidget.cpp +++ b/konsole/konsole/TEWidget.cpp @@ -1901,7 +1901,7 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) return false; // not us if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent* ke = (TQKeyEvent*)e; + TQKeyEvent *ke = TQT_TQKEYEVENT(e); actSel=0; // Key stroke implies a screen update, so TEWidget won't // know where the current selection is. @@ -1915,14 +1915,12 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) } emit keyPressedSignal(ke); // expose - - // in Qt2 when key events were propagated up the tree - // (unhandled? -> parent widget) they passed the event filter only once at - // the beginning. in qt3 this has changed, that is, the event filter is - // called each time the event is sent (see loop in TQApplication::notify, - // when internalNotify() is called for KeyPress, whereas internalNotify - // activates also the global event filter) . That's why we stop propagation - // here. + return true; + } + if ( e->type() == TQEvent::KeyRelease ) + { + TQKeyEvent* ke = (TQKeyEvent*)e; + emit keyReleasedSignal(ke); // expose return true; } if ( e->type() == TQEvent::Enter ) diff --git a/konsole/konsole/TEWidget.h b/konsole/konsole/TEWidget.h index 1e2c36d87..767190e57 100644 --- a/konsole/konsole/TEWidget.h +++ b/konsole/konsole/TEWidget.h @@ -153,6 +153,7 @@ public slots: signals: void keyPressedSignal(TQKeyEvent *e); + void keyReleasedSignal(TQKeyEvent *e); void mouseSignal(int cb, int cx, int cy); void changedFontMetricSignal(int height, int width); void changedContentSizeSignal(int height, int width); diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp index 8eeb25d54..e0efab745 100644 --- a/konsole/konsole/TEmuVt102.cpp +++ b/konsole/konsole/TEmuVt102.cpp @@ -927,12 +927,12 @@ void TEmuVt102::onScrollLock() the complications towards a configuration file [see KeyTrans class]. */ -void TEmuVt102::onKeyPress( TQKeyEvent* ev ) +void TEmuVt102::doKeyPress( TQKeyEvent* ev ) { - if (!listenToKeyPress) return; // someone else gets the keys emit notifySessionState(NOTIFYNORMAL); -//printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); + //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n", ev->state(),ev->key(), + // ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); // lookup in keyboard translation table ... int cmd = CMD_none; @@ -979,7 +979,8 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) if (cmd==CMD_send) { - if (((ev->state() & TQt::AltButton) || (metaKeyMode && (ev->state() & TQt::MetaButton))) && !metaspecified) + if ((ev->state() & TQt::AltButton) || + (metaKeyMode && ((ev->state() & TQt::MetaButton) || metaIsPressed) && !metaspecified)) sendString("\033"); emit sndBlock(txt,len); return; @@ -988,7 +989,8 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) // fall back handling if (!ev->text().isEmpty()) { - if ((ev->state() & TQt::AltButton) || (metaKeyMode && (ev->state() & TQt::MetaButton))) + if ((ev->state() & TQt::AltButton) || + (metaKeyMode && ((ev->state() & TQt::MetaButton) || metaIsPressed))) sendString("\033"); // ESC, this is the ALT prefix TQCString s = m_codec->fromUnicode(ev->text()); // encode for application // FIXME: In Qt 2, TQKeyEvent::text() would return "\003" for Ctrl-C etc. diff --git a/konsole/konsole/TEmuVt102.h b/konsole/konsole/TEmuVt102.h index 05f30ac04..8832a73d8 100644 --- a/konsole/konsole/TEmuVt102.h +++ b/konsole/konsole/TEmuVt102.h @@ -60,7 +60,8 @@ public: void changeGUI(TEWidget* newgui); ~TEmuVt102(); - virtual void onKeyPress(TQKeyEvent*); + virtual void doKeyPress(TQKeyEvent*); + public slots: // signals incoming from TEWidget void onMouse(int cb, int cx, int cy); diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp index 3aa1cfad4..d7cd13780 100644 --- a/konsole/konsole/TEmulation.cpp +++ b/konsole/konsole/TEmulation.cpp @@ -99,6 +99,7 @@ TEmulation::TEmulation(TEWidget* w) connected(false), listenToKeyPress(false), metaKeyMode(false), + metaIsPressed(false), m_codec(0), decoder(0), keytrans(0), @@ -124,6 +125,8 @@ void TEmulation::connectGUI() this,TQT_SLOT(onHistoryCursorChange(int))); TQObject::connect(gui,TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyPress(TQKeyEvent*))); + TQObject::connect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); TQObject::connect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::connect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -152,6 +155,8 @@ void TEmulation::changeGUI(TEWidget* newgui) this,TQT_SLOT(onHistoryCursorChange(int))); TQObject::disconnect(gui,TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyPress(TQKeyEvent*))); + TQObject::disconnect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); TQObject::disconnect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::disconnect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -276,11 +281,30 @@ void TEmulation::onRcvChar(int c) /*! */ - void TEmulation::onKeyPress( TQKeyEvent* ev ) { if (!listenToKeyPress) return; // someone else gets the keys + + // HACK - workaround for what looks like a bug in Qt. + // Specifically keep track of when the meta button is pressed or released. + // Upon restarting TDE, restored windows do not received the correct KeyEvent state + // when multiple keys are pressed: the MetaButton is missing. + // Instead on new created window, MetaButton information is correct. + // Ex: + // Meta is pressed --> the state is correct, both before and after + // State: Before=0x0000/After=0x0800 Key: 0x1022 + // Then h is presed --> the state does not contain the MetaButton anymore + // State: Before=0x0000/After=0x0000 Key: 0x0048 + if (ev->key() == TQt::Key_Meta) + metaIsPressed = true; + + doKeyPress(ev); +} + +void TEmulation::doKeyPress( TQKeyEvent* ev ) +{ emit notifySessionState(NOTIFYNORMAL); + if (scr->getHistCursor() != scr->getHistLines() && !ev->text().isEmpty()) scr->setHistCursor(scr->getHistLines()); if (!ev->text().isEmpty()) @@ -297,6 +321,30 @@ void TEmulation::onKeyPress( TQKeyEvent* ev ) } } +void TEmulation::onKeyReleased( TQKeyEvent* ev ) +{ + if (!listenToKeyPress) return; // someone else gets the keys + + // HACK - workaround for what looks like a bug in Qt. + // Specifically keep track of when the meta button is pressed or released. + // Upon restarting TDE, restored windows do not received the correct KeyEvent state + // when multiple keys are pressed: the MetaButton is missing. + // Instead on new created window, MetaButton information is correct. + // Ex: + // Meta is pressed --> the state is correct, both before and after + // State: Before=0x0000/After=0x0800 Key: 0x1022 + // Then h is presed --> the state does not contain the MetaButton anymore + // State: Before=0x0000/After=0x0000 Key: 0x0048 + if (ev->key() == TQt::Key_Meta || !(ev->stateAfter() & TQt::MetaButton)) + metaIsPressed = false; + + doKeyReleased(ev); +} + +void TEmulation::doKeyReleased( TQKeyEvent* ke ) +{ +} + // Unblocking, Byte to Unicode translation --------------------------------- -- /* diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h index 6eac5f91b..b50afc608 100644 --- a/konsole/konsole/TEmulation.h +++ b/konsole/konsole/TEmulation.h @@ -55,7 +55,12 @@ public slots: // signals incoming from TEWidget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); - virtual void onKeyPress(TQKeyEvent*); + + // HACK + void onKeyPress(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyPress(TQKeyEvent*); // Instead this function should be overwritten if necessary + void onKeyReleased(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyReleased(TQKeyEvent*); // Instead this function should be overwritten if necessary virtual void clearSelection(); virtual void copySelection(); @@ -121,6 +126,7 @@ protected: bool connected; // communicate with widget bool listenToKeyPress; // listen to input bool metaKeyMode; // true -> meta key is handled as Alt + bool metaIsPressed; // true -> the meta key has been pressed down - HACK void setCodec(int c); // codec number, 0 = locale, 1=utf8 diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index f59ae83da..646edd96b 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -2376,8 +2376,12 @@ void Konsole::disableMasterModeConnections() for (; to_it.current(); ++to_it) { TESession *to = to_it.current(); if (to!=from) + { disconnect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); + disconnect(from->widget(),TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(),TQT_SLOT(onKeyReleased(TQKeyEvent*))); + } } } } @@ -2392,9 +2396,12 @@ void Konsole::enableMasterModeConnections() TQPtrListIterator to_it(sessions); for (; to_it.current(); ++to_it) { TESession *to = to_it.current(); - if (to!=from) { + if (to!=from) + { connect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); + connect(from->widget(),TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(),TQT_SLOT(onKeyReleased(TQKeyEvent*))); } } } @@ -3736,8 +3743,12 @@ void Konsole::detachSession(TESession* _se) { for(; from_it.current(); ++from_it) { TESession *from = from_it.current(); if(from->isMasterMode()) + { disconnect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - _se->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + _se->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + _se->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + } } } From efdf0bbcd37d5aaa05649437b286aeecfd38c617 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 16 May 2014 18:32:17 +0900 Subject: [PATCH 11/11] Improved code for workaround for Qt/Tde/X? bug for handling Meta key as Alt key in terminal emulation after restored sessions. This relates to bug 1026. --- konsole/konsole/TEWidget.cpp | 15 ++++++++++++--- konsole/konsole/TEWidget.h | 1 + konsole/konsole/TEmulation.cpp | 18 ++++++++++++++++++ konsole/konsole/TEmulation.h | 13 ++++++++----- konsole/konsole/konsole.cpp | 22 ++++++++++++++-------- 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/konsole/konsole/TEWidget.cpp b/konsole/konsole/TEWidget.cpp index 71db16143..f16d97aac 100644 --- a/konsole/konsole/TEWidget.cpp +++ b/konsole/konsole/TEWidget.cpp @@ -1914,15 +1914,24 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) cursorBlinking = false; } - emit keyPressedSignal(ke); // expose + emit keyPressedSignal(ke); return true; } if ( e->type() == TQEvent::KeyRelease ) { - TQKeyEvent* ke = (TQKeyEvent*)e; - emit keyReleasedSignal(ke); // expose + TQKeyEvent *ke = TQT_TQKEYEVENT(e); + emit keyReleasedSignal(ke); return true; } + if ( e->type() == TQEvent::FocusIn ) + { + TQFocusEvent *fe = TQT_TQFOCUSEVENT(e); + if (fe->gotFocus()) + { + emit focusInSignal(fe); + return true; + } + } if ( e->type() == TQEvent::Enter ) { TQObject::disconnect( (TQObject*)cb, TQT_SIGNAL(dataChanged()), diff --git a/konsole/konsole/TEWidget.h b/konsole/konsole/TEWidget.h index 767190e57..2baa2531c 100644 --- a/konsole/konsole/TEWidget.h +++ b/konsole/konsole/TEWidget.h @@ -154,6 +154,7 @@ signals: void keyPressedSignal(TQKeyEvent *e); void keyReleasedSignal(TQKeyEvent *e); + void focusInSignal(TQFocusEvent *e); void mouseSignal(int cb, int cx, int cy); void changedFontMetricSignal(int height, int width); void changedContentSizeSignal(int height, int width); diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp index d7cd13780..7576e9688 100644 --- a/konsole/konsole/TEmulation.cpp +++ b/konsole/konsole/TEmulation.cpp @@ -127,6 +127,8 @@ void TEmulation::connectGUI() this,TQT_SLOT(onKeyPress(TQKeyEvent*))); TQObject::connect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); + TQObject::connect(gui,TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + this,TQT_SLOT(onFocusIn(TQFocusEvent*))); TQObject::connect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::connect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -157,6 +159,8 @@ void TEmulation::changeGUI(TEWidget* newgui) this,TQT_SLOT(onKeyPress(TQKeyEvent*))); TQObject::disconnect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); + TQObject::disconnect(gui,TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + this,TQT_SLOT(onFocusIn(TQFocusEvent*))); TQObject::disconnect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::disconnect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -345,6 +349,20 @@ void TEmulation::doKeyReleased( TQKeyEvent* ke ) { } +void TEmulation::onFocusIn( TQFocusEvent* fe ) +{ + // HACK - workaround for what looks like a bug in Qt. + // Always reset the status of 'metaIsPressed' when the emulation gets the focus, + // to avoid pending cases. A pending case is a case where the emulation lost the + // focus while Meta was pressed but gets the focus when Meta is no longer pressed. + metaIsPressed = false; + doFocusIn(fe); +} + +void TEmulation::doFocusIn( TQFocusEvent* fe ) +{ +} + // Unblocking, Byte to Unicode translation --------------------------------- -- /* diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h index b50afc608..9ddc2a4c7 100644 --- a/konsole/konsole/TEmulation.h +++ b/konsole/konsole/TEmulation.h @@ -56,11 +56,14 @@ public slots: // signals incoming from TEWidget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); - // HACK - void onKeyPress(TQKeyEvent*); // This should not be overwritten by derived classes - virtual void doKeyPress(TQKeyEvent*); // Instead this function should be overwritten if necessary - void onKeyReleased(TQKeyEvent*); // This should not be overwritten by derived classes - virtual void doKeyReleased(TQKeyEvent*); // Instead this function should be overwritten if necessary + // HACK - start + void onKeyPress(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyPress(TQKeyEvent*); // Instead this function should be overwritten if necessary + void onKeyReleased(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyReleased(TQKeyEvent*); // Instead this function should be overwritten if necessary + void onFocusIn(TQFocusEvent*); // This should not be overwritten by derived classes + virtual void doFocusIn(TQFocusEvent*); // Instead this function should be overwritten if necessary + // HACK - end virtual void clearSelection(); virtual void copySelection(); diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index 646edd96b..569110b08 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -2377,10 +2377,12 @@ void Konsole::disableMasterModeConnections() TESession *to = to_it.current(); if (to!=from) { - disconnect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); - disconnect(from->widget(),TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyReleased(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + to->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); } } } @@ -2398,10 +2400,12 @@ void Konsole::enableMasterModeConnections() TESession *to = to_it.current(); if (to!=from) { - connect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); - connect(from->widget(),TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyReleased(TQKeyEvent*))); + connect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + connect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + connect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + to->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); } } } @@ -3748,6 +3752,8 @@ void Konsole::detachSession(TESession* _se) { _se->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); disconnect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), _se->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + _se->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); } } }