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 ),
92 mDeleteRequestSignal(),
95 mVisibilityChangedSignal(),
96 mTransitionEffectEventSignal()
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 );
124 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
126 if( !positionSize.IsEmpty() )
128 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
129 mResizeEnabled = true;
132 SetClass( name, className );
134 mWindowSurface->Map();
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, *mAdaptor ) );
156 mEventHandler->AddObserver( *this );
159 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
161 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
164 void Window::SetClass( std::string name, std::string className )
167 mClassName = className;
168 mWindowBase->SetClass( name, className );
171 std::string Window::GetClassName() const
178 mWindowBase->Raise();
180 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
181 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
184 eglGraphics->SetFullSwapNextFrame();
187 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
192 mWindowBase->Lower();
194 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
195 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
198 eglGraphics->SetFullSwapNextFrame();
201 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
204 void Window::Activate()
206 mWindowBase->Activate();
208 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
209 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
212 eglGraphics->SetFullSwapNextFrame();
215 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
218 uint32_t Window::GetLayerCount() const
220 return mScene.GetLayerCount();
223 Dali::Layer Window::GetLayer( uint32_t depth ) const
225 return mScene.GetLayer( depth );
228 Dali::RenderTaskList Window::GetRenderTaskList() const
230 return mScene.GetRenderTaskList();
233 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
235 if( IsOrientationAvailable( orientation ) == false )
241 int convertedAngle = ConvertToAngle( orientation );
242 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
243 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
245 if( mAvailableAngles[i] == convertedAngle )
254 mAvailableAngles.push_back( convertedAngle );
255 SetAvailableAnlges( mAvailableAngles );
259 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
261 if( IsOrientationAvailable( orientation ) == false )
266 int convertedAngle = ConvertToAngle( orientation );
267 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
268 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
269 iter != mAvailableAngles.end(); ++iter )
271 if( *iter == convertedAngle )
273 mAvailableAngles.erase( iter );
278 SetAvailableAnlges( mAvailableAngles );
281 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
283 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
285 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
288 mPreferredAngle = ConvertToAngle( orientation );
289 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
290 mWindowBase->SetPreferredAngle( mPreferredAngle );
293 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
295 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
296 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
297 return preferredOrientation;
300 void Window::SetAvailableAnlges( const std::vector< int >& angles )
302 if( angles.size() > 4 )
304 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
308 mWindowBase->SetAvailableAnlges( angles );
311 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
313 int convertAngle = static_cast< int >( orientation );
314 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
316 switch( orientation )
318 case Dali::Window::LANDSCAPE:
323 case Dali::Window::PORTRAIT:
328 case Dali::Window::LANDSCAPE_INVERSE:
333 case Dali::Window::PORTRAIT_INVERSE:
338 case Dali::Window::NO_ORIENTATION_PREFERENCE:
348 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
350 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
351 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
357 orientation = Dali::Window::LANDSCAPE;
362 orientation = Dali::Window::PORTRAIT;
367 orientation = Dali::Window::LANDSCAPE_INVERSE;
372 orientation = Dali::Window::PORTRAIT_INVERSE;
377 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
385 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
387 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
389 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
395 Dali::Any Window::GetNativeHandle() const
397 return mWindowSurface->GetNativeWindow();
400 void Window::SetAcceptFocus( bool accept )
402 mIsFocusAcceptable = accept;
404 mWindowBase->SetAcceptFocus( accept );
407 bool Window::IsFocusAcceptable() const
409 return mIsFocusAcceptable;
420 WindowVisibilityObserver* observer( mAdaptor );
421 observer->OnWindowShown();
423 Dali::Window handle( this );
424 mVisibilityChangedSignal.Emit( handle, true );
427 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
428 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
431 eglGraphics->SetFullSwapNextFrame();
434 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
445 WindowVisibilityObserver* observer( mAdaptor );
446 observer->OnWindowHidden();
448 Dali::Window handle( this );
449 mVisibilityChangedSignal.Emit( handle, false );
453 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
454 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
457 eglGraphics->SetFullSwapNextFrame();
460 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
463 bool Window::IsVisible() const
465 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
466 return mVisible && !mIconified;
469 unsigned int Window::GetSupportedAuxiliaryHintCount() const
471 return mWindowBase->GetSupportedAuxiliaryHintCount();
474 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
476 return mWindowBase->GetSupportedAuxiliaryHint( index );
479 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
481 return mWindowBase->AddAuxiliaryHint( hint, value );
484 bool Window::RemoveAuxiliaryHint( unsigned int id )
486 return mWindowBase->RemoveAuxiliaryHint( id );
489 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
491 return mWindowBase->SetAuxiliaryHintValue( id, value );
494 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
496 return mWindowBase->GetAuxiliaryHintValue( id );
499 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
501 return mWindowBase->GetAuxiliaryHintId( hint );
504 void Window::SetInputRegion( const Rect< int >& inputRegion )
506 mWindowBase->SetInputRegion( inputRegion );
508 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
509 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
512 eglGraphics->SetFullSwapNextFrame();
515 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 );
518 void Window::SetType( Dali::Window::Type type )
522 mWindowBase->SetType( type );
528 Dali::Window::Type Window::GetType() const
533 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
535 if( mType != Dali::Window::NOTIFICATION )
537 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
541 return mWindowBase->SetNotificationLevel( level );
544 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
546 if( mType != Dali::Window::NOTIFICATION )
548 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
549 return Dali::Window::NotificationLevel::NONE;
552 return mWindowBase->GetNotificationLevel();
555 void Window::SetOpaqueState( bool opaque )
557 mOpaqueState = opaque;
559 mWindowBase->SetOpaqueState( opaque );
561 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
564 bool Window::IsOpaqueState() const
569 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
571 return mWindowBase->SetScreenOffMode( screenOffMode );
574 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
576 return mWindowBase->GetScreenOffMode();
579 bool Window::SetBrightness( int brightness )
581 if( brightness < 0 || brightness > 100 )
583 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
587 return mWindowBase->SetBrightness( brightness );
590 int Window::GetBrightness() const
592 return mWindowBase->GetBrightness();
595 void Window::SetSize( Dali::Window::WindowSize size )
597 if( !mResizeEnabled )
599 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
600 mResizeEnabled = true;
603 PositionSize oldRect = mSurface->GetPositionSize();
605 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
607 PositionSize newRect = mSurface->GetPositionSize();
609 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
610 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
612 Uint16Pair newSize( newRect.width, newRect.height );
616 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
618 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
620 Dali::Window handle( this );
621 mResizedSignal.Emit( newSize );
622 mResizeSignal.Emit( handle, newSize );
624 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
627 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
628 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
631 eglGraphics->SetFullSwapNextFrame();
635 Dali::Window::WindowSize Window::GetSize() const
637 PositionSize positionSize = mSurface->GetPositionSize();
639 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
642 void Window::SetPosition( Dali::Window::WindowPosition position )
644 if( !mResizeEnabled )
646 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
647 mResizeEnabled = true;
650 PositionSize oldRect = mSurface->GetPositionSize();
652 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
654 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
655 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
658 eglGraphics->SetFullSwapNextFrame();
662 Dali::Window::WindowPosition Window::GetPosition() const
664 PositionSize positionSize = mSurface->GetPositionSize();
666 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
669 void Window::SetPositionSize( PositionSize positionSize )
671 if( !mResizeEnabled )
673 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
674 mResizeEnabled = true;
677 PositionSize oldRect = mSurface->GetPositionSize();
679 mWindowSurface->MoveResize( positionSize );
681 PositionSize newRect = mSurface->GetPositionSize();
683 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
684 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
686 Uint16Pair newSize( newRect.width, newRect.height );
690 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
692 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
693 Dali::Window handle( this );
694 mResizedSignal.Emit( newSize );
695 mResizeSignal.Emit( handle, newSize );
696 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
699 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
700 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
703 eglGraphics->SetFullSwapNextFrame();
707 Dali::Layer Window::GetRootLayer() const
709 return mScene.GetRootLayer();
712 void Window::SetTransparency( bool transparent )
714 mWindowSurface->SetTransparency( transparent );
717 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
719 return mWindowBase->GrabKey( key, grabMode );
722 bool Window::UngrabKey( Dali::KEY key )
724 return mWindowBase->UngrabKey( key );
727 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
729 return mWindowBase->GrabKeyList( key, grabMode, result );
732 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
734 return mWindowBase->UngrabKeyList( key, result );
737 void Window::OnIconifyChanged( bool iconified )
745 WindowVisibilityObserver* observer( mAdaptor );
746 observer->OnWindowHidden();
748 Dali::Window handle( this );
749 mVisibilityChangedSignal.Emit( handle, false );
752 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
760 WindowVisibilityObserver* observer( mAdaptor );
761 observer->OnWindowShown();
763 Dali::Window handle( this );
764 mVisibilityChangedSignal.Emit( handle, true );
767 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
770 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
771 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
774 eglGraphics->SetFullSwapNextFrame();
778 void Window::OnFocusChanged( bool focusIn )
780 Dali::Window handle( this );
781 mFocusChangeSignal.Emit( handle, focusIn );
783 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
784 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
787 eglGraphics->SetFullSwapNextFrame();
791 void Window::OnOutputTransformed()
793 PositionSize positionSize = mSurface->GetPositionSize();
795 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
796 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
799 void Window::OnDeleteRequest()
801 mDeleteRequestSignal.Emit();
804 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
806 Dali::Window handle( this );
807 mTransitionEffectEventSignal.Emit( handle, state, type );
810 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
812 FeedTouchPoint( point, timeStamp );
815 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
817 FeedWheelEvent( wheelEvent );
820 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
822 FeedKeyEvent( keyEvent );
825 void Window::OnRotation( const RotationEvent& rotation )
827 mRotationAngle = rotation.angle;
828 mWindowWidth = rotation.width;
829 mWindowHeight = rotation.height;
831 // Notify that the orientation is changed
832 mOrientation->OnOrientationChange( rotation );
834 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
838 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
840 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
842 Dali::Window handle( this );
843 mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
844 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
846 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
849 void Window::OnPause()
853 mEventHandler->Pause();
856 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
857 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
860 eglGraphics->SetFullSwapNextFrame();
864 void Window::OnResume()
868 mEventHandler->Resume();
871 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
872 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
875 eglGraphics->SetFullSwapNextFrame();
879 void Window::RecalculateTouchPosition( Integration::Point& point )
881 Vector2 position = point.GetScreenPosition();
882 Vector2 convertedPosition;
884 switch( mRotationAngle )
888 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
889 convertedPosition.y = position.x;
894 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
895 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
900 convertedPosition.x = position.y;
901 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
906 convertedPosition = position;
911 point.SetScreenPosition( convertedPosition );
914 Dali::Window Window::Get( Dali::Actor actor )
916 Internal::Adaptor::Window* windowImpl = nullptr;
918 if ( Internal::Adaptor::Adaptor::IsAvailable() )
920 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
921 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
924 return Dali::Window( windowImpl );
928 return Dali::Window();
931 void Window::SetParent( Dali::Window& parent )
933 if ( DALI_UNLIKELY( parent ) )
935 mParentWindow = parent;
936 Dali::Window self = Dali::Window( this );
937 // check circular parent window setting
938 if ( Dali::DevelWindow::GetParent( parent ) == self )
940 Dali::DevelWindow::Unparent( parent );
942 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
946 void Window::Unparent()
948 mWindowBase->SetParent( nullptr );
949 mParentWindow.Reset();
952 Dali::Window Window::GetParent()
954 return mParentWindow;
957 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
959 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
960 return ConvertToOrientation( mRotationAngle );
963 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
965 Dali::Vector<float>::SizeType count = orientations.Count();
966 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
968 if( IsOrientationAvailable( orientations[index] ) == false )
970 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
975 int convertedAngle = ConvertToAngle( orientations[index] );
977 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
979 if( mAvailableAngles[i] == convertedAngle )
988 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
989 mAvailableAngles.push_back( convertedAngle );
992 SetAvailableAnlges( mAvailableAngles );
995 int32_t Window::GetNativeId() const
997 return mWindowBase->GetNativeWindowId();
1000 void Window::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
1002 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
1003 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
1006 eglGraphics->SetDamagedAreas(areas);