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>
44 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
56 #if defined(DEBUG_ENABLED)
57 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
60 } // unnamed namespace
62 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
65 return Window::New(surface, positionSize, name, className, isTransparent);
68 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
70 Window* window = new Window();
71 window->mIsTransparent = isTransparent;
72 window->Initialize(surface, positionSize, name, className);
77 : mWindowSurface( nullptr ),
79 mIsTransparent( false ),
80 mIsFocusAcceptable( true ),
82 mOpaqueState( false ),
83 mResizeEnabled( false ),
84 mType( Dali::Window::NORMAL ),
85 mParentWindow( NULL ),
86 mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ),
90 mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
91 mNativeWindowId( -1 ),
92 mDeleteRequestSignal(),
95 mVisibilityChangedSignal(),
96 mTransitionEffectEventSignal(),
97 mKeyboardRepeatSettingsChangedSignal()
105 auto bridge = Accessibility::Bridge::GetCurrentBridge();
106 auto accessible2 = mScene.GetRootLayer();
107 auto accessible = Accessibility::Accessible::Get( accessible2 );
108 bridge->RemoveTopLevelWindow( accessible );
110 mAdaptor->RemoveWindow( this );
115 mEventHandler->RemoveObserver( *this );
119 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
121 // Create a window render surface
122 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
123 mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
124 mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
127 mWindowBase = mWindowSurface->GetWindowBase();
130 mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
131 mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
132 mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
133 mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
134 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
135 mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
137 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
139 if( !positionSize.IsEmpty() )
141 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
142 mResizeEnabled = true;
145 SetClass( name, className );
147 mWindowSurface->Map();
149 mOrientation = Orientation::New( this );
151 // Get OrientationMode
152 int screenWidth, screenHeight;
153 WindowSystem::GetScreenSize( screenWidth, screenHeight );
154 if( screenWidth > screenHeight )
156 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
160 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
163 mNativeWindowId = mWindowBase->GetNativeWindowId();
166 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
168 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
169 mEventHandler->AddObserver( *this );
171 auto bridge = Accessibility::Bridge::GetCurrentBridge();
172 auto v = mScene.GetRootLayer();
173 auto accessible = Accessibility::Accessible::Get( v, true );
174 bridge->AddTopLevelWindow( accessible );
176 //FIXME: line below is temporary solution for missing "activate" signal and should be removed
180 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
182 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
185 void Window::SetClass( std::string name, std::string className )
188 mClassName = className;
189 mWindowBase->SetClass( name, className );
192 std::string Window::GetClassName() const
199 mWindowBase->Raise();
201 mSurface->SetFullSwapNextFrame();
203 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
208 mWindowBase->Lower();
210 mSurface->SetFullSwapNextFrame();
212 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
215 void Window::Activate()
217 mWindowBase->Activate();
219 mSurface->SetFullSwapNextFrame();
221 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
224 uint32_t Window::GetLayerCount() const
226 return mScene.GetLayerCount();
229 Dali::Layer Window::GetLayer( uint32_t depth ) const
231 return mScene.GetLayer( depth );
234 Dali::RenderTaskList Window::GetRenderTaskList() const
236 return mScene.GetRenderTaskList();
239 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
241 if( IsOrientationAvailable( orientation ) == false )
247 int convertedAngle = ConvertToAngle( orientation );
248 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
249 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
251 if( mAvailableAngles[i] == convertedAngle )
260 mAvailableAngles.push_back( convertedAngle );
261 SetAvailableAnlges( mAvailableAngles );
265 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
267 if( IsOrientationAvailable( orientation ) == false )
272 int convertedAngle = ConvertToAngle( orientation );
273 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
274 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
275 iter != mAvailableAngles.end(); ++iter )
277 if( *iter == convertedAngle )
279 mAvailableAngles.erase( iter );
284 SetAvailableAnlges( mAvailableAngles );
287 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
289 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
291 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
294 mPreferredAngle = ConvertToAngle( orientation );
295 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
296 mWindowBase->SetPreferredAngle( mPreferredAngle );
299 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
301 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
302 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
303 return preferredOrientation;
306 void Window::SetAvailableAnlges( const std::vector< int >& angles )
308 if( angles.size() > 4 )
310 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
314 mWindowBase->SetAvailableAnlges( angles );
317 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
319 int convertAngle = static_cast< int >( orientation );
320 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
322 switch( orientation )
324 case Dali::Window::LANDSCAPE:
329 case Dali::Window::PORTRAIT:
334 case Dali::Window::LANDSCAPE_INVERSE:
339 case Dali::Window::PORTRAIT_INVERSE:
344 case Dali::Window::NO_ORIENTATION_PREFERENCE:
354 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
356 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
357 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
363 orientation = Dali::Window::LANDSCAPE;
368 orientation = Dali::Window::PORTRAIT;
373 orientation = Dali::Window::LANDSCAPE_INVERSE;
378 orientation = Dali::Window::PORTRAIT_INVERSE;
383 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
391 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
393 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
395 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
401 Dali::Any Window::GetNativeHandle() const
403 return mWindowSurface->GetNativeWindow();
406 void Window::SetAcceptFocus( bool accept )
408 mIsFocusAcceptable = accept;
410 mWindowBase->SetAcceptFocus( accept );
413 bool Window::IsFocusAcceptable() const
415 return mIsFocusAcceptable;
426 WindowVisibilityObserver* observer( mAdaptor );
427 observer->OnWindowShown();
429 Dali::Window handle( this );
430 mVisibilityChangedSignal.Emit( handle, true );
433 mSurface->SetFullSwapNextFrame();
435 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
446 WindowVisibilityObserver* observer( mAdaptor );
447 observer->OnWindowHidden();
449 Dali::Window handle( this );
450 mVisibilityChangedSignal.Emit( handle, false );
453 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
456 bool Window::IsVisible() const
458 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
459 return mVisible && !mIconified;
462 unsigned int Window::GetSupportedAuxiliaryHintCount() const
464 return mWindowBase->GetSupportedAuxiliaryHintCount();
467 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
469 return mWindowBase->GetSupportedAuxiliaryHint( index );
472 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
474 return mWindowBase->AddAuxiliaryHint( hint, value );
477 bool Window::RemoveAuxiliaryHint( unsigned int id )
479 return mWindowBase->RemoveAuxiliaryHint( id );
482 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
484 return mWindowBase->SetAuxiliaryHintValue( id, value );
487 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
489 return mWindowBase->GetAuxiliaryHintValue( id );
492 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
494 return mWindowBase->GetAuxiliaryHintId( hint );
497 void Window::SetInputRegion( const Rect< int >& inputRegion )
499 mWindowBase->SetInputRegion( inputRegion );
501 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 );
504 void Window::SetType( Dali::Window::Type type )
508 mWindowBase->SetType( type );
514 Dali::Window::Type Window::GetType() const
519 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
521 if( mType != Dali::Window::NOTIFICATION )
523 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
527 return mWindowBase->SetNotificationLevel( level );
530 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
532 if( mType != Dali::Window::NOTIFICATION )
534 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
535 return Dali::Window::NotificationLevel::NONE;
538 return mWindowBase->GetNotificationLevel();
541 void Window::SetOpaqueState( bool opaque )
543 mOpaqueState = opaque;
545 mWindowBase->SetOpaqueState( opaque );
547 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
550 bool Window::IsOpaqueState() const
555 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
557 return mWindowBase->SetScreenOffMode( screenOffMode );
560 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
562 return mWindowBase->GetScreenOffMode();
565 bool Window::SetBrightness( int brightness )
567 if( brightness < 0 || brightness > 100 )
569 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
573 return mWindowBase->SetBrightness( brightness );
576 int Window::GetBrightness() const
578 return mWindowBase->GetBrightness();
581 void Window::SetSize( Dali::Window::WindowSize size )
583 if( !mResizeEnabled )
585 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
586 mResizeEnabled = true;
589 PositionSize oldRect = mSurface->GetPositionSize();
591 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
593 PositionSize newRect = mSurface->GetPositionSize();
595 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
596 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
598 Uint16Pair newSize( newRect.width, newRect.height );
602 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
604 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
606 Dali::Window handle( this );
607 mResizeSignal.Emit( handle, newSize );
609 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
612 mSurface->SetFullSwapNextFrame();
615 Dali::Window::WindowSize Window::GetSize() const
617 PositionSize positionSize = mSurface->GetPositionSize();
619 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
622 void Window::SetPosition( Dali::Window::WindowPosition position )
624 if( !mResizeEnabled )
626 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
627 mResizeEnabled = true;
630 PositionSize oldRect = mSurface->GetPositionSize();
632 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
634 mSurface->SetFullSwapNextFrame();
637 Dali::Window::WindowPosition Window::GetPosition() const
639 PositionSize positionSize = mSurface->GetPositionSize();
641 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
644 void Window::SetPositionSize( PositionSize positionSize )
646 if( !mResizeEnabled )
648 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
649 mResizeEnabled = true;
652 PositionSize oldRect = mSurface->GetPositionSize();
654 mWindowSurface->MoveResize( positionSize );
656 PositionSize newRect = mSurface->GetPositionSize();
658 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
659 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
661 Uint16Pair newSize( newRect.width, newRect.height );
665 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
667 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
668 Dali::Window handle( this );
669 mResizeSignal.Emit( handle, newSize );
670 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
673 mSurface->SetFullSwapNextFrame();
676 Dali::Layer Window::GetRootLayer() const
678 return mScene.GetRootLayer();
681 void Window::SetTransparency( bool transparent )
683 mWindowSurface->SetTransparency( transparent );
686 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
688 return mWindowBase->GrabKey( key, grabMode );
691 bool Window::UngrabKey( Dali::KEY key )
693 return mWindowBase->UngrabKey( key );
696 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
698 return mWindowBase->GrabKeyList( key, grabMode, result );
701 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
703 return mWindowBase->UngrabKeyList( key, result );
706 void Window::OnIconifyChanged( bool iconified )
714 WindowVisibilityObserver* observer( mAdaptor );
715 observer->OnWindowHidden();
717 Dali::Window handle( this );
718 mVisibilityChangedSignal.Emit( handle, false );
721 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
729 WindowVisibilityObserver* observer( mAdaptor );
730 observer->OnWindowShown();
732 Dali::Window handle( this );
733 mVisibilityChangedSignal.Emit( handle, true );
736 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
739 mSurface->SetFullSwapNextFrame();
742 void Window::OnFocusChanged( bool focusIn )
744 Dali::Window handle( this );
745 mFocusChangeSignal.Emit( handle, focusIn );
747 mSurface->SetFullSwapNextFrame();
749 if (auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
753 b->ApplicationShown();
757 b->ApplicationHidden();
762 void Window::OnOutputTransformed()
764 PositionSize positionSize = mSurface->GetPositionSize();
766 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
767 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
770 void Window::OnDeleteRequest()
772 mDeleteRequestSignal.Emit();
775 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
777 Dali::Window handle( this );
778 mTransitionEffectEventSignal.Emit( handle, state, type );
781 void Window::OnKeyboardRepeatSettingsChanged()
783 Dali::Window handle( this );
784 mKeyboardRepeatSettingsChangedSignal.Emit();
787 void Window::OnWindowRedrawRequest()
789 mAdaptor->RenderOnce();
792 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
794 FeedTouchPoint( point, timeStamp );
797 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
799 FeedWheelEvent( wheelEvent );
802 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
804 FeedKeyEvent( keyEvent );
807 void Window::OnRotation( const RotationEvent& rotation )
809 mRotationAngle = rotation.angle;
810 mWindowWidth = rotation.width;
811 mWindowHeight = rotation.height;
813 // Notify that the orientation is changed
814 mOrientation->OnOrientationChange( rotation );
816 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
820 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
822 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
824 Dali::Window handle( this );
825 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
827 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
830 void Window::OnPause()
834 mEventHandler->Pause();
838 void Window::OnResume()
842 mEventHandler->Resume();
845 mSurface->SetFullSwapNextFrame();
848 void Window::RecalculateTouchPosition( Integration::Point& point )
850 Vector2 position = point.GetScreenPosition();
851 Vector2 convertedPosition;
853 switch( mRotationAngle )
857 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
858 convertedPosition.y = position.x;
863 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
864 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
869 convertedPosition.x = position.y;
870 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
875 convertedPosition = position;
880 point.SetScreenPosition( convertedPosition );
883 Dali::Window Window::Get( Dali::Actor actor )
885 Internal::Adaptor::Window* windowImpl = nullptr;
887 if ( Internal::Adaptor::Adaptor::IsAvailable() )
889 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
890 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
893 return Dali::Window( windowImpl );
897 return Dali::Window();
900 void Window::SetParent( Dali::Window& parent )
902 if ( DALI_UNLIKELY( parent ) )
904 mParentWindow = parent;
905 Dali::Window self = Dali::Window( this );
906 // check circular parent window setting
907 if ( Dali::DevelWindow::GetParent( parent ) == self )
909 Dali::DevelWindow::Unparent( parent );
911 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
915 void Window::Unparent()
917 mWindowBase->SetParent( nullptr );
918 mParentWindow.Reset();
921 Dali::Window Window::GetParent()
923 return mParentWindow;
926 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
928 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
929 return ConvertToOrientation( mRotationAngle );
932 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
934 Dali::Vector<float>::SizeType count = orientations.Count();
935 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
937 if( IsOrientationAvailable( orientations[index] ) == false )
939 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
944 int convertedAngle = ConvertToAngle( orientations[index] );
946 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
948 if( mAvailableAngles[i] == convertedAngle )
957 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
958 mAvailableAngles.push_back( convertedAngle );
961 SetAvailableAnlges( mAvailableAngles );
964 int32_t Window::GetNativeId() const
966 return mWindowBase->GetNativeWindowId();