@ -114,7 +114,7 @@ SessionController::SessionController(Session *sessionParam, TerminalDisplay *vie
, _findAction ( nullptr )
, _findAction ( nullptr )
, _findNextAction ( nullptr )
, _findNextAction ( nullptr )
, _findPreviousAction ( nullptr )
, _findPreviousAction ( nullptr )
, _snapshot Timer ( nullptr )
, _interaction Timer ( nullptr )
, _searchStartLine ( 0 )
, _searchStartLine ( 0 )
, _prevSearchResultLine ( 0 )
, _prevSearchResultLine ( 0 )
, _codecAction ( nullptr )
, _codecAction ( nullptr )
@ -209,18 +209,22 @@ SessionController::SessionController(Session *sessionParam, TerminalDisplay *vie
connect ( session ( ) , & Konsole : : Session : : flowControlEnabledChanged , view ( ) , & Konsole : : TerminalDisplay : : setFlowControlWarningEnabled ) ;
connect ( session ( ) , & Konsole : : Session : : flowControlEnabledChanged , view ( ) , & Konsole : : TerminalDisplay : : setFlowControlWarningEnabled ) ;
view ( ) - > setFlowControlWarningEnabled ( session ( ) - > flowControlEnabled ( ) ) ;
view ( ) - > setFlowControlWarningEnabled ( session ( ) - > flowControlEnabled ( ) ) ;
// take a snapshot of the session state shortly after any event occurs
// take a snapshot of the session state every so often when
// user activity occurs
//
//
// Don't link the timer with the session or we will have an use after
// the timer is owned by the session so that it will be destroyed along
// free in SessionController::eventFilter
// with the session
_snapshotTimer = new QTimer ( nullptr ) ;
_interactionTimer = new QTimer ( session ( ) ) ;
_snapshotTimer - > setSingleShot ( true ) ;
_interactionTimer - > setSingleShot ( true ) ;
_snapshotTimer - > setInterval ( 500 ) ;
_interactionTimer - > setInterval ( 2000 ) ;
connect ( _snapshotTimer , & QTimer : : timeout , this , & Konsole : : SessionController : : snapshot ) ;
connect ( _interactionTimer , & QTimer : : timeout , this , & Konsole : : SessionController : : snapshot ) ;
// Install an event handler on QCoreApplication
connect ( view ( ) , & Konsole : : TerminalDisplay : : compositeFocusChanged , this , [ this ] ( bool focused ) {
// This will catch all events: key strokes, mouse moves/clicks...
if ( focused ) {
// but also all changes that occur in all tabs
interactionHandler ( ) ;
QCoreApplication : : instance ( ) - > installEventFilter ( this ) ;
}
} ) ;
connect ( view ( ) , & Konsole : : TerminalDisplay : : keyPressedSignal , this , & Konsole : : SessionController : : interactionHandler ) ;
connect ( session ( ) - > emulation ( ) , & Konsole : : Emulation : : outputChanged , this , & Konsole : : SessionController : : interactionHandler ) ;
// xterm '10;?' request
// xterm '10;?' request
connect ( session ( ) , & Konsole : : Session : : getForegroundColor , this , & Konsole : : SessionController : : sendForegroundColor ) ;
connect ( session ( ) , & Konsole : : Session : : getForegroundColor , this , & Konsole : : SessionController : : sendForegroundColor ) ;
@ -245,8 +249,6 @@ SessionController::SessionController(Session *sessionParam, TerminalDisplay *vie
SessionController : : ~ SessionController ( )
SessionController : : ~ SessionController ( )
{
{
QCoreApplication : : instance ( ) - > removeEventFilter ( this ) ;
delete _snapshotTimer ;
_allControllers . remove ( this ) ;
_allControllers . remove ( this ) ;
if ( factory ( ) ! = nullptr ) {
if ( factory ( ) ! = nullptr ) {
@ -309,6 +311,13 @@ void SessionController::viewFocusChangeHandler(bool focused)
}
}
}
}
void SessionController : : interactionHandler ( )
{
if ( ! _interactionTimer - > isActive ( ) ) {
_interactionTimer - > start ( ) ;
}
}
void SessionController : : snapshot ( )
void SessionController : : snapshot ( )
{
{
Q_ASSERT ( ! session ( ) . isNull ( ) ) ;
Q_ASSERT ( ! session ( ) . isNull ( ) ) ;
@ -1325,20 +1334,6 @@ void SessionController::searchClosed()
searchHistory ( false ) ;
searchHistory ( false ) ;
}
}
bool SessionController : : eventFilter ( QObject * obj , QEvent * event )
{
// Forward event to super class
bool ret = ViewProperties : : eventFilter ( obj , event ) ;
// Start the snapshot timer if:
// - it is not already started
// - the event is not a timer timeout
if ( ! _snapshotTimer - > isActive ( ) & & event - > type ( ) ! = QEvent : : Timer ) {
_snapshotTimer - > start ( ) ;
}
return ret ;
}
void SessionController : : updateFilterList ( const Profile : : Ptr & profile )
void SessionController : : updateFilterList ( const Profile : : Ptr & profile )
{
{
if ( profile ! = SessionManager : : instance ( ) - > sessionProfile ( session ( ) ) ) {
if ( profile ! = SessionManager : : instance ( ) - > sessionProfile ( session ( ) ) ) {