Git commit 143f3254fcebb649438841205c9a2dec60bb3ef8 by Patrick Spendrin. Committed on 30/06/2014 at 20:43. Pushed by sengels into branch 'master'. add an event for isActive This event is triggered if the terminal is fully functional and input can be safely send to the terminal. M +22 -2 terminal.cpp M +4 -0 terminal.h http://commits.kde.org/kcwsh/143f3254fcebb649438841205c9a2dec60bb3ef8 diff --git a/terminal.cpp b/terminal.cpp index b8a114f..1ec52a4 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -145,6 +145,10 @@ void Terminal::titleChanged() { // KcwDebug() << __FUNCTION__; } = +void Terminal::activityChanged() { +// KcwDebug() << __FUNCTION__; +} + void Terminal::hasScrolled() { // KcwDebug() << __FUNCTION__; } @@ -206,6 +210,7 @@ void Terminal::setActive(bool t) { SuspendThread(m_inputWriter); SuspendThread(m_outputReader); } + m_activityChanged.notify(); } = bool Terminal::active() const { @@ -232,6 +237,10 @@ void Terminal::setEnvironment(KcwProcess::KcwProcessEn= vironment env) { m_process.setStartupEnvironment(env); } = +HANDLE Terminal::activityHandle() { + return m_activityChanged; +} + DWORD Terminal::run() { if(m_inputReader =3D=3D NULL || m_outputWriter =3D=3D NULL) { KcwDebug() << "no inputreader or outputwriter set!"; @@ -247,8 +256,6 @@ DWORD Terminal::run() { m_process.start(); addCallback(m_process.process(), CB(hasQuit)); = - m_active =3D true; - m_inputReader->setProcess(&m_process); m_inputReader->init(); m_inputReader->start(); @@ -269,6 +276,14 @@ DWORD Terminal::run() { }; = wss.str(L""); + wss << "kcwsh-activity-" << m_process.pid(); + if(m_activityChanged.open(wss.str().c_str()) !=3D 0) { + KcwDebug() << "could not create activityEvent!"; + return -1; + }; + addCallback(m_activityChanged, CB(activityChanged)); + + wss.str(L""); wss << "kcwsh-titleChanged-" << m_process.pid(); if(m_titleChanged.open(wss.str().c_str()) !=3D 0) { KcwDebug() << "could not create titleChanged!"; @@ -318,5 +333,10 @@ DWORD Terminal::run() { sizeChanged(); = m_process.resume(); + + m_active =3D true; + + m_activityChanged.notify(); + return KcwEventLoop::exec(); } diff --git a/terminal.h b/terminal.h index c596e91..8ce4700 100644 --- a/terminal.h +++ b/terminal.h @@ -78,6 +78,8 @@ class KCWSH_EXPORT Terminal : public KcwThread { = virtual KCW_CALLBACK(Terminal, titleChanged); = + virtual KCW_CALLBACK(Terminal, activityChanged); + void setActive(bool t); bool active() const; = @@ -101,6 +103,7 @@ class KCWSH_EXPORT Terminal : public KcwThread { = void setEnvironment(KcwProcess::KcwProcessEnvironment env); = + HANDLE activityHandle(); protected: Terminal(InputReader* ir, OutputWriter* ow); = @@ -122,6 +125,7 @@ class KCWSH_EXPORT Terminal : public KcwThread { KcwNotifier m_exitEvent; KcwNotifier m_setupEvent; KcwNotifier m_titleChanged; + KcwNotifier m_activityChanged; }; }; #endif /* kcwsh_terminal */