Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/window-system/common/window-impl.h>
20
21 // EXTERNAL HEADERS
22 #include <dali/integration-api/core.h>
23 #include <dali/integration-api/render-task-list-integ.h>
24 #include <dali/public-api/actors/actor.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/actors/camera-actor.h>
27 #include <dali/public-api/render-tasks/render-task.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
29 #include <dali/public-api/rendering/frame-buffer.h>
30 #include <dali/devel-api/adaptor-framework/orientation.h>
31
32 // INTERNAL HEADERS
33 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
34 #include <dali/internal/window-system/common/window-visibility-observer.h>
35 #include <dali/internal/window-system/common/orientation-impl.h>
36 #include <dali/internal/window-system/common/render-surface-factory.h>
37 #include <dali/internal/window-system/common/window-factory.h>
38 #include <dali/internal/window-system/common/window-base.h>
39 #include <dali/internal/window-system/common/window-render-surface.h>
40
41 namespace Dali
42 {
43 namespace Internal
44 {
45 namespace Adaptor
46 {
47
48 uint32_t Window::mWindowCounter = 0;
49
50 namespace
51 {
52
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
55 #endif
56
57 } // unnamed namespace
58
59 Window* Window::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent )
60 {
61   Window* window = new Window();
62   window->mIsTransparent = isTransparent;
63   window->Initialize( positionSize, name, className );
64   return window;
65 }
66
67 Window::Window()
68 : mId( mWindowCounter++ ),
69   mSurface( nullptr ),
70   mWindowBase(),
71   mIndicatorVisible( Dali::Window::INVISIBLE ),   // TODO: Enable this after indicator implementation based on tizen 5.
72   mIndicatorIsShown( false ),
73   mShowRotatedIndicatorOnClose( false ),
74   mStarted( false ),
75   mIsFocusAcceptable( true ),
76   mVisible( true ),
77   mIconified( false ),
78   mOpaqueState( false ),
79   mResizeEnabled( false ),
80   mIndicator(),
81   mIndicatorOrientation( Dali::Window::PORTRAIT ),
82   mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
83   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
84   mAdaptor( NULL ),
85   mType( Dali::Window::NORMAL ),
86   mPreferredOrientation( Dali::Window::PORTRAIT ),
87   mIndicatorVisibilityChangedSignal(),
88   mFocusChangedSignal(),
89   mResizedSignal(),
90   mDeleteRequestSignal()
91 {
92 }
93
94 Window::~Window()
95 {
96   if( mIndicator )
97   {
98     mIndicator->Close();
99   }
100
101   if ( mAdaptor )
102   {
103     mAdaptor->RemoveObserver( *this );
104     mAdaptor->SetDragAndDropDetector( NULL );
105     mAdaptor->RemoveWindow( this );
106     mAdaptor = NULL;
107   }
108
109   mSurface.reset( nullptr );
110 }
111
112 void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
113 {
114   // Create a window render surface
115   Any surface;
116   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
117   mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
118
119   // Get a window base
120   mWindowBase = mSurface->GetWindowBase();
121
122   // Connect signals
123   mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
124   mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
125   mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
126   mWindowBase->IndicatorFlickedSignal().Connect( this, &Window::OnIndicatorFlicked );
127
128   mSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
129
130   if( !positionSize.IsEmpty() )
131   {
132     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
133     mResizeEnabled = true;
134   }
135
136   SetClass( name, className );
137
138   mSurface->Map();
139
140   mOrientation = Orientation::New( this );
141 }
142
143 void Window::SetAdaptor(Dali::Adaptor& adaptor)
144 {
145   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
146   mStarted = true;
147
148   PositionSize positionSize = mSurface->GetPositionSize();
149   mScene = Dali::Integration::Scene::New( Vector2(positionSize.width, positionSize.height) );
150   mScene.SetSurface( *mSurface.get() );
151
152   unsigned int dpiHorizontal, dpiVertical;
153   dpiHorizontal = dpiVertical = 0;
154
155   mSurface->GetDpi( dpiHorizontal, dpiVertical );
156   mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
157
158   // Create one overlay for the main window only
159   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
160   mAdaptor = &adaptorImpl;
161   mAdaptor->AddObserver( *this );
162
163   // Can only create the detector when we know the Core has been instantiated.
164   mDragAndDropDetector = DragAndDropDetector::New();
165   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
166
167   if( mOrientation )
168   {
169     mOrientation->SetAdaptor(adaptor);
170   }
171
172   if( mIndicator != NULL )
173   {
174     mIndicator->SetAdaptor(mAdaptor);
175   }
176
177   mSurface->SetAdaptor( *mAdaptor );
178 }
179
180 WindowRenderSurface* Window::GetSurface()
181 {
182   return mSurface.get();
183 }
184
185 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
186 {
187   // TODO: Enable this after indicator implementation based on tizen 5.
188 //  mIndicatorVisible = visibleMode;
189
190   mWindowBase->ShowIndicator( mIndicatorVisible, mIndicatorOpacityMode );
191
192   DoShowIndicator( mIndicatorOrientation );
193 }
194
195 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
196 {
197   mIndicatorOpacityMode = opacityMode;
198
199   if( mIndicator != NULL )
200   {
201     mIndicator->SetOpacityMode( opacityMode );
202   }
203 }
204
205 void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode )
206 {
207   // TODO: Enable this after indicator implementation based on tizen 5.
208 //  mIndicatorVisible = mode;
209 }
210
211 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
212 {
213   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
214
215   DoRotateIndicator( orientation );
216 }
217
218 void Window::SetClass( std::string name, std::string className )
219 {
220   mWindowBase->SetClass( name, className );
221 }
222
223 void Window::Raise()
224 {
225   mWindowBase->Raise();
226 }
227
228 void Window::Lower()
229 {
230   mWindowBase->Lower();
231 }
232
233 void Window::Activate()
234 {
235   mWindowBase->Activate();
236 }
237
238 void Window::Add( Dali::Actor actor )
239 {
240   mScene.Add( actor );
241 }
242
243 void Window::Remove( Dali::Actor actor )
244 {
245   mScene.Remove( actor );
246 }
247
248 Dali::Layer Window::GetRootLayer() const
249 {
250   return mScene.GetRootLayer();
251 }
252
253 uint32_t Window::GetLayerCount() const
254 {
255   return mScene.GetLayerCount();
256 }
257
258 Dali::Layer Window::GetLayer( uint32_t depth ) const
259 {
260   return mScene.GetLayer( depth );
261 }
262
263 void Window::SetBackgroundColor( Vector4 color )
264 {
265   if ( mSurface )
266   {
267     mSurface->SetBackgroundColor( color );
268   }
269 }
270
271 Vector4 Window::GetBackgroundColor() const
272 {
273   return mSurface ? mSurface->GetBackgroundColor() : Vector4();
274 }
275
276 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
277 {
278   bool found = false;
279
280   if( orientation <= Dali::Window::LANDSCAPE_INVERSE )
281   {
282     for( std::size_t i = 0; i < mAvailableOrientations.size(); i++ )
283     {
284       if( mAvailableOrientations[i] == orientation )
285       {
286         found = true;
287         break;
288       }
289     }
290
291     if( !found )
292     {
293       mAvailableOrientations.push_back( orientation );
294       SetAvailableOrientations( mAvailableOrientations );
295     }
296   }
297 }
298
299 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
300 {
301   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
302        iter != mAvailableOrientations.end(); ++iter )
303   {
304     if( *iter == orientation )
305     {
306       mAvailableOrientations.erase( iter );
307       break;
308     }
309   }
310   SetAvailableOrientations( mAvailableOrientations );
311 }
312
313 void Window::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
314 {
315   if( orientations.size() > 4 )
316   {
317     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableOrientations: Invalid vector size! [%d]\n", orientations.size() );
318     return;
319   }
320
321   mAvailableOrientations = orientations;
322
323   mWindowBase->SetAvailableOrientations( mAvailableOrientations );
324 }
325
326 const std::vector< Dali::Window::WindowOrientation >& Window::GetAvailableOrientations()
327 {
328   return mAvailableOrientations;
329 }
330
331 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
332 {
333   mPreferredOrientation = orientation;
334
335   mWindowBase->SetPreferredOrientation( mPreferredOrientation );
336 }
337
338 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
339 {
340   return mPreferredOrientation;
341 }
342
343 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
344 {
345   return mDragAndDropDetector;
346 }
347
348 Dali::Any Window::GetNativeHandle() const
349 {
350   return mSurface->GetNativeWindow();
351 }
352
353 void Window::SetAcceptFocus( bool accept )
354 {
355   mIsFocusAcceptable = accept;
356
357   mWindowBase->SetAcceptFocus( accept );
358 }
359
360 bool Window::IsFocusAcceptable() const
361 {
362   return mIsFocusAcceptable;
363 }
364
365 void Window::Show()
366 {
367   mVisible = true;
368
369   mWindowBase->Show();
370
371   if( !mIconified )
372   {
373     WindowVisibilityObserver* observer( mAdaptor );
374     observer->OnWindowShown();
375     DALI_LOG_RELEASE_INFO( "Window (%p) ::Show()\n", this );
376   }
377 }
378
379 void Window::Hide()
380 {
381   mVisible = false;
382
383   mWindowBase->Hide();
384
385   if( !mIconified )
386   {
387     WindowVisibilityObserver* observer( mAdaptor );
388     observer->OnWindowHidden();
389     DALI_LOG_RELEASE_INFO( "Window (%p) ::Hide() \n", this );
390   }
391 }
392
393 bool Window::IsVisible() const
394 {
395   return mVisible;
396 }
397
398 unsigned int Window::GetSupportedAuxiliaryHintCount() const
399 {
400   return mWindowBase->GetSupportedAuxiliaryHintCount();
401 }
402
403 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
404 {
405   return mWindowBase->GetSupportedAuxiliaryHint( index );
406 }
407
408 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
409 {
410   return mWindowBase->AddAuxiliaryHint( hint, value );
411 }
412
413 bool Window::RemoveAuxiliaryHint( unsigned int id )
414 {
415   return mWindowBase->RemoveAuxiliaryHint( id );
416 }
417
418 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
419 {
420   return mWindowBase->SetAuxiliaryHintValue( id, value );
421 }
422
423 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
424 {
425   return mWindowBase->GetAuxiliaryHintValue( id );
426 }
427
428 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
429 {
430   return mWindowBase->GetAuxiliaryHintId( hint );
431 }
432
433 void Window::SetInputRegion( const Rect< int >& inputRegion )
434 {
435   mWindowBase->SetInputRegion( inputRegion );
436
437   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
438 }
439
440 void Window::SetType( Dali::Window::Type type )
441 {
442   if( type != mType )
443   {
444     mWindowBase->SetType( type );
445
446     mType = type;
447   }
448 }
449
450 Dali::Window::Type Window::GetType() const
451 {
452   return mType;
453 }
454
455 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
456 {
457   if( mType != Dali::Window::NOTIFICATION )
458   {
459     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
460     return false;
461   }
462
463   return mWindowBase->SetNotificationLevel( level );
464 }
465
466 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
467 {
468   if( mType != Dali::Window::NOTIFICATION )
469   {
470     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
471     return Dali::Window::NotificationLevel::NONE;
472   }
473
474   return mWindowBase->GetNotificationLevel();
475 }
476
477 void Window::SetOpaqueState( bool opaque )
478 {
479   mOpaqueState = opaque;
480
481   mWindowBase->SetOpaqueState( opaque );
482
483   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
484 }
485
486 bool Window::IsOpaqueState() const
487 {
488   return mOpaqueState;
489 }
490
491 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
492 {
493   return mWindowBase->SetScreenOffMode( screenOffMode );
494 }
495
496 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
497 {
498   return mWindowBase->GetScreenOffMode();
499 }
500
501 bool Window::SetBrightness( int brightness )
502 {
503   if( brightness < 0 || brightness > 100 )
504   {
505     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
506     return false;
507   }
508
509   return mWindowBase->SetBrightness( brightness );
510 }
511
512 int Window::GetBrightness() const
513 {
514   return mWindowBase->GetBrightness();
515 }
516
517 void Window::SetSize( Dali::Window::WindowSize size )
518 {
519   if( !mResizeEnabled )
520   {
521     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
522     mResizeEnabled = true;
523   }
524
525   PositionSize oldRect = mSurface->GetPositionSize();
526
527   mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
528
529   PositionSize newRect = mSurface->GetPositionSize();
530
531   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
532   if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
533   {
534     Uint16Pair newSize( newRect.width, newRect.height );
535
536     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
537
538     mResizedSignal.Emit( newSize );
539
540     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
541   }
542 }
543
544 Dali::Window::WindowSize Window::GetSize() const
545 {
546   PositionSize positionSize = mSurface->GetPositionSize();
547
548   return Dali::Window::WindowSize( positionSize.width, positionSize.height );
549 }
550
551 void Window::SetPosition( Dali::Window::WindowPosition position )
552 {
553   if( !mResizeEnabled )
554   {
555     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
556     mResizeEnabled = true;
557   }
558
559   PositionSize oldRect = mSurface->GetPositionSize();
560
561   mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
562 }
563
564 Dali::Window::WindowPosition Window::GetPosition() const
565 {
566   PositionSize positionSize = mSurface->GetPositionSize();
567
568   return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
569 }
570
571 void Window::SetPositionSize( PositionSize positionSize )
572 {
573   if( !mResizeEnabled )
574   {
575     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
576     mResizeEnabled = true;
577   }
578
579   PositionSize oldRect = mSurface->GetPositionSize();
580
581   mSurface->MoveResize( positionSize );
582
583   PositionSize newRect = mSurface->GetPositionSize();
584
585   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
586   if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
587   {
588     Uint16Pair newSize( newRect.width, newRect.height );
589
590     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
591
592     mResizedSignal.Emit( newSize );
593
594     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
595   }
596 }
597
598 void Window::SetTransparency( bool transparent )
599 {
600   mSurface->SetTransparency( transparent );
601 }
602
603 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
604 {
605   return mWindowBase->GrabKey( key, grabMode );
606 }
607
608 bool Window::UngrabKey( Dali::KEY key )
609 {
610   return mWindowBase->UngrabKey( key );
611 }
612
613 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
614 {
615   return mWindowBase->GrabKeyList( key, grabMode, result );
616 }
617
618 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
619 {
620   return mWindowBase->UngrabKeyList( key, result );
621 }
622
623 void Window::RotationDone( int orientation, int width, int height )
624 {
625   mSurface->RequestRotation( orientation, width, height );
626
627   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( width, height ) );
628
629   // Emit signal
630   mResizedSignal.Emit( Dali::Window::WindowSize( width, height ) );
631
632   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( width, height ) );
633 }
634
635 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
636 {
637   if( mIndicator == NULL )
638   {
639     if( mIndicatorVisible != Dali::Window::INVISIBLE )
640     {
641       auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
642       mIndicator = windowFactory->CreateIndicator( mAdaptor, mIndicatorOrientation, this );
643       if( mIndicator )
644       {
645         mIndicator->SetOpacityMode( mIndicatorOpacityMode );
646         Dali::Actor actor = mIndicator->GetActor();
647         SetIndicatorActorRotation();
648       }
649     }
650     // else don't create a hidden indicator
651   }
652   else // Already have indicator
653   {
654     if( mIndicatorVisible == Dali::Window::VISIBLE )
655     {
656       // If we are resuming, and rotation has changed,
657       if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
658       {
659         // then close current indicator and open new one
660         mShowRotatedIndicatorOnClose = true;
661         mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
662         // Don't show actor - will contain indicator for old orientation.
663       }
664     }
665   }
666
667   // set indicator visible mode
668   if( mIndicator != NULL )
669   {
670     mIndicator->SetVisible( mIndicatorVisible );
671   }
672
673   bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
674   SetIndicatorProperties( show, lastOrientation );
675   mIndicatorIsShown = show;
676 }
677
678 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
679 {
680   if( mIndicatorIsShown )
681   {
682     mShowRotatedIndicatorOnClose = true;
683     mNextIndicatorOrientation = orientation;
684     if( mIndicator )
685     {
686       mIndicator->Close(); // May synchronously call IndicatorClosed() callback
687     }
688   }
689   else
690   {
691     // Save orientation for when the indicator is next shown
692     mShowRotatedIndicatorOnClose = false;
693     mNextIndicatorOrientation = orientation;
694   }
695 }
696
697 void Window::SetIndicatorActorRotation()
698 {
699   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
700   if( mIndicator )
701   {
702     Dali::Actor actor = mIndicator->GetActor();
703     switch( mIndicatorOrientation )
704     {
705       case Dali::Window::PORTRAIT:
706         actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
707         actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
708         actor.SetOrientation( Degree(0), Vector3::ZAXIS );
709         break;
710       case Dali::Window::PORTRAIT_INVERSE:
711         actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
712         actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
713         actor.SetOrientation( Degree(180), Vector3::ZAXIS );
714         break;
715       case Dali::Window::LANDSCAPE:
716         actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
717         actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
718         actor.SetOrientation( Degree(270), Vector3::ZAXIS );
719         break;
720       case Dali::Window::LANDSCAPE_INVERSE:
721         actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
722         actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
723         actor.SetOrientation( Degree(90), Vector3::ZAXIS );
724         break;
725     }
726   }
727 }
728
729 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
730 {
731   mWindowBase->SetIndicatorProperties( isShow, lastOrientation );
732 }
733
734 void Window::OnIconifyChanged( bool iconified )
735 {
736   if( iconified )
737   {
738     mIconified = true;
739
740     if( mVisible )
741     {
742       WindowVisibilityObserver* observer( mAdaptor );
743       observer->OnWindowHidden();
744       DALI_LOG_RELEASE_INFO( "Window (%p) Iconified\n", this );
745     }
746   }
747   else
748   {
749     mIconified = false;
750
751     if( mVisible )
752     {
753       WindowVisibilityObserver* observer( mAdaptor );
754       observer->OnWindowShown();
755       DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified\n", this );
756     }
757   }
758 }
759
760 void Window::OnFocusChanged( bool focusIn )
761 {
762   mFocusChangedSignal.Emit( focusIn );
763 }
764
765 void Window::OnOutputTransformed()
766 {
767   PositionSize positionSize = mSurface->GetPositionSize();
768   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
769   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
770 }
771
772 void Window::OnDeleteRequest()
773 {
774   mDeleteRequestSignal.Emit();
775 }
776
777 void Window::OnIndicatorFlicked()
778 {
779   if( mIndicator )
780   {
781     mIndicator->Flicked();
782   }
783 }
784
785 void Window::IndicatorTypeChanged( IndicatorInterface::Type type )
786 {
787   mWindowBase->IndicatorTypeChanged( type );
788 }
789
790 void Window::IndicatorClosed( IndicatorInterface* indicator )
791 {
792   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
793
794   if( mShowRotatedIndicatorOnClose )
795   {
796     Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
797     if( mIndicator )
798     {
799       mIndicator->Open( mNextIndicatorOrientation );
800     }
801     mIndicatorOrientation = mNextIndicatorOrientation;
802     SetIndicatorActorRotation();
803     DoShowIndicator( currentOrientation );
804   }
805 }
806
807 void Window::IndicatorVisibilityChanged( bool isVisible )
808 {
809   mIndicatorVisibilityChangedSignal.Emit( isVisible );
810 }
811
812 void Window::OnStart()
813 {
814   DoShowIndicator( mIndicatorOrientation );
815 }
816
817 void Window::OnPause()
818 {
819 }
820
821 void Window::OnResume()
822 {
823   // resume indicator status
824   if( mIndicator != NULL )
825   {
826     // Restore own indicator opacity
827     // Send opacity mode to indicator service when app resumed
828     mIndicator->SetOpacityMode( mIndicatorOpacityMode );
829   }
830 }
831
832 void Window::OnStop()
833 {
834   if( mIndicator )
835   {
836     mIndicator->Close();
837   }
838
839   mIndicator.release();
840 }
841
842 void Window::OnDestroy()
843 {
844   mAdaptor = NULL;
845 }
846
847 uint32_t Window::GetId() const
848 {
849   return mId;
850 }
851
852 } // Adaptor
853
854 } // Internal
855
856 } // Dali