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 mOrientation = Orientation::New( this );
138 // Get OrientationMode
139 int screenWidth, screenHeight;
140 WindowSystem::GetScreenSize( screenWidth, screenHeight );
141 if( screenWidth > screenHeight )
143 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
147 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
150 mNativeWindowId = mWindowBase->GetNativeWindowId();
153 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
155 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
156 mEventHandler->AddObserver( *this );
158 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
159 // The show must be called after the adaptor is initialized.
163 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
165 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
168 void Window::SetClass( std::string name, std::string className )
171 mClassName = className;
172 mWindowBase->SetClass( name, className );
175 std::string Window::GetClassName() const
182 mWindowBase->Raise();
184 mSurface->SetFullSwapNextFrame();
186 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
191 mWindowBase->Lower();
193 mSurface->SetFullSwapNextFrame();
195 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
198 void Window::Activate()
200 mWindowBase->Activate();
202 mSurface->SetFullSwapNextFrame();
204 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
207 uint32_t Window::GetLayerCount() const
209 return mScene.GetLayerCount();
212 Dali::Layer Window::GetLayer( uint32_t depth ) const
214 return mScene.GetLayer( depth );
217 Dali::RenderTaskList Window::GetRenderTaskList() const
219 return mScene.GetRenderTaskList();
222 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
224 if( IsOrientationAvailable( orientation ) == false )
230 int convertedAngle = ConvertToAngle( orientation );
231 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
232 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
234 if( mAvailableAngles[i] == convertedAngle )
243 mAvailableAngles.push_back( convertedAngle );
244 SetAvailableAnlges( mAvailableAngles );
248 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
250 if( IsOrientationAvailable( orientation ) == false )
255 int convertedAngle = ConvertToAngle( orientation );
256 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
257 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
258 iter != mAvailableAngles.end(); ++iter )
260 if( *iter == convertedAngle )
262 mAvailableAngles.erase( iter );
267 SetAvailableAnlges( mAvailableAngles );
270 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
272 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
274 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
277 mPreferredAngle = ConvertToAngle( orientation );
278 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
279 mWindowBase->SetPreferredAngle( mPreferredAngle );
282 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
284 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
285 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
286 return preferredOrientation;
289 void Window::SetAvailableAnlges( const std::vector< int >& angles )
291 if( angles.size() > 4 )
293 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
297 mWindowBase->SetAvailableAnlges( angles );
300 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
302 int convertAngle = static_cast< int >( orientation );
303 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
305 switch( orientation )
307 case Dali::Window::LANDSCAPE:
312 case Dali::Window::PORTRAIT:
317 case Dali::Window::LANDSCAPE_INVERSE:
322 case Dali::Window::PORTRAIT_INVERSE:
327 case Dali::Window::NO_ORIENTATION_PREFERENCE:
337 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
339 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
340 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
346 orientation = Dali::Window::LANDSCAPE;
351 orientation = Dali::Window::PORTRAIT;
356 orientation = Dali::Window::LANDSCAPE_INVERSE;
361 orientation = Dali::Window::PORTRAIT_INVERSE;
366 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
374 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
376 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
378 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
384 Dali::Any Window::GetNativeHandle() const
386 return mWindowSurface->GetNativeWindow();
389 void Window::SetAcceptFocus( bool accept )
391 mIsFocusAcceptable = accept;
393 mWindowBase->SetAcceptFocus( accept );
396 bool Window::IsFocusAcceptable() const
398 return mIsFocusAcceptable;
409 WindowVisibilityObserver* observer( mAdaptor );
410 observer->OnWindowShown();
412 Dali::Window handle( this );
413 mVisibilityChangedSignal.Emit( handle, true );
416 mSurface->SetFullSwapNextFrame();
418 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
429 WindowVisibilityObserver* observer( mAdaptor );
430 observer->OnWindowHidden();
432 Dali::Window handle( this );
433 mVisibilityChangedSignal.Emit( handle, false );
436 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
439 bool Window::IsVisible() const
441 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
442 return mVisible && !mIconified;
445 unsigned int Window::GetSupportedAuxiliaryHintCount() const
447 return mWindowBase->GetSupportedAuxiliaryHintCount();
450 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
452 return mWindowBase->GetSupportedAuxiliaryHint( index );
455 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
457 return mWindowBase->AddAuxiliaryHint( hint, value );
460 bool Window::RemoveAuxiliaryHint( unsigned int id )
462 return mWindowBase->RemoveAuxiliaryHint( id );
465 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
467 return mWindowBase->SetAuxiliaryHintValue( id, value );
470 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
472 return mWindowBase->GetAuxiliaryHintValue( id );
475 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
477 return mWindowBase->GetAuxiliaryHintId( hint );
480 void Window::SetInputRegion( const Rect< int >& inputRegion )
482 mWindowBase->SetInputRegion( inputRegion );
484 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 );
487 void Window::SetType( Dali::Window::Type type )
491 mWindowBase->SetType( type );
497 Dali::Window::Type Window::GetType() const
502 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
504 if( mType != Dali::Window::NOTIFICATION )
506 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
510 return mWindowBase->SetNotificationLevel( level );
513 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
515 if( mType != Dali::Window::NOTIFICATION )
517 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
518 return Dali::Window::NotificationLevel::NONE;
521 return mWindowBase->GetNotificationLevel();
524 void Window::SetOpaqueState( bool opaque )
526 mOpaqueState = opaque;
528 mWindowBase->SetOpaqueState( opaque );
530 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
533 bool Window::IsOpaqueState() const
538 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
540 return mWindowBase->SetScreenOffMode( screenOffMode );
543 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
545 return mWindowBase->GetScreenOffMode();
548 bool Window::SetBrightness( int brightness )
550 if( brightness < 0 || brightness > 100 )
552 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
556 return mWindowBase->SetBrightness( brightness );
559 int Window::GetBrightness() const
561 return mWindowBase->GetBrightness();
564 void Window::SetSize( Dali::Window::WindowSize size )
566 if( !mResizeEnabled )
568 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
569 mResizeEnabled = true;
572 PositionSize oldRect = mSurface->GetPositionSize();
574 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
576 PositionSize newRect = mSurface->GetPositionSize();
578 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
579 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
581 Uint16Pair newSize( newRect.width, newRect.height );
583 bool forceUpdate = false;
584 if( mWindowBase->IsEglWindowRotationSupported() )
589 SurfaceResized( forceUpdate );
591 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
593 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
595 Dali::Window handle( this );
596 mResizeSignal.Emit( handle, newSize );
598 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
601 mSurface->SetFullSwapNextFrame();
604 Dali::Window::WindowSize Window::GetSize() const
606 PositionSize positionSize = mSurface->GetPositionSize();
608 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
611 void Window::SetPosition( Dali::Window::WindowPosition position )
613 if( !mResizeEnabled )
615 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
616 mResizeEnabled = true;
619 PositionSize oldRect = mSurface->GetPositionSize();
621 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
623 mSurface->SetFullSwapNextFrame();
626 Dali::Window::WindowPosition Window::GetPosition() const
628 PositionSize positionSize = mSurface->GetPositionSize();
630 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
633 void Window::SetPositionSize( PositionSize positionSize )
635 if( !mResizeEnabled )
637 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
638 mResizeEnabled = true;
641 PositionSize oldRect = mSurface->GetPositionSize();
643 mWindowSurface->MoveResize( positionSize );
645 PositionSize newRect = mSurface->GetPositionSize();
647 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
648 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
650 Uint16Pair newSize( newRect.width, newRect.height );
652 bool forceUpdate = false;
653 if( mWindowBase->IsEglWindowRotationSupported() )
658 SurfaceResized( forceUpdate );
660 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
662 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
663 Dali::Window handle( this );
664 mResizeSignal.Emit( handle, newSize );
665 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
668 mSurface->SetFullSwapNextFrame();
671 Dali::Layer Window::GetRootLayer() const
673 return mScene.GetRootLayer();
676 void Window::SetTransparency( bool transparent )
678 mWindowSurface->SetTransparency( transparent );
681 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
683 return mWindowBase->GrabKey( key, grabMode );
686 bool Window::UngrabKey( Dali::KEY key )
688 return mWindowBase->UngrabKey( key );
691 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
693 return mWindowBase->GrabKeyList( key, grabMode, result );
696 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
698 return mWindowBase->UngrabKeyList( key, result );
701 void Window::OnIconifyChanged( bool iconified )
709 WindowVisibilityObserver* observer( mAdaptor );
710 observer->OnWindowHidden();
712 Dali::Window handle( this );
713 mVisibilityChangedSignal.Emit( handle, false );
716 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
724 WindowVisibilityObserver* observer( mAdaptor );
725 observer->OnWindowShown();
727 Dali::Window handle( this );
728 mVisibilityChangedSignal.Emit( handle, true );
731 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
734 mSurface->SetFullSwapNextFrame();
737 void Window::OnFocusChanged( bool focusIn )
739 Dali::Window handle( this );
740 mFocusChangeSignal.Emit( handle, focusIn );
742 mSurface->SetFullSwapNextFrame();
745 void Window::OnOutputTransformed()
747 bool forceUpdate = false;
748 if( mWindowBase->IsEglWindowRotationSupported() )
752 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnOutputTransformed()\n", this, mNativeWindowId );
753 SurfaceResized( forceUpdate );
755 PositionSize positionSize = mSurface->GetPositionSize();
756 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
757 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
760 void Window::OnDeleteRequest()
762 mDeleteRequestSignal.Emit();
765 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
767 Dali::Window handle( this );
768 mTransitionEffectEventSignal.Emit( handle, state, type );
771 void Window::OnKeyboardRepeatSettingsChanged()
773 Dali::Window handle( this );
774 mKeyboardRepeatSettingsChangedSignal.Emit();
777 void Window::OnWindowRedrawRequest()
779 mAdaptor->RenderOnce();
782 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
784 FeedTouchPoint( point, timeStamp );
787 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
789 FeedWheelEvent( wheelEvent );
792 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
794 FeedKeyEvent( keyEvent );
797 void Window::OnRotation( const RotationEvent& rotation )
799 mRotationAngle = rotation.angle;
800 mWindowWidth = rotation.width;
801 mWindowHeight = rotation.height;
803 // Notify that the orientation is changed
804 mOrientation->OnOrientationChange( rotation );
806 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
808 bool forceUpdate = false;
809 if( mWindowBase->IsEglWindowRotationSupported() )
814 SurfaceResized( forceUpdate );
816 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
818 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
820 Dali::Window handle( this );
821 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
823 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
826 void Window::OnPause()
830 mEventHandler->Pause();
834 void Window::OnResume()
838 mEventHandler->Resume();
841 mSurface->SetFullSwapNextFrame();
844 void Window::RecalculateTouchPosition( Integration::Point& point )
846 Vector2 position = point.GetScreenPosition();
847 Vector2 convertedPosition;
849 switch( mRotationAngle )
853 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
854 convertedPosition.y = position.x;
859 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
860 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
865 convertedPosition.x = position.y;
866 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
871 convertedPosition = position;
876 point.SetScreenPosition( convertedPosition );
879 Dali::Window Window::Get( Dali::Actor actor )
881 Internal::Adaptor::Window* windowImpl = nullptr;
883 if ( Internal::Adaptor::Adaptor::IsAvailable() )
885 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
886 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
889 return Dali::Window( windowImpl );
893 return Dali::Window();
896 void Window::SetParent( Dali::Window& parent )
898 if ( DALI_UNLIKELY( parent ) )
900 mParentWindow = parent;
901 Dali::Window self = Dali::Window( this );
902 // check circular parent window setting
903 if ( Dali::DevelWindow::GetParent( parent ) == self )
905 Dali::DevelWindow::Unparent( parent );
907 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
911 void Window::Unparent()
913 mWindowBase->SetParent( nullptr );
914 mParentWindow.Reset();
917 Dali::Window Window::GetParent()
919 return mParentWindow;
922 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
924 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
925 return ConvertToOrientation( mRotationAngle );
928 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
930 Dali::Vector<float>::SizeType count = orientations.Count();
931 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
933 if( IsOrientationAvailable( orientations[index] ) == false )
935 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
940 int convertedAngle = ConvertToAngle( orientations[index] );
942 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
944 if( mAvailableAngles[i] == convertedAngle )
953 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
954 mAvailableAngles.push_back( convertedAngle );
957 SetAvailableAnlges( mAvailableAngles );
960 int32_t Window::GetNativeId() const
962 return mWindowBase->GetNativeWindowId();