Merge branch 'devel/master' into tizen
[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     SurfaceResized();
535
536     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
537
538     Dali::Window handle( this );
539     mResizedSignal.Emit( newSize );
540     mResizeSignal.Emit( handle, newSize );
541
542     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
543   }
544 }
545
546 Dali::Window::WindowSize Window::GetSize() const
547 {
548   PositionSize positionSize = mSurface->GetPositionSize();
549
550   return Dali::Window::WindowSize( positionSize.width, positionSize.height );
551 }
552
553 void Window::SetPosition( Dali::Window::WindowPosition position )
554 {
555   if( !mResizeEnabled )
556   {
557     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
558     mResizeEnabled = true;
559   }
560
561   PositionSize oldRect = mSurface->GetPositionSize();
562
563   mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
564 }
565
566 Dali::Window::WindowPosition Window::GetPosition() const
567 {
568   PositionSize positionSize = mSurface->GetPositionSize();
569
570   return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
571 }
572
573 void Window::SetPositionSize( PositionSize positionSize )
574 {
575   if( !mResizeEnabled )
576   {
577     AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
578     mResizeEnabled = true;
579   }
580
581   PositionSize oldRect = mSurface->GetPositionSize();
582
583   mWindowSurface->MoveResize( positionSize );
584
585   PositionSize newRect = mSurface->GetPositionSize();
586
587   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
588   if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
589   {
590     Uint16Pair newSize( newRect.width, newRect.height );
591
592     SurfaceResized();
593
594     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
595
596     Dali::Window handle( this );
597     mResizedSignal.Emit( newSize );
598     mResizeSignal.Emit( handle, newSize );
599     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
600   }
601 }
602
603 Dali::Layer Window::GetRootLayer() const
604 {
605   return mScene.GetRootLayer();
606 }
607
608 void Window::SetTransparency( bool transparent )
609 {
610   mWindowSurface->SetTransparency( transparent );
611 }
612
613 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
614 {
615   return mWindowBase->GrabKey( key, grabMode );
616 }
617
618 bool Window::UngrabKey( Dali::KEY key )
619 {
620   return mWindowBase->UngrabKey( key );
621 }
622
623 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
624 {
625   return mWindowBase->GrabKeyList( key, grabMode, result );
626 }
627
628 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
629 {
630   return mWindowBase->UngrabKeyList( key, result );
631 }
632
633 void Window::OnIconifyChanged( bool iconified )
634 {
635   if( iconified )
636   {
637     mIconified = true;
638
639     if( mVisible )
640     {
641       WindowVisibilityObserver* observer( mAdaptor );
642       observer->OnWindowHidden();
643
644       Dali::Window handle( this );
645       mVisibilityChangedSignal.Emit( handle, false );
646     }
647
648     DALI_LOG_RELEASE_INFO( "Window (%p) Iconified: visible = %d\n", this, mVisible );
649   }
650   else
651   {
652     mIconified = false;
653
654     if( mVisible )
655     {
656       WindowVisibilityObserver* observer( mAdaptor );
657       observer->OnWindowShown();
658
659       Dali::Window handle( this );
660       mVisibilityChangedSignal.Emit( handle, true );
661     }
662
663     DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified: visible = %d\n", this, mVisible );
664   }
665 }
666
667 void Window::OnFocusChanged( bool focusIn )
668 {
669   Dali::Window handle( this );
670   mFocusChangedSignal.Emit( focusIn );
671   mFocusChangeSignal.Emit( handle, focusIn );
672 }
673
674 void Window::OnOutputTransformed()
675 {
676   PositionSize positionSize = mSurface->GetPositionSize();
677   SurfaceResized();
678   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
679   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
680 }
681
682 void Window::OnDeleteRequest()
683 {
684   mDeleteRequestSignal.Emit();
685 }
686
687 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
688 {
689   Dali::Window handle( this );
690   mTransitionEffectEventSignal.Emit( handle, state, type );
691 }
692
693 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
694 {
695   FeedTouchPoint( point, timeStamp );
696 }
697
698 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
699 {
700   FeedWheelEvent( wheelEvent );
701 }
702
703 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
704 {
705   FeedKeyEvent( keyEvent );
706 }
707
708 void Window::OnRotation( const RotationEvent& rotation )
709 {
710   mRotationAngle = rotation.angle;
711   mWindowWidth = rotation.width;
712   mWindowHeight = rotation.height;
713
714   // Notify that the orientation is changed
715   mOrientation->OnOrientationChange( rotation );
716
717   mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
718
719   SurfaceResized();
720
721   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
722
723   // Emit signal
724   Dali::Window handle( this );
725   mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
726   mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
727
728   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
729 }
730
731 void Window::OnPause()
732 {
733   if( mEventHandler )
734   {
735     mEventHandler->Pause();
736   }
737 }
738
739 void Window::OnResume()
740 {
741   if( mEventHandler )
742   {
743     mEventHandler->Resume();
744   }
745 }
746
747 void Window::RecalculateTouchPosition( Integration::Point& point )
748 {
749   Vector2 position = point.GetScreenPosition();
750   Vector2 convertedPosition;
751
752   switch( mRotationAngle )
753   {
754     case 90:
755     {
756       convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
757       convertedPosition.y = position.x;
758       break;
759     }
760     case 180:
761     {
762       convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
763       convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
764       break;
765     }
766     case 270:
767     {
768       convertedPosition.x = position.y;
769       convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
770       break;
771     }
772     default:
773     {
774       convertedPosition = position;
775       break;
776     }
777   }
778
779   point.SetScreenPosition( convertedPosition );
780 }
781
782 Dali::Window Window::Get( Dali::Actor actor )
783 {
784   Internal::Adaptor::Window* windowImpl = nullptr;
785
786   if ( Internal::Adaptor::Adaptor::IsAvailable() )
787   {
788     Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
789     windowImpl = static_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
790   }
791
792   return Dali::Window( windowImpl );
793 }
794
795 void Window::SetParent( Dali::Window& parent )
796 {
797   if ( DALI_UNLIKELY( parent ) )
798   {
799     mParentWindow = parent;
800     Dali::Window self = Dali::Window( this );
801     // check circular parent window setting
802     if ( Dali::DevelWindow::GetParent( parent ) == self )
803     {
804       Dali::DevelWindow::Unparent( parent );
805     }
806     mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
807   }
808 }
809
810 void Window::Unparent()
811 {
812   mWindowBase->SetParent( nullptr );
813   mParentWindow.Reset();
814 }
815
816 Dali::Window Window::GetParent()
817 {
818   return mParentWindow;
819 }
820
821 } // Adaptor
822
823 } // Internal
824
825 } // Dali