diff -r ea65f74e6de4 -r 8e5f6eea9c9f tvout/tvoutengine/src/glxwindowvisibilitymonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tvout/tvoutengine/src/glxwindowvisibilitymonitor.cpp Tue Aug 31 15:14:51 2010 +0300 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that monitors tv window visibility +* +*/ + + + +// CLASS HEADER +#include "glxwindowvisibilitymonitor.h" + +// EXTERNAL INCLUDES +#include // for TWsEvent +#include // for KAknFullOrPartialForegroundLost +#include // for EventMonitor +#include + +// INTERNAL INCLUDES +#include +#include +#include "glxtv.h" // for MGlxWindowVisibilityObserver + + + +//----------------------------------------------------------------------------- +// Return new object +//----------------------------------------------------------------------------- +// +CGlxWindowVisibilityMonitor* CGlxWindowVisibilityMonitor::NewL( + MGlxWindowVisibilityObserver& aVisibilityObserver ) + { + GLX_LOG_INFO("CGlxWindowVisibilityMonitor::NewL"); + CGlxWindowVisibilityMonitor* self = new ( ELeave ) + CGlxWindowVisibilityMonitor( aVisibilityObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +//----------------------------------------------------------------------------- +// Destructor +//----------------------------------------------------------------------------- +// +CGlxWindowVisibilityMonitor::~CGlxWindowVisibilityMonitor() + { + GLX_LOG_INFO("~CGlxWindowVisibilityMonitor"); + } + + +//----------------------------------------------------------------------------- +// Close +// To overcome code-scanner high rated warning +//----------------------------------------------------------------------------- +// +void CGlxWindowVisibilityMonitor::Close() + { + iAknEventMonitor->Enable( EFalse ); + iAknEventMonitor->RemoveObserver( this ); + } + +//----------------------------------------------------------------------------- +// Default C++ constructor +//----------------------------------------------------------------------------- +// +CGlxWindowVisibilityMonitor::CGlxWindowVisibilityMonitor + ( MGlxWindowVisibilityObserver& aVisibilityObserver ) + :iVisibilityObserver ( aVisibilityObserver ) + { + GLX_LOG_INFO("CGlxWindowVisibilityMonitor"); + } + + +//----------------------------------------------------------------------------- +// Symbian second phase constructor +//----------------------------------------------------------------------------- +// +void CGlxWindowVisibilityMonitor::ConstructL() + { + GLX_LOG_INFO("CGlxWindowVisibilityMonitor::ConstructL"); + // Register for visibility events + iAknEventMonitor = + static_cast(CCoeEnv::Static()->AppUi())->EventMonitor(); + iAknEventMonitor->Enable( ETrue ); + iAknEventMonitor->AddObserverL( this ); + } + + +//----------------------------------------------------------------------------- +// From class MAknWsEventObserver +// Propagates window server visibility events to the observer +//----------------------------------------------------------------------------- +// +void CGlxWindowVisibilityMonitor::HandleWsEventL( const TWsEvent& aEvent, + CCoeControl* /*aDestination*/ ) + { + GLX_LOG_INFO("CGlxWindowVisibilityMonitor::HandleWsEventL"); + TInt eventType = aEvent.Type(); + + if ( eventType == EEventWindowVisibilityChanged ) + { + // check the state + TUint visible = aEvent.VisibilityChanged()->iFlags; + // notify the observer + if ( visible & TWsVisibilityChangedEvent::EFullyVisible ) + { + GLX_LOG_INFO("Visibility Event - EFullyVisible"); + iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayIsVisible ); + } + else if ( visible & TWsVisibilityChangedEvent::ENotVisible ) + { + GLX_LOG_INFO("Visibility Event - ENotVisible"); + iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayNotVisible ); + } + else if (visible & TWsVisibilityChangedEvent::EPartiallyVisible) + { + GLX_LOG_INFO("Visibility Event - EPartiallyVisible"); + iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayNotVisible ); + } + } + } + + + + +