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