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 );
614 bool forceUpdate = false;
615 if( mWindowBase->IsEglWindowRotationSupported() )
620 SurfaceResized( forceUpdate );
622 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
624 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
626 Dali::Window handle( this );
627 mResizedSignal.Emit( newSize );
628 mResizeSignal.Emit( handle, newSize );
630 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
633 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
634 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
637 eglGraphics->SetFullSwapNextFrame();
641 Dali::Window::WindowSize Window::GetSize() const
643 PositionSize positionSize = mSurface->GetPositionSize();
645 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
648 void Window::SetPosition( Dali::Window::WindowPosition position )
650 if( !mResizeEnabled )
652 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
653 mResizeEnabled = true;
656 PositionSize oldRect = mSurface->GetPositionSize();
658 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
660 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
661 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
664 eglGraphics->SetFullSwapNextFrame();
668 Dali::Window::WindowPosition Window::GetPosition() const
670 PositionSize positionSize = mSurface->GetPositionSize();
672 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
675 void Window::SetPositionSize( PositionSize positionSize )
677 if( !mResizeEnabled )
679 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
680 mResizeEnabled = true;
683 PositionSize oldRect = mSurface->GetPositionSize();
685 mWindowSurface->MoveResize( positionSize );
687 PositionSize newRect = mSurface->GetPositionSize();
689 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
690 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
692 Uint16Pair newSize( newRect.width, newRect.height );
694 bool forceUpdate = false;
695 if( mWindowBase->IsEglWindowRotationSupported() )
700 SurfaceResized( forceUpdate );
702 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
704 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
705 Dali::Window handle( this );
706 mResizedSignal.Emit( newSize );
707 mResizeSignal.Emit( handle, newSize );
708 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
711 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
712 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
715 eglGraphics->SetFullSwapNextFrame();
719 Dali::Layer Window::GetRootLayer() const
721 return mScene.GetRootLayer();
724 void Window::SetTransparency( bool transparent )
726 mWindowSurface->SetTransparency( transparent );
729 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
731 return mWindowBase->GrabKey( key, grabMode );
734 bool Window::UngrabKey( Dali::KEY key )
736 return mWindowBase->UngrabKey( key );
739 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
741 return mWindowBase->GrabKeyList( key, grabMode, result );
744 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
746 return mWindowBase->UngrabKeyList( key, result );
749 void Window::OnIconifyChanged( bool iconified )
757 WindowVisibilityObserver* observer( mAdaptor );
758 observer->OnWindowHidden();
760 Dali::Window handle( this );
761 mVisibilityChangedSignal.Emit( handle, false );
764 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
772 WindowVisibilityObserver* observer( mAdaptor );
773 observer->OnWindowShown();
775 Dali::Window handle( this );
776 mVisibilityChangedSignal.Emit( handle, true );
779 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
782 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
783 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
786 eglGraphics->SetFullSwapNextFrame();
790 void Window::OnFocusChanged( bool focusIn )
792 Dali::Window handle( this );
793 mFocusChangeSignal.Emit( handle, focusIn );
795 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
796 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
799 eglGraphics->SetFullSwapNextFrame();
803 void Window::OnOutputTransformed()
805 bool forceUpdate = false;
806 if( mWindowBase->IsEglWindowRotationSupported() )
810 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnOutputTransformed()\n", this, mNativeWindowId );
811 SurfaceResized( forceUpdate );
813 PositionSize positionSize = mSurface->GetPositionSize();
814 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
815 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
818 void Window::OnDeleteRequest()
820 mDeleteRequestSignal.Emit();
823 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
825 Dali::Window handle( this );
826 mTransitionEffectEventSignal.Emit( handle, state, type );
829 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
831 FeedTouchPoint( point, timeStamp );
834 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
836 FeedWheelEvent( wheelEvent );
839 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
841 FeedKeyEvent( keyEvent );
844 void Window::OnRotation( const RotationEvent& rotation )
846 mRotationAngle = rotation.angle;
847 mWindowWidth = rotation.width;
848 mWindowHeight = rotation.height;
850 // Notify that the orientation is changed
851 mOrientation->OnOrientationChange( rotation );
853 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
855 bool forceUpdate = false;
856 if( mWindowBase->IsEglWindowRotationSupported() )
861 SurfaceResized( forceUpdate );
863 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
865 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
867 Dali::Window handle( this );
868 mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
869 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
871 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
874 void Window::OnPause()
878 mEventHandler->Pause();
881 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
882 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
885 eglGraphics->SetFullSwapNextFrame();
889 void Window::OnResume()
893 mEventHandler->Resume();
896 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
897 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
900 eglGraphics->SetFullSwapNextFrame();
904 void Window::RecalculateTouchPosition( Integration::Point& point )
906 Vector2 position = point.GetScreenPosition();
907 Vector2 convertedPosition;
909 switch( mRotationAngle )
913 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
914 convertedPosition.y = position.x;
919 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
920 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
925 convertedPosition.x = position.y;
926 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
931 convertedPosition = position;
936 point.SetScreenPosition( convertedPosition );
939 Dali::Window Window::Get( Dali::Actor actor )
941 Internal::Adaptor::Window* windowImpl = nullptr;
943 if ( Internal::Adaptor::Adaptor::IsAvailable() )
945 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
946 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
949 return Dali::Window( windowImpl );
953 return Dali::Window();
956 void Window::SetParent( Dali::Window& parent )
958 if ( DALI_UNLIKELY( parent ) )
960 mParentWindow = parent;
961 Dali::Window self = Dali::Window( this );
962 // check circular parent window setting
963 if ( Dali::DevelWindow::GetParent( parent ) == self )
965 Dali::DevelWindow::Unparent( parent );
967 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
971 void Window::Unparent()
973 mWindowBase->SetParent( nullptr );
974 mParentWindow.Reset();
977 Dali::Window Window::GetParent()
979 return mParentWindow;
982 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
984 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
985 return ConvertToOrientation( mRotationAngle );
988 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
990 Dali::Vector<float>::SizeType count = orientations.Count();
991 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
993 if( IsOrientationAvailable( orientations[index] ) == false )
995 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1000 int convertedAngle = ConvertToAngle( orientations[index] );
1002 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
1004 if( mAvailableAngles[i] == convertedAngle )
1013 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
1014 mAvailableAngles.push_back( convertedAngle );
1017 SetAvailableAnlges( mAvailableAngles );
1020 int32_t Window::GetNativeId() const
1022 return mWindowBase->GetNativeWindowId();
1025 void Window::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
1027 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
1028 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
1031 eglGraphics->SetDamagedAreas(areas);