|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class that monitors tv window visibility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 * @internal reviewed 24/08/2007 by D Holland |
|
22 */ |
|
23 |
|
24 // CLASS HEADER |
|
25 #include "glxwindowvisibilitymonitor.h" |
|
26 |
|
27 // EXTERNAL INCLUDES |
|
28 #include <w32std.h> // for TWsEvent |
|
29 #include <AknDef.h> // for KAknFullOrPartialForegroundLost |
|
30 #include <AknWsEventObserver.h> // for EventMonitor |
|
31 #include <aknappui.h> |
|
32 |
|
33 // INTERNAL INCLUDES |
|
34 #include <glxlog.h> |
|
35 #include <glxpanic.h> |
|
36 #include "glxtv.h" // for MGlxWindowVisibilityObserver |
|
37 |
|
38 |
|
39 |
|
40 //----------------------------------------------------------------------------- |
|
41 // Return new object |
|
42 //----------------------------------------------------------------------------- |
|
43 // |
|
44 CGlxWindowVisibilityMonitor* CGlxWindowVisibilityMonitor::NewL( |
|
45 MGlxWindowVisibilityObserver& aVisibilityObserver ) |
|
46 { |
|
47 GLX_LOG_INFO("CGlxWindowVisibilityMonitor::NewL"); |
|
48 CGlxWindowVisibilityMonitor* self = new ( ELeave ) |
|
49 CGlxWindowVisibilityMonitor( aVisibilityObserver ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 //----------------------------------------------------------------------------- |
|
58 // Destructor |
|
59 //----------------------------------------------------------------------------- |
|
60 // |
|
61 CGlxWindowVisibilityMonitor::~CGlxWindowVisibilityMonitor() |
|
62 { |
|
63 GLX_LOG_INFO("~CGlxWindowVisibilityMonitor"); |
|
64 } |
|
65 |
|
66 |
|
67 //----------------------------------------------------------------------------- |
|
68 // Close |
|
69 // To overcome code-scanner high rated warning |
|
70 //----------------------------------------------------------------------------- |
|
71 // |
|
72 void CGlxWindowVisibilityMonitor::Close() |
|
73 { |
|
74 iAknEventMonitor->Enable( EFalse ); |
|
75 iAknEventMonitor->RemoveObserver( this ); |
|
76 } |
|
77 |
|
78 //----------------------------------------------------------------------------- |
|
79 // Default C++ constructor |
|
80 //----------------------------------------------------------------------------- |
|
81 // |
|
82 CGlxWindowVisibilityMonitor::CGlxWindowVisibilityMonitor |
|
83 ( MGlxWindowVisibilityObserver& aVisibilityObserver ) |
|
84 :iVisibilityObserver ( aVisibilityObserver ) |
|
85 { |
|
86 GLX_LOG_INFO("CGlxWindowVisibilityMonitor"); |
|
87 } |
|
88 |
|
89 |
|
90 //----------------------------------------------------------------------------- |
|
91 // Symbian second phase constructor |
|
92 //----------------------------------------------------------------------------- |
|
93 // |
|
94 void CGlxWindowVisibilityMonitor::ConstructL() |
|
95 { |
|
96 GLX_LOG_INFO("CGlxWindowVisibilityMonitor::ConstructL"); |
|
97 // Register for visibility events |
|
98 iAknEventMonitor = |
|
99 static_cast<CAknAppUiBase*>(CCoeEnv::Static()->AppUi())->EventMonitor(); |
|
100 iAknEventMonitor->Enable( ETrue ); |
|
101 iAknEventMonitor->AddObserverL( this ); |
|
102 } |
|
103 |
|
104 |
|
105 //----------------------------------------------------------------------------- |
|
106 // From class MAknWsEventObserver |
|
107 // Propagates window server visibility events to the observer |
|
108 //----------------------------------------------------------------------------- |
|
109 // |
|
110 void CGlxWindowVisibilityMonitor::HandleWsEventL( const TWsEvent& aEvent, |
|
111 CCoeControl* /*aDestination*/ ) |
|
112 { |
|
113 GLX_LOG_INFO("CGlxWindowVisibilityMonitor::HandleWsEventL"); |
|
114 TInt eventType = aEvent.Type(); |
|
115 |
|
116 if ( eventType == EEventWindowVisibilityChanged ) |
|
117 { |
|
118 // check the state |
|
119 TUint visible = aEvent.VisibilityChanged()->iFlags; |
|
120 // notify the observer |
|
121 if ( visible & TWsVisibilityChangedEvent::EFullyVisible ) |
|
122 { |
|
123 GLX_LOG_INFO("Visibility Event - EFullyVisible"); |
|
124 iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayIsVisible ); |
|
125 } |
|
126 else if ( visible & TWsVisibilityChangedEvent::ENotVisible ) |
|
127 { |
|
128 GLX_LOG_INFO("Visibility Event - ENotVisible"); |
|
129 iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayNotVisible ); |
|
130 } |
|
131 else if (visible & TWsVisibilityChangedEvent::EPartiallyVisible) |
|
132 { |
|
133 GLX_LOG_INFO("Visibility Event - EPartiallyVisible"); |
|
134 iVisibilityObserver.HandleWindowVisibilityChangedL( ETvDisplayNotVisible ); |
|
135 } |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |