2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/window-system/common/window-impl.h>
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>
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>
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
59 } // unnamed namespace
61 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
64 return Window::New(surface, positionSize, name, className, isTransparent);
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
69 Window* window = new Window();
70 window->mIsTransparent = isTransparent;
71 window->Initialize(surface, positionSize, name, className);
76 : mWindowSurface( nullptr ),
78 mIsTransparent( false ),
79 mIsFocusAcceptable( true ),
81 mOpaqueState( false ),
82 mResizeEnabled( false ),
83 mType( Dali::Window::NORMAL ),
84 mParentWindow( NULL ),
85 mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ),
89 mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
90 mNativeWindowId( -1 ),
91 mDeleteRequestSignal(),
94 mVisibilityChangedSignal(),
95 mTransitionEffectEventSignal(),
96 mKeyboardRepeatSettingsChangedSignal()
104 mEventHandler->RemoveObserver( *this );
108 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
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() );
116 mWindowBase = mWindowSurface->GetWindowBase();
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 );
126 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
128 if( !positionSize.IsEmpty() )
130 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
131 mResizeEnabled = true;
134 SetClass( name, className );
136 mWindowSurface->Map();
138 mOrientation = Orientation::New( this );
140 // Get OrientationMode
141 int screenWidth, screenHeight;
142 WindowSystem::GetScreenSize( screenWidth, screenHeight );
143 if( screenWidth > screenHeight )
145 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
149 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
152 mNativeWindowId = mWindowBase->GetNativeWindowId();
155 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
157 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
158 mEventHandler->AddObserver( *this );
161 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
163 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
166 void Window::SetClass( std::string name, std::string className )
169 mClassName = className;
170 mWindowBase->SetClass( name, className );
173 std::string Window::GetClassName() const
180 mWindowBase->Raise();
182 mSurface->SetFullSwapNextFrame();
184 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
189 mWindowBase->Lower();
191 mSurface->SetFullSwapNextFrame();
193 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
196 void Window::Activate()
198 mWindowBase->Activate();
200 mSurface->SetFullSwapNextFrame();
202 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
205 uint32_t Window::GetLayerCount() const
207 return mScene.GetLayerCount();
210 Dali::Layer Window::GetLayer( uint32_t depth ) const
212 return mScene.GetLayer( depth );
215 Dali::RenderTaskList Window::GetRenderTaskList() const
217 return mScene.GetRenderTaskList();
220 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
222 if( IsOrientationAvailable( orientation ) == false )
228 int convertedAngle = ConvertToAngle( orientation );
229 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
230 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
232 if( mAvailableAngles[i] == convertedAngle )
241 mAvailableAngles.push_back( convertedAngle );
242 SetAvailableAnlges( mAvailableAngles );
246 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
248 if( IsOrientationAvailable( orientation ) == false )
253 int convertedAngle = ConvertToAngle( orientation );
254 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
255 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
256 iter != mAvailableAngles.end(); ++iter )
258 if( *iter == convertedAngle )
260 mAvailableAngles.erase( iter );
265 SetAvailableAnlges( mAvailableAngles );
268 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
270 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
272 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
275 mPreferredAngle = ConvertToAngle( orientation );
276 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
277 mWindowBase->SetPreferredAngle( mPreferredAngle );
280 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
282 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
283 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
284 return preferredOrientation;
287 void Window::SetAvailableAnlges( const std::vector< int >& angles )
289 if( angles.size() > 4 )
291 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
295 mWindowBase->SetAvailableAnlges( angles );
298 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
300 int convertAngle = static_cast< int >( orientation );
301 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
303 switch( orientation )
305 case Dali::Window::LANDSCAPE:
310 case Dali::Window::PORTRAIT:
315 case Dali::Window::LANDSCAPE_INVERSE:
320 case Dali::Window::PORTRAIT_INVERSE:
325 case Dali::Window::NO_ORIENTATION_PREFERENCE:
335 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
337 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
338 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
344 orientation = Dali::Window::LANDSCAPE;
349 orientation = Dali::Window::PORTRAIT;
354 orientation = Dali::Window::LANDSCAPE_INVERSE;
359 orientation = Dali::Window::PORTRAIT_INVERSE;
364 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
372 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
374 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
376 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
382 Dali::Any Window::GetNativeHandle() const
384 return mWindowSurface->GetNativeWindow();
387 void Window::SetAcceptFocus( bool accept )
389 mIsFocusAcceptable = accept;
391 mWindowBase->SetAcceptFocus( accept );
394 bool Window::IsFocusAcceptable() const
396 return mIsFocusAcceptable;
407 WindowVisibilityObserver* observer( mAdaptor );
408 observer->OnWindowShown();
410 Dali::Window handle( this );
411 mVisibilityChangedSignal.Emit( handle, true );
414 mSurface->SetFullSwapNextFrame();
416 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
427 WindowVisibilityObserver* observer( mAdaptor );
428 observer->OnWindowHidden();
430 Dali::Window handle( this );
431 mVisibilityChangedSignal.Emit( handle, false );
434 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
437 bool Window::IsVisible() const
439 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
440 return mVisible && !mIconified;
443 unsigned int Window::GetSupportedAuxiliaryHintCount() const
445 return mWindowBase->GetSupportedAuxiliaryHintCount();
448 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
450 return mWindowBase->GetSupportedAuxiliaryHint( index );
453 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
455 return mWindowBase->AddAuxiliaryHint( hint, value );
458 bool Window::RemoveAuxiliaryHint( unsigned int id )
460 return mWindowBase->RemoveAuxiliaryHint( id );
463 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
465 return mWindowBase->SetAuxiliaryHintValue( id, value );
468 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
470 return mWindowBase->GetAuxiliaryHintValue( id );
473 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
475 return mWindowBase->GetAuxiliaryHintId( hint );
478 void Window::SetInputRegion( const Rect< int >& inputRegion )
480 mWindowBase->SetInputRegion( inputRegion );
482 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 void Window::SetType( Dali::Window::Type type )
489 mWindowBase->SetType( type );
495 Dali::Window::Type Window::GetType() const
500 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
502 if( mType != Dali::Window::NOTIFICATION )
504 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
508 return mWindowBase->SetNotificationLevel( level );
511 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
513 if( mType != Dali::Window::NOTIFICATION )
515 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
516 return Dali::Window::NotificationLevel::NONE;
519 return mWindowBase->GetNotificationLevel();
522 void Window::SetOpaqueState( bool opaque )
524 mOpaqueState = opaque;
526 mWindowBase->SetOpaqueState( opaque );
528 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
531 bool Window::IsOpaqueState() const
536 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
538 return mWindowBase->SetScreenOffMode( screenOffMode );
541 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
543 return mWindowBase->GetScreenOffMode();
546 bool Window::SetBrightness( int brightness )
548 if( brightness < 0 || brightness > 100 )
550 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
554 return mWindowBase->SetBrightness( brightness );
557 int Window::GetBrightness() const
559 return mWindowBase->GetBrightness();
562 void Window::SetSize( Dali::Window::WindowSize size )
564 if( !mResizeEnabled )
566 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
567 mResizeEnabled = true;
570 PositionSize oldRect = mSurface->GetPositionSize();
572 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
574 PositionSize newRect = mSurface->GetPositionSize();
576 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
577 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
579 Uint16Pair newSize( newRect.width, newRect.height );
581 bool forceUpdate = false;
582 if( mWindowBase->IsEglWindowRotationSupported() )
587 SurfaceResized( forceUpdate );
589 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
591 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
593 Dali::Window handle( this );
594 mResizeSignal.Emit( handle, newSize );
596 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
599 mSurface->SetFullSwapNextFrame();
602 Dali::Window::WindowSize Window::GetSize() const
604 PositionSize positionSize = mSurface->GetPositionSize();
606 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
609 void Window::SetPosition( Dali::Window::WindowPosition position )
611 if( !mResizeEnabled )
613 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
614 mResizeEnabled = true;
617 PositionSize oldRect = mSurface->GetPositionSize();
619 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
621 mSurface->SetFullSwapNextFrame();
624 Dali::Window::WindowPosition Window::GetPosition() const
626 PositionSize positionSize = mSurface->GetPositionSize();
628 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
631 void Window::SetPositionSize( PositionSize positionSize )
633 if( !mResizeEnabled )
635 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
636 mResizeEnabled = true;
639 PositionSize oldRect = mSurface->GetPositionSize();
641 mWindowSurface->MoveResize( positionSize );
643 PositionSize newRect = mSurface->GetPositionSize();
645 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
646 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
648 Uint16Pair newSize( newRect.width, newRect.height );
650 bool forceUpdate = false;
651 if( mWindowBase->IsEglWindowRotationSupported() )
656 SurfaceResized( forceUpdate );
658 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
660 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
661 Dali::Window handle( this );
662 mResizeSignal.Emit( handle, newSize );
663 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
666 mSurface->SetFullSwapNextFrame();
669 Dali::Layer Window::GetRootLayer() const
671 return mScene.GetRootLayer();
674 void Window::SetTransparency( bool transparent )
676 mWindowSurface->SetTransparency( transparent );
679 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
681 return mWindowBase->GrabKey( key, grabMode );
684 bool Window::UngrabKey( Dali::KEY key )
686 return mWindowBase->UngrabKey( key );
689 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
691 return mWindowBase->GrabKeyList( key, grabMode, result );
694 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
696 return mWindowBase->UngrabKeyList( key, result );
699 void Window::OnIconifyChanged( bool iconified )
707 WindowVisibilityObserver* observer( mAdaptor );
708 observer->OnWindowHidden();
710 Dali::Window handle( this );
711 mVisibilityChangedSignal.Emit( handle, false );
714 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
722 WindowVisibilityObserver* observer( mAdaptor );
723 observer->OnWindowShown();
725 Dali::Window handle( this );
726 mVisibilityChangedSignal.Emit( handle, true );
729 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
732 mSurface->SetFullSwapNextFrame();
735 void Window::OnFocusChanged( bool focusIn )
737 Dali::Window handle( this );
738 mFocusChangeSignal.Emit( handle, focusIn );
740 mSurface->SetFullSwapNextFrame();
743 void Window::OnOutputTransformed()
745 bool forceUpdate = false;
746 if( mWindowBase->IsEglWindowRotationSupported() )
750 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnOutputTransformed()\n", this, mNativeWindowId );
751 SurfaceResized( forceUpdate );
753 PositionSize positionSize = mSurface->GetPositionSize();
754 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
755 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
758 void Window::OnDeleteRequest()
760 mDeleteRequestSignal.Emit();
763 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
765 Dali::Window handle( this );
766 mTransitionEffectEventSignal.Emit( handle, state, type );
769 void Window::OnKeyboardRepeatSettingsChanged()
771 Dali::Window handle( this );
772 mKeyboardRepeatSettingsChangedSignal.Emit();
775 void Window::OnWindowRedrawRequest()
777 mAdaptor->RenderOnce();
780 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
782 FeedTouchPoint( point, timeStamp );
785 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
787 FeedWheelEvent( wheelEvent );
790 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
792 FeedKeyEvent( keyEvent );
795 void Window::OnRotation( const RotationEvent& rotation )
797 mRotationAngle = rotation.angle;
798 mWindowWidth = rotation.width;
799 mWindowHeight = rotation.height;
801 // Notify that the orientation is changed
802 mOrientation->OnOrientationChange( rotation );
804 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
806 bool forceUpdate = false;
807 if( mWindowBase->IsEglWindowRotationSupported() )
812 SurfaceResized( forceUpdate );
814 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
816 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
818 Dali::Window handle( this );
819 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
821 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
824 void Window::OnPause()
828 mEventHandler->Pause();
832 void Window::OnResume()
836 mEventHandler->Resume();
839 mSurface->SetFullSwapNextFrame();
842 void Window::RecalculateTouchPosition( Integration::Point& point )
844 Vector2 position = point.GetScreenPosition();
845 Vector2 convertedPosition;
847 switch( mRotationAngle )
851 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
852 convertedPosition.y = position.x;
857 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
858 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
863 convertedPosition.x = position.y;
864 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
869 convertedPosition = position;
874 point.SetScreenPosition( convertedPosition );
877 Dali::Window Window::Get( Dali::Actor actor )
879 Internal::Adaptor::Window* windowImpl = nullptr;
881 if ( Internal::Adaptor::Adaptor::IsAvailable() )
883 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
884 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
887 return Dali::Window( windowImpl );
891 return Dali::Window();
894 void Window::SetParent( Dali::Window& parent )
896 if ( DALI_UNLIKELY( parent ) )
898 mParentWindow = parent;
899 Dali::Window self = Dali::Window( this );
900 // check circular parent window setting
901 if ( Dali::DevelWindow::GetParent( parent ) == self )
903 Dali::DevelWindow::Unparent( parent );
905 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
909 void Window::Unparent()
911 mWindowBase->SetParent( nullptr );
912 mParentWindow.Reset();
915 Dali::Window Window::GetParent()
917 return mParentWindow;
920 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
922 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
923 return ConvertToOrientation( mRotationAngle );
926 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
928 Dali::Vector<float>::SizeType count = orientations.Count();
929 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
931 if( IsOrientationAvailable( orientations[index] ) == false )
933 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
938 int convertedAngle = ConvertToAngle( orientations[index] );
940 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
942 if( mAvailableAngles[i] == convertedAngle )
951 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
952 mAvailableAngles.push_back( convertedAngle );
955 SetAvailableAnlges( mAvailableAngles );
958 int32_t Window::GetNativeId() const
960 return mWindowBase->GetNativeWindowId();