Showing with 58 additions and 0 deletions.
  1. +1 −0 desktop/sessionui.rc
  2. +26 −0 src/Session.cpp
  3. +18 −0 src/Session.h
  4. +12 −0 src/SessionController.cpp
  5. +1 −0 src/SessionController.h
1 change: 1 addition & 0 deletions desktop/sessionui.rc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Menu name="view">
<Action name="monitor-silence" group="session-view-operations"/>
<Action name="monitor-activity" group="session-view-operations"/>
<Action name="monitor-trigger-on-change" group="session-view-operations"/>
<Separator group="session-view-operations"/>
<Action name="enlarge-font" group="session-view-operations"/>
<Action name="shrink-font" group="session-view-operations"/>
Expand Down
26 changes: 26 additions & 0 deletions src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Session::Session(QObject* parent) :
, _monitorSilence(false)
, _notifiedActivity(false)
, _silenceSeconds(10)
, _monitorTriggerOnChange(false)
, _monitorAlreadyChanged(false)
, _autoClose(true)
, _closePerUserRequest(false)
, _addToUtmp(true)
Expand Down Expand Up @@ -144,6 +146,8 @@ Session::Session(QObject* parent) :
this, SIGNAL(selectionChanged(QString)));
connect(_emulation, SIGNAL(imageResizeRequest(QSize)),
this, SIGNAL(resizeRequest(QSize)));
connect(_emulation, SIGNAL(sendData(const char*, int)),
this, SLOT(resetMonitorAlreadyChanged(const char*, int)));

//create new teletype for I/O with shell process
openTeletype(-1);
Expand Down Expand Up @@ -641,6 +645,10 @@ void Session::activityStateSet(int state)
// TODO: should this hardcoded interval be user configurable?
const int activityMaskInSeconds = 15;

if (_monitorTriggerOnChange && _monitorAlreadyChanged) {
return;
}

if (state == NOTIFYBELL) {
emit bellRequest(i18n("Bell in session '%1'", _nameTitle));
} else if (state == NOTIFYACTIVITY) {
Expand All @@ -665,6 +673,8 @@ void Session::activityStateSet(int state)
if (state == NOTIFYSILENCE && !_monitorSilence)
state = NOTIFYNORMAL;

_monitorAlreadyChanged = true;

emit stateChanged(state);
}

Expand Down Expand Up @@ -1123,6 +1133,22 @@ void Session::setMonitorSilenceSeconds(int seconds)
}
}

void Session::setMonitorTriggerOnChange(bool onChange)
{
_monitorTriggerOnChange = onChange;
}

bool Session::isMonitorTriggerOnChange() const
{
return _monitorTriggerOnChange;
}

void Session::resetMonitorAlreadyChanged(const char* /* data */, int /* len */)
{
// Reset monitor activity trigger.
_monitorAlreadyChanged = false;
}

void Session::setAddToUtmp(bool add)
{
_addToUtmp = add;
Expand Down
18 changes: 18 additions & 0 deletions src/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,22 @@ public slots:
/** See setMonitorSilence() */
Q_SCRIPTABLE void setMonitorSilenceSeconds(int seconds);

/**
* Trigger monitor activity/silence on change only
* Usefull for tmux
*/
Q_SCRIPTABLE void setMonitorTriggerOnChange(bool);

/**
* Return true if monitor must trigger only on change
*/
Q_SCRIPTABLE bool isMonitorTriggerOnChange() const;

/**
* Reset _monitorAlreadyChanged state to false.
*/
Q_SCRIPTABLE void resetMonitorAlreadyChanged(const char* data, int len);

/**
* Sets whether flow control is enabled for this terminal
* session.
Expand Down Expand Up @@ -709,6 +725,8 @@ private slots:
int _silenceSeconds;
QTimer* _silenceTimer;
QTimer* _activityTimer;
bool _monitorTriggerOnChange;
bool _monitorAlreadyChanged;

bool _masterMode;
bool _autoClose;
Expand Down
12 changes: 12 additions & 0 deletions src/SessionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ void SessionController::setupExtraActions()
action = collection->addAction("monitor-silence", toggleAction);
connect(action, SIGNAL(toggled(bool)), this, SLOT(monitorSilence(bool)));

toggleAction = new KToggleAction(i18n("Monitor trigger on &Change"), this);
action = collection->addAction("monitor-trigger-on-change", toggleAction);
connect(action, SIGNAL(toggled(bool)), this, SLOT(monitorTriggerOnChange(bool)));

// Character Encoding
_codecAction = new KCodecAction(i18n("Set &Encoding"), this);
_codecAction->setIcon(KIcon("character-set"));
Expand Down Expand Up @@ -1339,10 +1343,17 @@ void SessionController::monitorActivity(bool monitor)
{
_session->setMonitorActivity(monitor);
}

void SessionController::monitorSilence(bool monitor)
{
_session->setMonitorSilence(monitor);
}

void SessionController::monitorTriggerOnChange(bool onChange)
{
_session->setMonitorTriggerOnChange(onChange);
}

void SessionController::updateSessionIcon()
{
// Visualize that the session is broadcasting to others
Expand All @@ -1356,6 +1367,7 @@ void SessionController::updateSessionIcon()
}
}
}

void SessionController::sessionTitleChanged()
{
if (_sessionIconName != _session->iconName()) {
Expand Down
1 change: 1 addition & 0 deletions src/SessionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ private slots:
void clearHistoryAndReset();
void monitorActivity(bool monitor);
void monitorSilence(bool monitor);
void monitorTriggerOnChange(bool onChange);
void renameSession();
void switchProfile(Profile::Ptr profile);
void handleWebShortcutAction();
Expand Down