# HG changeset patch # User Tom Sutcliffe # Date 1282669008 -3600 # Node ID f8e05215af4a464b7d75dd8aee8b7977e8df71e4 # Parent 284c68d7a3acb4388312d3ba5e07ab93a593d421 Performance improvements to terminalkeyboardcons. diff -r 284c68d7a3ac -r f8e05215af4a plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp --- a/plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp Tue Aug 24 11:54:30 2010 +0100 +++ b/plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp Tue Aug 24 17:56:48 2010 +0100 @@ -62,6 +62,7 @@ CTerminalKeyboardCons::~CTerminalKeyboardCons() { + delete iIdleUpdateTimer; CleanupUnderlyingConsole(); delete iWatcher; iDriver.Close(); @@ -90,6 +91,8 @@ iMungedTextBuffer.CreateL((ScreenSize().iWidth + 2) * (ScreenSize().iHeight + 2)); #endif + iIdleUpdateTimer = CPeriodic::NewL(CActive::EPriorityLow); // Lower priority than the message watcher + TInt err = User::LoadLogicalDevice(KTcLddDriverName); if (err && err != KErrAlreadyExists) { @@ -311,6 +314,25 @@ void CTerminalKeyboardCons::Update() { + // Delay updates to the screen, to improve performance + static const TInt KDelay = 100000; // 0.1s + if (!iIdleUpdateTimer->IsActive()) + { + // Don't reset timer if we're already running - otherwise constant typing will never show up until you stop pressing keys + iIdleUpdateTimer->Start(KDelay, KDelay, TCallBack(&UpdateCallback, this)); + } + } + +TInt CTerminalKeyboardCons::UpdateCallback(TAny* aSelf) + { + static_cast(aSelf)->DoUpdate(); + return 0; + } + +void CTerminalKeyboardCons::DoUpdate() + { + iIdleUpdateTimer->Cancel(); // Stop any further updates + #ifdef SHOW_TEXTSHELL_BORDERS // Update munged buffer const TInt contentWidth = ScreenSize().iWidth; diff -r 284c68d7a3ac -r f8e05215af4a plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.h --- a/plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.h Tue Aug 24 11:54:30 2010 +0100 +++ b/plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.h Tue Aug 24 17:56:48 2010 +0100 @@ -50,8 +50,10 @@ private: virtual void ConstructL(const TDesC& aTitle, const TSize& aSize); void Update(); + void DoUpdate(); void MessageReceived(TInt aError); void Transmit(const TDesC& aBuf, TInt aWidth, TInt aHeight); + static TInt UpdateCallback(TAny* aSelf); protected: TRequestStatus* iClientStatus; @@ -67,6 +69,7 @@ CMessageWatcher* iWatcher; friend class CMessageWatcher; TBool iBacktickModifierDown; + CPeriodic* iIdleUpdateTimer; }; #endif // TERMINALKEYBOARDCONS_H