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/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/devel-api/adaptor-framework/orientation.h>
32 #include <dali/integration-api/events/touch-event-integ.h>
35 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
36 #include <dali/internal/graphics/gles/egl-graphics.h>
37 #include <dali/internal/window-system/common/event-handler.h>
38 #include <dali/internal/window-system/common/orientation-impl.h>
39 #include <dali/internal/window-system/common/render-surface-factory.h>
40 #include <dali/internal/window-system/common/window-factory.h>
41 #include <dali/internal/window-system/common/window-base.h>
42 #include <dali/internal/window-system/common/window-system.h>
43 #include <dali/internal/window-system/common/window-render-surface.h>
44 #include <dali/internal/window-system/common/window-visibility-observer.h>
45 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
57 #if defined(DEBUG_ENABLED)
58 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
61 } // unnamed namespace
63 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
66 return Window::New(surface, positionSize, name, className, isTransparent);
69 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
71 Window* window = new Window();
72 window->mIsTransparent = isTransparent;
73 window->Initialize(surface, positionSize, name, className);
78 : mWindowSurface(nullptr),
80 mIsTransparent( false ),
81 mIsFocusAcceptable( true ),
83 mOpaqueState( false ),
84 mResizeEnabled( false ),
85 mType( WindowType::NORMAL ),
86 mParentWindow( NULL ),
87 mPreferredAngle( static_cast< int >( WindowOrientation::NO_ORIENTATION_PREFERENCE ) ),
91 mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
92 mNativeWindowId( -1 ),
93 mDeleteRequestSignal(),
96 mVisibilityChangedSignal(),
97 mTransitionEffectEventSignal(),
98 mKeyboardRepeatSettingsChangedSignal()
106 auto bridge = Accessibility::Bridge::GetCurrentBridge();
107 auto accessible2 = mScene.GetRootLayer();
108 auto accessible = Accessibility::Accessible::Get( accessible2 );
109 bridge->RemoveTopLevelWindow( accessible );
111 mAdaptor->RemoveWindow( this );
116 mEventHandler->RemoveObserver( *this );
120 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
122 // Create a window render surface
123 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
124 mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
125 mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
128 mWindowBase = mWindowSurface->GetWindowBase();
131 mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
132 mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
133 mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
134 mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
135 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
136 mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
138 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
140 if( !positionSize.IsEmpty() )
142 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
143 mResizeEnabled = true;
146 SetClass( name, className );
148 mWindowSurface->Map();
150 mOrientation = Orientation::New( this );
152 // Get OrientationMode
153 int screenWidth, screenHeight;
154 WindowSystem::GetScreenSize( screenWidth, screenHeight );
155 if( screenWidth > screenHeight )
157 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
161 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
164 mNativeWindowId = mWindowBase->GetNativeWindowId();
167 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
169 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
170 mEventHandler->AddObserver( *this );
172 auto bridge = Accessibility::Bridge::GetCurrentBridge();
173 auto v = mScene.GetRootLayer();
174 auto accessible = Accessibility::Accessible::Get( v, true );
175 bridge->AddTopLevelWindow( accessible );
177 //FIXME: line below is temporary solution for missing "activate" signal and should be removed
181 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
183 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
186 void Window::SetClass( std::string name, std::string className )
189 mClassName = className;
190 mWindowBase->SetClass( name, className );
193 std::string Window::GetClassName() const
200 mWindowBase->Raise();
202 mSurface->SetFullSwapNextFrame();
204 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
209 mWindowBase->Lower();
211 mSurface->SetFullSwapNextFrame();
213 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
216 void Window::Activate()
218 mWindowBase->Activate();
220 mSurface->SetFullSwapNextFrame();
222 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
225 uint32_t Window::GetLayerCount() const
227 return mScene.GetLayerCount();
230 Dali::Layer Window::GetLayer( uint32_t depth ) const
232 return mScene.GetLayer( depth );
235 Dali::RenderTaskList Window::GetRenderTaskList() const
237 return mScene.GetRenderTaskList();
240 void Window::AddAvailableOrientation( WindowOrientation orientation )
242 if( IsOrientationAvailable( orientation ) == false )
248 int convertedAngle = ConvertToAngle( orientation );
249 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
250 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
252 if( mAvailableAngles[i] == convertedAngle )
261 mAvailableAngles.push_back( convertedAngle );
262 SetAvailableAnlges( mAvailableAngles );
266 void Window::RemoveAvailableOrientation( WindowOrientation orientation )
268 if( IsOrientationAvailable( orientation ) == false )
273 int convertedAngle = ConvertToAngle( orientation );
274 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
275 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
276 iter != mAvailableAngles.end(); ++iter )
278 if( *iter == convertedAngle )
280 mAvailableAngles.erase( iter );
285 SetAvailableAnlges( mAvailableAngles );
288 void Window::SetPreferredOrientation( WindowOrientation orientation )
290 if( orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
292 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
295 mPreferredAngle = ConvertToAngle( orientation );
296 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
297 mWindowBase->SetPreferredAngle( mPreferredAngle );
300 WindowOrientation Window::GetPreferredOrientation()
302 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
303 WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
304 return preferredOrientation;
307 void Window::SetAvailableAnlges( const std::vector< int >& angles )
309 if( angles.size() > 4 )
311 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
315 mWindowBase->SetAvailableAnlges( angles );
318 int Window::ConvertToAngle( WindowOrientation orientation )
320 int convertAngle = static_cast< int >( orientation );
321 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
323 switch( orientation )
325 case WindowOrientation::LANDSCAPE:
330 case WindowOrientation::PORTRAIT:
335 case WindowOrientation::LANDSCAPE_INVERSE:
340 case WindowOrientation::PORTRAIT_INVERSE:
345 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
355 WindowOrientation Window::ConvertToOrientation( int angle ) const
357 WindowOrientation orientation = static_cast< WindowOrientation >( angle );
358 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
364 orientation = WindowOrientation::LANDSCAPE;
369 orientation = WindowOrientation::PORTRAIT;
374 orientation = WindowOrientation::LANDSCAPE_INVERSE;
379 orientation = WindowOrientation::PORTRAIT_INVERSE;
384 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
392 bool Window::IsOrientationAvailable( WindowOrientation orientation ) const
394 if( orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
396 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
402 Dali::Any Window::GetNativeHandle() const
404 return mWindowSurface->GetNativeWindow();
407 void Window::SetAcceptFocus( bool accept )
409 mIsFocusAcceptable = accept;
411 mWindowBase->SetAcceptFocus( accept );
414 bool Window::IsFocusAcceptable() const
416 return mIsFocusAcceptable;
427 WindowVisibilityObserver* observer( mAdaptor );
428 observer->OnWindowShown();
430 Dali::Window handle( this );
431 mVisibilityChangedSignal.Emit( handle, true );
434 mSurface->SetFullSwapNextFrame();
436 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
447 WindowVisibilityObserver* observer( mAdaptor );
448 observer->OnWindowHidden();
450 Dali::Window handle( this );
451 mVisibilityChangedSignal.Emit( handle, false );
454 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
457 bool Window::IsVisible() const
459 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
460 return mVisible && !mIconified;
463 unsigned int Window::GetSupportedAuxiliaryHintCount() const
465 return mWindowBase->GetSupportedAuxiliaryHintCount();
468 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
470 return mWindowBase->GetSupportedAuxiliaryHint( index );
473 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
475 return mWindowBase->AddAuxiliaryHint( hint, value );
478 bool Window::RemoveAuxiliaryHint( unsigned int id )
480 return mWindowBase->RemoveAuxiliaryHint( id );
483 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
485 return mWindowBase->SetAuxiliaryHintValue( id, value );
488 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
490 return mWindowBase->GetAuxiliaryHintValue( id );
493 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
495 return mWindowBase->GetAuxiliaryHintId( hint );
498 void Window::SetInputRegion( const Rect< int >& inputRegion )
500 mWindowBase->SetInputRegion( inputRegion );
502 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 );
505 void Window::SetType( WindowType type )
509 mWindowBase->SetType( type );
515 WindowType Window::GetType() const
520 bool Window::SetNotificationLevel( WindowNotificationLevel level )
522 if( mType != WindowType::NOTIFICATION )
524 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
528 return mWindowBase->SetNotificationLevel( level );
531 WindowNotificationLevel Window::GetNotificationLevel() const
533 if( mType != WindowType::NOTIFICATION )
535 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
536 return WindowNotificationLevel::NONE;
539 return mWindowBase->GetNotificationLevel();
542 void Window::SetOpaqueState( bool opaque )
544 mOpaqueState = opaque;
546 mWindowBase->SetOpaqueState( opaque );
548 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
551 bool Window::IsOpaqueState() const
556 bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
558 return mWindowBase->SetScreenOffMode( screenOffMode );
561 WindowScreenOffMode Window::GetScreenOffMode() const
563 return mWindowBase->GetScreenOffMode();
566 bool Window::SetBrightness( int brightness )
568 if( brightness < 0 || brightness > 100 )
570 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
574 return mWindowBase->SetBrightness( brightness );
577 int Window::GetBrightness() const
579 return mWindowBase->GetBrightness();
582 void Window::SetSize( Dali::Window::WindowSize size )
584 if( !mResizeEnabled )
586 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
587 mResizeEnabled = true;
590 PositionSize oldRect = mSurface->GetPositionSize();
592 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
594 PositionSize newRect = mSurface->GetPositionSize();
596 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
597 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
599 Uint16Pair newSize( newRect.width, newRect.height );
603 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
605 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
607 Dali::Window handle( this );
608 mResizeSignal.Emit( handle, newSize );
610 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
613 mSurface->SetFullSwapNextFrame();
616 Dali::Window::WindowSize Window::GetSize() const
618 PositionSize positionSize = mSurface->GetPositionSize();
620 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
623 void Window::SetPosition( Dali::Window::WindowPosition position )
625 if( !mResizeEnabled )
627 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
628 mResizeEnabled = true;
631 PositionSize oldRect = mSurface->GetPositionSize();
633 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
635 mSurface->SetFullSwapNextFrame();
638 Dali::Window::WindowPosition Window::GetPosition() const
640 PositionSize positionSize = mSurface->GetPositionSize();
642 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
645 void Window::SetPositionSize( PositionSize positionSize )
647 if( !mResizeEnabled )
649 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
650 mResizeEnabled = true;
653 PositionSize oldRect = mSurface->GetPositionSize();
655 mWindowSurface->MoveResize( positionSize );
657 PositionSize newRect = mSurface->GetPositionSize();
659 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
660 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
662 Uint16Pair newSize( newRect.width, newRect.height );
666 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
668 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
669 Dali::Window handle( this );
670 mResizeSignal.Emit( handle, newSize );
671 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
674 mSurface->SetFullSwapNextFrame();
677 Dali::Layer Window::GetRootLayer() const
679 return mScene.GetRootLayer();
682 void Window::SetTransparency( bool transparent )
684 mWindowSurface->SetTransparency( transparent );
687 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
689 return mWindowBase->GrabKey( key, grabMode );
692 bool Window::UngrabKey( Dali::KEY key )
694 return mWindowBase->UngrabKey( key );
697 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
699 return mWindowBase->GrabKeyList( key, grabMode, result );
702 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
704 return mWindowBase->UngrabKeyList( key, result );
707 void Window::OnIconifyChanged( bool iconified )
715 WindowVisibilityObserver* observer( mAdaptor );
716 observer->OnWindowHidden();
718 Dali::Window handle( this );
719 mVisibilityChangedSignal.Emit( handle, false );
722 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
730 WindowVisibilityObserver* observer( mAdaptor );
731 observer->OnWindowShown();
733 Dali::Window handle( this );
734 mVisibilityChangedSignal.Emit( handle, true );
737 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
740 mSurface->SetFullSwapNextFrame();
743 void Window::OnFocusChanged( bool focusIn )
745 Dali::Window handle( this );
746 mFocusChangeSignal.Emit( handle, focusIn );
748 mSurface->SetFullSwapNextFrame();
750 if (auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
754 b->ApplicationShown();
758 b->ApplicationHidden();
763 void Window::OnOutputTransformed()
765 PositionSize positionSize = mSurface->GetPositionSize();
767 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
768 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
770 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
771 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
774 void Window::OnDeleteRequest()
776 mDeleteRequestSignal.Emit();
779 void Window::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
781 Dali::Window handle( this );
782 mTransitionEffectEventSignal.Emit( handle, state, type );
785 void Window::OnKeyboardRepeatSettingsChanged()
787 Dali::Window handle( this );
788 mKeyboardRepeatSettingsChangedSignal.Emit();
791 void Window::OnWindowRedrawRequest()
793 mAdaptor->RenderOnce();
796 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
798 FeedTouchPoint( point, timeStamp );
801 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
803 FeedWheelEvent( wheelEvent );
806 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
808 FeedKeyEvent( keyEvent );
811 void Window::OnRotation(const RotationEvent& rotation)
813 mRotationAngle = rotation.angle;
814 mWindowWidth = rotation.width;
815 mWindowHeight = rotation.height;
817 // Notify that the orientation is changed
818 mOrientation->OnOrientationChange(rotation);
820 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
822 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
823 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
825 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
827 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
829 Dali::Window handle(this);
830 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
832 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
835 void Window::OnPause()
839 mEventHandler->Pause();
843 void Window::OnResume()
847 mEventHandler->Resume();
850 mSurface->SetFullSwapNextFrame();
853 void Window::RecalculateTouchPosition( Integration::Point& point )
855 Vector2 position = point.GetScreenPosition();
856 Vector2 convertedPosition;
858 switch( mRotationAngle )
862 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
863 convertedPosition.y = position.x;
868 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
869 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
874 convertedPosition.x = position.y;
875 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
880 convertedPosition = position;
885 point.SetScreenPosition( convertedPosition );
888 Dali::Window Window::Get( Dali::Actor actor )
890 Internal::Adaptor::Window* windowImpl = nullptr;
892 if ( Internal::Adaptor::Adaptor::IsAvailable() )
894 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
895 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
898 return Dali::Window( windowImpl );
902 return Dali::Window();
905 void Window::SetParent( Dali::Window& parent )
907 if ( DALI_UNLIKELY( parent ) )
909 mParentWindow = parent;
910 Dali::Window self = Dali::Window( this );
911 // check circular parent window setting
912 if ( Dali::DevelWindow::GetParent( parent ) == self )
914 Dali::DevelWindow::Unparent( parent );
916 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
920 void Window::Unparent()
922 mWindowBase->SetParent( nullptr );
923 mParentWindow.Reset();
926 Dali::Window Window::GetParent()
928 return mParentWindow;
931 WindowOrientation Window::GetCurrentOrientation() const
933 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
934 return ConvertToOrientation( mRotationAngle );
937 void Window::SetAvailableOrientations( const Dali::Vector<WindowOrientation>& orientations )
939 Dali::Vector<float>::SizeType count = orientations.Count();
940 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
942 if( IsOrientationAvailable( orientations[index] ) == false )
944 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
949 int convertedAngle = ConvertToAngle( orientations[index] );
951 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
953 if( mAvailableAngles[i] == convertedAngle )
962 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
963 mAvailableAngles.push_back( convertedAngle );
966 SetAvailableAnlges( mAvailableAngles );
969 int32_t Window::GetNativeId() const
971 return mWindowBase->GetNativeWindowId();