[Tizen] Showing window after adaptor is initialized
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
1 /*
2  * Copyright (c) 2020 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 <thread>
23 #include <dali/integration-api/core.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 #include <dali/integration-api/events/touch-event-integ.h>
32
33 // INTERNAL HEADERS
34 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
35 #include <dali/internal/graphics/gles/egl-graphics.h>
36 #include <dali/internal/window-system/common/event-handler.h>
37 #include <dali/internal/window-system/common/orientation-impl.h>
38 #include <dali/internal/window-system/common/render-surface-factory.h>
39 #include <dali/internal/window-system/common/window-factory.h>
40 #include <dali/internal/window-system/common/window-base.h>
41 #include <dali/internal/window-system/common/window-system.h>
42 #include <dali/internal/window-system/common/window-render-surface.h>
43 #include <dali/internal/window-system/common/window-visibility-observer.h>
44
45 namespace Dali
46 {
47 namespace Internal
48 {
49 namespace Adaptor
50 {
51
52 namespace
53 {
54
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
57 #endif
58
59 } // unnamed namespace
60
61 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
62 {
63   Any surface;
64   return Window::New(surface, positionSize, name, className, isTransparent);
65 }
66
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
68 {
69   Window* window = new Window();
70   window->mIsTransparent = isTransparent;
71   window->Initialize(surface, positionSize, name, className);
72   return window;
73 }
74
75 Window::Window()
76 : mWindowSurface( nullptr ),
77   mWindowBase(),
78   mIsTransparent( false ),
79   mIsFocusAcceptable( true ),
80   mIconified( false ),
81   mOpaqueState( false ),
82   mResizeEnabled( false ),
83   mType( Dali::Window::NORMAL ),
84   mParentWindow( NULL ),
85   mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ),
86   mRotationAngle( -1 ),
87   mWindowWidth( 0 ),
88   mWindowHeight( 0 ),
89   mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
90   mNativeWindowId( -1 ),
91   mDeleteRequestSignal(),
92   mFocusChangeSignal(),
93   mResizeSignal(),
94   mVisibilityChangedSignal(),
95   mTransitionEffectEventSignal(),
96   mKeyboardRepeatSettingsChangedSignal()
97 {
98 }
99
100 Window::~Window()
101 {
102   if ( mEventHandler )
103   {
104     mEventHandler->RemoveObserver( *this );
105   }
106 }
107
108 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
109 {
110   // Create a window render surface
111   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
112   mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
113   mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
114
115   // Get a window base
116   mWindowBase = mWindowSurface->GetWindowBase();
117
118   // Connect signals
119   mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
120   mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
121   mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
122   mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
123   mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
124   mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
125
126   mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
127
128   if( !positionSize.IsEmpty() )
129   {
130     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
131     mResizeEnabled = true;
132   }
133
134   SetClass( name, className );
135
136   mOrientation = Orientation::New( this );
137
138   // Get OrientationMode
139   int screenWidth, screenHeight;
140   WindowSystem::GetScreenSize( screenWidth, screenHeight );
141   if( screenWidth > screenHeight )
142   {
143     mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
144   }
145   else
146   {
147     mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
148   }
149   // For Debugging
150   mNativeWindowId = mWindowBase->GetNativeWindowId();
151 }
152
153 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
154 {
155   mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
156   mEventHandler->AddObserver( *this );
157
158   // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
159   // The show must be called after the adaptor is initialized.
160   Show();
161 }
162
163 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
164 {
165   mWindowSurface = static_cast<WindowRenderSurface*>( surface );
166 }
167
168 void Window::SetClass( std::string name, std::string className )
169 {
170   mName = name;
171   mClassName = className;
172   mWindowBase->SetClass( name, className );
173 }
174
175 std::string Window::GetClassName() const
176 {
177   return mClassName;
178 }
179
180 void Window::Raise()
181 {
182   mWindowBase->Raise();
183
184   mSurface->SetFullSwapNextFrame();
185
186   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
187 }
188
189 void Window::Lower()
190 {
191   mWindowBase->Lower();
192
193   mSurface->SetFullSwapNextFrame();
194
195   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
196 }
197
198 void Window::Activate()
199 {
200   mWindowBase->Activate();
201
202   mSurface->SetFullSwapNextFrame();
203
204   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
205 }
206
207 uint32_t Window::GetLayerCount() const
208 {
209   return mScene.GetLayerCount();
210 }
211
212 Dali::Layer Window::GetLayer( uint32_t depth ) const
213 {
214   return mScene.GetLayer( depth );
215 }
216
217 Dali::RenderTaskList Window::GetRenderTaskList() const
218 {
219   return mScene.GetRenderTaskList();
220 }
221
222 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
223 {
224   if( IsOrientationAvailable( orientation ) == false )
225   {
226     return;
227   }
228
229   bool found = false;
230   int convertedAngle = ConvertToAngle( orientation );
231   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
232   for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
233   {
234     if( mAvailableAngles[i] == convertedAngle )
235     {
236       found = true;
237       break;
238     }
239   }
240
241   if( !found )
242   {
243     mAvailableAngles.push_back( convertedAngle );
244     SetAvailableAnlges( mAvailableAngles );
245   }
246 }
247
248 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
249 {
250   if( IsOrientationAvailable( orientation ) == false )
251   {
252     return;
253   }
254
255   int convertedAngle = ConvertToAngle( orientation );
256   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
257   for( std::vector< int >::iterator iter = mAvailableAngles.begin();
258        iter != mAvailableAngles.end(); ++iter )
259   {
260     if( *iter == convertedAngle )
261     {
262       mAvailableAngles.erase( iter );
263       break;
264     }
265   }
266
267   SetAvailableAnlges( mAvailableAngles );
268 }
269
270 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
271 {
272   if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
273   {
274     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
275     return;
276   }
277   mPreferredAngle = ConvertToAngle( orientation );
278   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
279   mWindowBase->SetPreferredAngle( mPreferredAngle );
280 }
281
282 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
283 {
284   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
285   Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
286   return preferredOrientation;
287 }
288
289 void Window::SetAvailableAnlges( const std::vector< int >& angles )
290 {
291   if( angles.size() > 4 )
292   {
293     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
294     return;
295   }
296
297   mWindowBase->SetAvailableAnlges( angles );
298 }
299
300 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
301 {
302   int convertAngle = static_cast< int >( orientation );
303   if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
304   {
305     switch( orientation )
306     {
307       case Dali::Window::LANDSCAPE:
308       {
309         convertAngle = 0;
310         break;
311       }
312       case Dali::Window::PORTRAIT:
313       {
314         convertAngle = 90;
315         break;
316       }
317       case Dali::Window::LANDSCAPE_INVERSE:
318       {
319         convertAngle = 180;
320         break;
321       }
322       case Dali::Window::PORTRAIT_INVERSE:
323       {
324         convertAngle = 270;
325         break;
326       }
327       case Dali::Window::NO_ORIENTATION_PREFERENCE:
328       {
329         convertAngle = -1;
330         break;
331       }
332     }
333   }
334   return convertAngle;
335 }
336
337 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
338 {
339   Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
340   if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
341   {
342     switch( angle )
343     {
344       case 0:
345       {
346         orientation = Dali::Window::LANDSCAPE;
347         break;
348       }
349       case 90:
350       {
351         orientation = Dali::Window::PORTRAIT;
352         break;
353       }
354       case 180:
355       {
356         orientation = Dali::Window::LANDSCAPE_INVERSE;
357         break;
358       }
359       case 270:
360       {
361         orientation = Dali::Window::PORTRAIT_INVERSE;
362         break;
363       }
364       case -1:
365       {
366         orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
367         break;
368       }
369     }
370   }
371   return orientation;
372 }
373
374 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
375 {
376   if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
377   {
378     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
379     return false;
380   }
381   return true;
382 }
383
384 Dali::Any Window::GetNativeHandle() const
385 {
386   return mWindowSurface->GetNativeWindow();
387 }
388
389 void Window::SetAcceptFocus( bool accept )
390 {
391   mIsFocusAcceptable = accept;
392
393   mWindowBase->SetAcceptFocus( accept );
394 }
395
396 bool Window::IsFocusAcceptable() const
397 {
398   return mIsFocusAcceptable;
399 }
400
401 void Window::Show()
402 {
403   mVisible = true;
404
405   mWindowBase->Show();
406
407   if( !mIconified )
408   {
409     WindowVisibilityObserver* observer( mAdaptor );
410     observer->OnWindowShown();
411
412     Dali::Window handle( this );
413     mVisibilityChangedSignal.Emit( handle, true );
414   }
415
416   mSurface->SetFullSwapNextFrame();
417
418   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
419 }
420
421 void Window::Hide()
422 {
423   mVisible = false;
424
425   mWindowBase->Hide();
426
427   if( !mIconified )
428   {
429     WindowVisibilityObserver* observer( mAdaptor );
430     observer->OnWindowHidden();
431
432     Dali::Window handle( this );
433     mVisibilityChangedSignal.Emit( handle, false );
434   }
435
436   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
437 }
438
439 bool Window::IsVisible() const
440 {
441   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
442   return mVisible && !mIconified;
443 }
444
445 unsigned int Window::GetSupportedAuxiliaryHintCount() const
446 {
447   return mWindowBase->GetSupportedAuxiliaryHintCount();
448 }
449
450 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
451 {
452   return mWindowBase->GetSupportedAuxiliaryHint( index );
453 }
454
455 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
456 {
457   return mWindowBase->AddAuxiliaryHint( hint, value );
458 }
459
460 bool Window::RemoveAuxiliaryHint( unsigned int id )
461 {
462   return mWindowBase->RemoveAuxiliaryHint( id );
463 }
464
465 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
466 {
467   return mWindowBase->SetAuxiliaryHintValue( id, value );
468 }
469
470 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
471 {
472   return mWindowBase->GetAuxiliaryHintValue( id );
473 }
474
475 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
476 {
477   return mWindowBase->GetAuxiliaryHintId( hint );
478 }
479
480 void Window::SetInputRegion( const Rect< int >& inputRegion )
481 {
482   mWindowBase->SetInputRegion( inputRegion );
483
484   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 );
485 }
486
487 void Window::SetType( Dali::Window::Type type )
488 {
489   if( type != mType )
490   {
491     mWindowBase->SetType( type );
492
493     mType = type;
494   }
495 }
496
497 Dali::Window::Type Window::GetType() const
498 {
499   return mType;
500 }
501
502 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
503 {
504   if( mType != Dali::Window::NOTIFICATION )
505   {
506     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
507     return false;
508   }
509
510   return mWindowBase->SetNotificationLevel( level );
511 }
512
513 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
514 {
515   if( mType != Dali::Window::NOTIFICATION )
516   {
517     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
518     return Dali::Window::NotificationLevel::NONE;
519   }
520
521   return mWindowBase->GetNotificationLevel();
522 }
523
524 void Window::SetOpaqueState( bool opaque )
525 {
526   mOpaqueState = opaque;
527
528   mWindowBase->SetOpaqueState( opaque );
529
530   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
531 }
532
533 bool Window::IsOpaqueState() const
534 {
535   return mOpaqueState;
536 }
537
538 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
539 {
540   return mWindowBase->SetScreenOffMode( screenOffMode );
541 }
542
543 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
544 {
545   return mWindowBase->GetScreenOffMode();
546 }
547
548 bool Window::SetBrightness( int brightness )
549 {
550   if( brightness < 0 || brightness > 100 )
551   {
552     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
553     return false;
554   }
555
556   return mWindowBase->SetBrightness( brightness );
557 }
558
559 int Window::GetBrightness() const
560 {
561   return mWindowBase->GetBrightness();
562 }
563
564 void Window::SetSize( Dali::Window::WindowSize size )
565 {
566   if( !mResizeEnabled )
567   {
568     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
569     mResizeEnabled = true;
570   }
571
572   PositionSize oldRect = mSurface->GetPositionSize();
573
574   mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
575
576   PositionSize newRect = mSurface->GetPositionSize();
577
578   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
579   if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
580   {
581     Uint16Pair newSize( newRect.width, newRect.height );
582
583     bool forceUpdate = false;
584     if( mWindowBase->IsEglWindowRotationSupported() )
585     {
586       forceUpdate = true;
587     }
588
589     SurfaceResized( forceUpdate );
590
591     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
592
593     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
594
595     Dali::Window handle( this );
596     mResizeSignal.Emit( handle, newSize );
597
598     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
599   }
600
601   mSurface->SetFullSwapNextFrame();
602 }
603
604 Dali::Window::WindowSize Window::GetSize() const
605 {
606   PositionSize positionSize = mSurface->GetPositionSize();
607
608   return Dali::Window::WindowSize( positionSize.width, positionSize.height );
609 }
610
611 void Window::SetPosition( Dali::Window::WindowPosition position )
612 {
613   if( !mResizeEnabled )
614   {
615     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
616     mResizeEnabled = true;
617   }
618
619   PositionSize oldRect = mSurface->GetPositionSize();
620
621   mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
622
623   mSurface->SetFullSwapNextFrame();
624 }
625
626 Dali::Window::WindowPosition Window::GetPosition() const
627 {
628   PositionSize positionSize = mSurface->GetPositionSize();
629
630   return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
631 }
632
633 void Window::SetPositionSize( PositionSize positionSize )
634 {
635   if( !mResizeEnabled )
636   {
637     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
638     mResizeEnabled = true;
639   }
640
641   PositionSize oldRect = mSurface->GetPositionSize();
642
643   mWindowSurface->MoveResize( positionSize );
644
645   PositionSize newRect = mSurface->GetPositionSize();
646
647   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
648   if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
649   {
650     Uint16Pair newSize( newRect.width, newRect.height );
651
652     bool forceUpdate = false;
653     if( mWindowBase->IsEglWindowRotationSupported() )
654     {
655       forceUpdate = true;
656     }
657
658     SurfaceResized( forceUpdate );
659
660     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
661
662     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
663     Dali::Window handle( this );
664     mResizeSignal.Emit( handle, newSize );
665     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
666   }
667
668   mSurface->SetFullSwapNextFrame();
669 }
670
671 Dali::Layer Window::GetRootLayer() const
672 {
673   return mScene.GetRootLayer();
674 }
675
676 void Window::SetTransparency( bool transparent )
677 {
678   mWindowSurface->SetTransparency( transparent );
679 }
680
681 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
682 {
683   return mWindowBase->GrabKey( key, grabMode );
684 }
685
686 bool Window::UngrabKey( Dali::KEY key )
687 {
688   return mWindowBase->UngrabKey( key );
689 }
690
691 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
692 {
693   return mWindowBase->GrabKeyList( key, grabMode, result );
694 }
695
696 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
697 {
698   return mWindowBase->UngrabKeyList( key, result );
699 }
700
701 void Window::OnIconifyChanged( bool iconified )
702 {
703   if( iconified )
704   {
705     mIconified = true;
706
707     if( mVisible )
708     {
709       WindowVisibilityObserver* observer( mAdaptor );
710       observer->OnWindowHidden();
711
712       Dali::Window handle( this );
713       mVisibilityChangedSignal.Emit( handle, false );
714     }
715
716     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
717   }
718   else
719   {
720     mIconified = false;
721
722     if( mVisible )
723     {
724       WindowVisibilityObserver* observer( mAdaptor );
725       observer->OnWindowShown();
726
727       Dali::Window handle( this );
728       mVisibilityChangedSignal.Emit( handle, true );
729     }
730
731     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
732   }
733
734   mSurface->SetFullSwapNextFrame();
735 }
736
737 void Window::OnFocusChanged( bool focusIn )
738 {
739   Dali::Window handle( this );
740   mFocusChangeSignal.Emit( handle, focusIn );
741
742   mSurface->SetFullSwapNextFrame();
743 }
744
745 void Window::OnOutputTransformed()
746 {
747   bool forceUpdate = false;
748   if( mWindowBase->IsEglWindowRotationSupported() )
749   {
750     forceUpdate = true;
751   }
752   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnOutputTransformed()\n", this, mNativeWindowId );
753   SurfaceResized( forceUpdate );
754
755   PositionSize positionSize = mSurface->GetPositionSize();
756   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
757   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
758 }
759
760 void Window::OnDeleteRequest()
761 {
762   mDeleteRequestSignal.Emit();
763 }
764
765 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
766 {
767   Dali::Window handle( this );
768   mTransitionEffectEventSignal.Emit( handle, state, type );
769 }
770
771 void Window::OnKeyboardRepeatSettingsChanged()
772 {
773   Dali::Window handle( this );
774   mKeyboardRepeatSettingsChangedSignal.Emit();
775 }
776
777 void Window::OnWindowRedrawRequest()
778 {
779   mAdaptor->RenderOnce();
780 }
781
782 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
783 {
784   FeedTouchPoint( point, timeStamp );
785 }
786
787 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
788 {
789   FeedWheelEvent( wheelEvent );
790 }
791
792 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
793 {
794   FeedKeyEvent( keyEvent );
795 }
796
797 void Window::OnRotation( const RotationEvent& rotation )
798 {
799   mRotationAngle = rotation.angle;
800   mWindowWidth = rotation.width;
801   mWindowHeight = rotation.height;
802
803   // Notify that the orientation is changed
804   mOrientation->OnOrientationChange( rotation );
805
806   mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
807
808   bool forceUpdate = false;
809   if( mWindowBase->IsEglWindowRotationSupported() )
810   {
811     forceUpdate = true;
812   }
813
814   SurfaceResized( forceUpdate );
815
816   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
817
818   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
819   // Emit signal
820   Dali::Window handle( this );
821   mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
822
823   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
824 }
825
826 void Window::OnPause()
827 {
828   if( mEventHandler )
829   {
830     mEventHandler->Pause();
831   }
832 }
833
834 void Window::OnResume()
835 {
836   if( mEventHandler )
837   {
838     mEventHandler->Resume();
839   }
840
841   mSurface->SetFullSwapNextFrame();
842 }
843
844 void Window::RecalculateTouchPosition( Integration::Point& point )
845 {
846   Vector2 position = point.GetScreenPosition();
847   Vector2 convertedPosition;
848
849   switch( mRotationAngle )
850   {
851     case 90:
852     {
853       convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
854       convertedPosition.y = position.x;
855       break;
856     }
857     case 180:
858     {
859       convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
860       convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
861       break;
862     }
863     case 270:
864     {
865       convertedPosition.x = position.y;
866       convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
867       break;
868     }
869     default:
870     {
871       convertedPosition = position;
872       break;
873     }
874   }
875
876   point.SetScreenPosition( convertedPosition );
877 }
878
879 Dali::Window Window::Get( Dali::Actor actor )
880 {
881   Internal::Adaptor::Window* windowImpl = nullptr;
882
883   if ( Internal::Adaptor::Adaptor::IsAvailable() )
884   {
885     Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
886     windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
887     if( windowImpl )
888     {
889       return Dali::Window( windowImpl );
890     }
891   }
892
893   return Dali::Window();
894 }
895
896 void Window::SetParent( Dali::Window& parent )
897 {
898   if ( DALI_UNLIKELY( parent ) )
899   {
900     mParentWindow = parent;
901     Dali::Window self = Dali::Window( this );
902     // check circular parent window setting
903     if ( Dali::DevelWindow::GetParent( parent ) == self )
904     {
905       Dali::DevelWindow::Unparent( parent );
906     }
907     mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
908   }
909 }
910
911 void Window::Unparent()
912 {
913   mWindowBase->SetParent( nullptr );
914   mParentWindow.Reset();
915 }
916
917 Dali::Window Window::GetParent()
918 {
919   return mParentWindow;
920 }
921
922 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
923 {
924   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
925   return ConvertToOrientation( mRotationAngle );
926 }
927
928 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
929 {
930   Dali::Vector<float>::SizeType count = orientations.Count();
931   for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
932   {
933     if( IsOrientationAvailable( orientations[index] ) == false )
934     {
935       DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
936       continue;
937     }
938
939     bool found = false;
940     int convertedAngle = ConvertToAngle( orientations[index] );
941
942     for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
943     {
944       if( mAvailableAngles[i] == convertedAngle )
945       {
946         found = true;
947         break;
948       }
949     }
950
951     if( !found )
952     {
953       DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
954       mAvailableAngles.push_back( convertedAngle );
955     }
956   }
957   SetAvailableAnlges( mAvailableAngles );
958 }
959
960 int32_t Window::GetNativeId() const
961 {
962   return mWindowBase->GetNativeWindowId();
963 }
964
965 } // Adaptor
966
967 } // Internal
968
969 } // Dali