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