plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp
changeset 35 f8e05215af4a
parent 33 cfabd0207208
child 47 1c9b53dbf08b
equal deleted inserted replaced
34:284c68d7a3ac 35:f8e05215af4a
    60 	{
    60 	{
    61 	}
    61 	}
    62 
    62 
    63 CTerminalKeyboardCons::~CTerminalKeyboardCons()
    63 CTerminalKeyboardCons::~CTerminalKeyboardCons()
    64 	{
    64 	{
       
    65 	delete iIdleUpdateTimer;
    65 	CleanupUnderlyingConsole();
    66 	CleanupUnderlyingConsole();
    66 	delete iWatcher;
    67 	delete iWatcher;
    67 	iDriver.Close();
    68 	iDriver.Close();
    68 	iTextBuffer.Close();
    69 	iTextBuffer.Close();
    69 	iMungedTextBuffer.Close();
    70 	iMungedTextBuffer.Close();
    87 
    88 
    88 	iTextBuffer.CreateMaxL(ScreenSize().iWidth * ScreenSize().iHeight);
    89 	iTextBuffer.CreateMaxL(ScreenSize().iWidth * ScreenSize().iHeight);
    89 #ifdef SHOW_TEXTSHELL_BORDERS
    90 #ifdef SHOW_TEXTSHELL_BORDERS
    90 	iMungedTextBuffer.CreateL((ScreenSize().iWidth + 2) * (ScreenSize().iHeight + 2));
    91 	iMungedTextBuffer.CreateL((ScreenSize().iWidth + 2) * (ScreenSize().iHeight + 2));
    91 #endif
    92 #endif
       
    93 
       
    94 	iIdleUpdateTimer = CPeriodic::NewL(CActive::EPriorityLow); // Lower priority than the message watcher
    92 
    95 
    93 	TInt err = User::LoadLogicalDevice(KTcLddDriverName);
    96 	TInt err = User::LoadLogicalDevice(KTcLddDriverName);
    94 	if (err && err != KErrAlreadyExists)
    97 	if (err && err != KErrAlreadyExists)
    95 		{
    98 		{
    96 		Message(EError, _L("Couldn't load LDD %S: %d"), &KTcLddDriverName, err);
    99 		Message(EError, _L("Couldn't load LDD %S: %d"), &KTcLddDriverName, err);
   309 	EBoxBottomRight = 0xBC,
   312 	EBoxBottomRight = 0xBC,
   310 	};
   313 	};
   311 
   314 
   312 void CTerminalKeyboardCons::Update()
   315 void CTerminalKeyboardCons::Update()
   313 	{
   316 	{
       
   317 	// Delay updates to the screen, to improve performance
       
   318 	static const TInt KDelay = 100000; // 0.1s
       
   319 	if (!iIdleUpdateTimer->IsActive())
       
   320 		{
       
   321 		// Don't reset timer if we're already running - otherwise constant typing will never show up until you stop pressing keys
       
   322 		iIdleUpdateTimer->Start(KDelay, KDelay, TCallBack(&UpdateCallback, this));
       
   323 		}
       
   324 	}
       
   325 
       
   326 TInt CTerminalKeyboardCons::UpdateCallback(TAny* aSelf)
       
   327 	{
       
   328 	static_cast<CTerminalKeyboardCons*>(aSelf)->DoUpdate();
       
   329 	return 0;
       
   330 	}
       
   331 
       
   332 void CTerminalKeyboardCons::DoUpdate()
       
   333 	{
       
   334 	iIdleUpdateTimer->Cancel(); // Stop any further updates
       
   335 
   314 #ifdef SHOW_TEXTSHELL_BORDERS
   336 #ifdef SHOW_TEXTSHELL_BORDERS
   315 	// Update munged buffer
   337 	// Update munged buffer
   316 	const TInt contentWidth = ScreenSize().iWidth;
   338 	const TInt contentWidth = ScreenSize().iWidth;
   317 	const TInt width = contentWidth + 2;
   339 	const TInt width = contentWidth + 2;
   318 	iMungedTextBuffer.SetLength(width);
   340 	iMungedTextBuffer.SetLength(width);