taskswitcher/contextengine/tsfswpreviewprovider/wsplugin/src/previewprovidercrp.cpp
equal
deleted
inserted
replaced
31 #include <graphics/wsscreendevice.h> |
31 #include <graphics/wsscreendevice.h> |
32 #endif |
32 #endif |
33 |
33 |
34 // CONSTANTS |
34 // CONSTANTS |
35 const TInt KImpId( 0x20016BEC ); |
35 const TInt KImpId( 0x20016BEC ); |
|
36 const TInt KMinTimeForOrientationSwitch = 1; // 1 second |
36 |
37 |
37 // -------------------------------------------------------------------------- |
38 // -------------------------------------------------------------------------- |
38 // CPreviewProviderCRP::CreateL |
39 // CPreviewProviderCRP::CreateL |
39 // -------------------------------------------------------------------------- |
40 // -------------------------------------------------------------------------- |
40 // |
41 // |
143 { |
144 { |
144 TSLOG_CONTEXT( ConstructL, TSLOG_LOCAL ); |
145 TSLOG_CONTEXT( ConstructL, TSLOG_LOCAL ); |
145 TSLOG_IN(); |
146 TSLOG_IN(); |
146 |
147 |
147 BaseConstructL( aEnv, aId, aOwner ); |
148 BaseConstructL( aEnv, aId, aOwner ); |
148 aEnv.RegisterEventHandler( this, this, TWservCrEvent::EWindowGroupChanged ); |
149 aEnv.RegisterEventHandler( this, this, TWservCrEvent::EWindowGroupChanged | |
|
150 TWservCrEvent::EDeviceOrientationChanged ); |
|
151 iScreenChangedTime = 0; |
149 |
152 |
150 TSLOG_OUT(); |
153 TSLOG_OUT(); |
151 } |
154 } |
152 |
155 |
153 // -------------------------------------------------------------------------- |
156 // -------------------------------------------------------------------------- |
163 { |
166 { |
164 const TInt wgId = aEvent.WindowGroupIdentifier(); |
167 const TInt wgId = aEvent.WindowGroupIdentifier(); |
165 if ( iWgIds.FindInOrder( iPrevId ) >= 0 || |
168 if ( iWgIds.FindInOrder( iPrevId ) >= 0 || |
166 ( iPrevId == 0 && iPrevReg != 0 ) ) |
169 ( iPrevId == 0 && iPrevReg != 0 ) ) |
167 { |
170 { |
168 TRAP_IGNORE( ScreenshotL() ); |
171 TTime currTime; |
|
172 currTime.HomeTime(); |
|
173 TTimeIntervalSeconds secondsFrom; |
|
174 TInt err = currTime.SecondsFrom( iScreenChangedTime, secondsFrom ); |
|
175 if ( err != KErrNone || secondsFrom.Int() > KMinTimeForOrientationSwitch ) |
|
176 { |
|
177 TRAP_IGNORE( ScreenshotL() ); |
|
178 } |
|
179 else |
|
180 { |
|
181 // Reset time to allow screenshot taking on next wg change |
|
182 iScreenChangedTime = 0; |
|
183 // Order screenshot rotation |
|
184 BitmapRotationNeeded( iPrevId?iPrevId:iPrevReg, iClockwiseRot ); |
|
185 } |
169 iPrevReg = 0; |
186 iPrevReg = 0; |
170 } |
187 } |
171 iPrevId = wgId; |
188 iPrevId = wgId; |
|
189 } |
|
190 else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged ) |
|
191 { |
|
192 iScreenChangedTime.HomeTime(); |
|
193 TRAP_IGNORE( ScreenshotL() ); |
172 } |
194 } |
173 |
195 |
174 TSLOG_OUT(); |
196 TSLOG_OUT(); |
175 } |
197 } |
176 |
198 |
215 SendMessage(buf); |
237 SendMessage(buf); |
216 |
238 |
217 TSLOG_OUT(); |
239 TSLOG_OUT(); |
218 } |
240 } |
219 |
241 |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // CPreviewProviderCRP::BitmapRotationNeeded |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 void CPreviewProviderCRP::BitmapRotationNeeded( TInt aWgId, TBool aClockwise ) |
|
248 { |
|
249 TSLOG_CONTEXT( BitmapRotationNeeded, TSLOG_LOCAL ); |
|
250 TSLOG_IN(); |
|
251 |
|
252 const TInt msg[] = { |
|
253 aClockwise ? NPreviewMsg::EBitmapRotationNeeded90 : NPreviewMsg::EBitmapRotationNeeded270, |
|
254 aWgId, |
|
255 0 |
|
256 }; |
|
257 TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg); |
|
258 SendMessage(buf); |
|
259 |
|
260 TSLOG_OUT(); |
|
261 } |
|
262 |
|
263 |
220 // -------------------------------------------------------------------------- |
264 // -------------------------------------------------------------------------- |
221 // CPreviewProviderCRP::Register |
265 // CPreviewProviderCRP::Register |
222 // -------------------------------------------------------------------------- |
266 // -------------------------------------------------------------------------- |
223 // |
267 // |
224 void CPreviewProviderCRP::Register( TInt aWgId ) |
268 void CPreviewProviderCRP::Register( TInt aWgId ) |
298 iScreenshotSize.iHeight == 0 || |
342 iScreenshotSize.iHeight == 0 || |
299 !screenFront ) |
343 !screenFront ) |
300 { |
344 { |
301 iScreenshotSize = sz; |
345 iScreenshotSize = sz; |
302 } |
346 } |
|
347 |
|
348 // Mark direction for possible rotation |
|
349 iClockwiseRot = iScreenshotSize.iWidth > iScreenshotSize.iHeight; |
|
350 |
303 // Use the the same DisplayMode as for the source image |
351 // Use the the same DisplayMode as for the source image |
304 // so override the display mode, ignoring any requests. |
352 // so override the display mode, ignoring any requests. |
305 iScreenshotMode = screenConfig->DisplayMode(); |
353 iScreenshotMode = screenConfig->DisplayMode(); |
306 |
354 |
307 TSLOG3( TSLOG_INFO, "iShotSize: %dx%d mode: %d", |
355 TSLOG3( TSLOG_INFO, "iShotSize: %dx%d mode: %d", |