2 * Copyright (c) 2019 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 mFocusChangedSignal(),
93 mDeleteRequestSignal(),
96 mVisibilityChangedSignal(),
97 mTransitionEffectEventSignal()
105 mEventHandler->RemoveObserver( *this );
109 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
111 // Create a window render surface
112 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
113 mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
114 mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
117 mWindowBase = mWindowSurface->GetWindowBase();
120 mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
121 mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
122 mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
123 mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
125 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
127 if( !positionSize.IsEmpty() )
129 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
130 mResizeEnabled = true;
133 SetClass( name, className );
135 mWindowSurface->Map();
137 mOrientation = Orientation::New( this );
139 // Get OrientationMode
140 int screenWidth, screenHeight;
141 WindowSystem::GetScreenSize( screenWidth, screenHeight );
142 if( screenWidth > screenHeight )
144 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
148 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
151 mNativeWindowId = mWindowBase->GetNativeWindowId();
154 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
156 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface, *mAdaptor ) );
157 mEventHandler->AddObserver( *this );
160 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
162 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
165 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
169 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
173 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
177 void Window::SetClass( std::string name, std::string className )
180 mClassName = className;
181 mWindowBase->SetClass( name, className );
184 std::string Window::GetClassName() const
191 mWindowBase->Raise();
193 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
194 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
197 eglGraphics->SetFullSwapNextFrame();
200 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
205 mWindowBase->Lower();
207 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
208 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
211 eglGraphics->SetFullSwapNextFrame();
214 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
217 void Window::Activate()
219 mWindowBase->Activate();
221 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
222 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
225 eglGraphics->SetFullSwapNextFrame();
228 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
231 uint32_t Window::GetLayerCount() const
233 return mScene.GetLayerCount();
236 Dali::Layer Window::GetLayer( uint32_t depth ) const
238 return mScene.GetLayer( depth );
241 Dali::RenderTaskList Window::GetRenderTaskList() const
243 return mScene.GetRenderTaskList();
246 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
248 if( IsOrientationAvailable( orientation ) == false )
254 int convertedAngle = ConvertToAngle( orientation );
255 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
256 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
258 if( mAvailableAngles[i] == convertedAngle )
267 mAvailableAngles.push_back( convertedAngle );
268 SetAvailableAnlges( mAvailableAngles );
272 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
274 if( IsOrientationAvailable( orientation ) == false )
279 int convertedAngle = ConvertToAngle( orientation );
280 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
281 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
282 iter != mAvailableAngles.end(); ++iter )
284 if( *iter == convertedAngle )
286 mAvailableAngles.erase( iter );
291 SetAvailableAnlges( mAvailableAngles );
294 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
296 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
298 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
301 mPreferredAngle = ConvertToAngle( orientation );
302 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
303 mWindowBase->SetPreferredAngle( mPreferredAngle );
306 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
308 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
309 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
310 return preferredOrientation;
313 void Window::SetAvailableAnlges( const std::vector< int >& angles )
315 if( angles.size() > 4 )
317 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
321 mWindowBase->SetAvailableAnlges( angles );
324 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
326 int convertAngle = static_cast< int >( orientation );
327 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
329 switch( orientation )
331 case Dali::Window::LANDSCAPE:
336 case Dali::Window::PORTRAIT:
341 case Dali::Window::LANDSCAPE_INVERSE:
346 case Dali::Window::PORTRAIT_INVERSE:
351 case Dali::Window::NO_ORIENTATION_PREFERENCE:
361 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
363 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
364 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
370 orientation = Dali::Window::LANDSCAPE;
375 orientation = Dali::Window::PORTRAIT;
380 orientation = Dali::Window::LANDSCAPE_INVERSE;
385 orientation = Dali::Window::PORTRAIT_INVERSE;
390 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
398 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
400 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
402 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
408 Dali::Any Window::GetNativeHandle() const
410 return mWindowSurface->GetNativeWindow();
413 void Window::SetAcceptFocus( bool accept )
415 mIsFocusAcceptable = accept;
417 mWindowBase->SetAcceptFocus( accept );
420 bool Window::IsFocusAcceptable() const
422 return mIsFocusAcceptable;
433 WindowVisibilityObserver* observer( mAdaptor );
434 observer->OnWindowShown();
436 Dali::Window handle( this );
437 mVisibilityChangedSignal.Emit( handle, true );
440 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
441 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
444 eglGraphics->SetFullSwapNextFrame();
447 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
458 WindowVisibilityObserver* observer( mAdaptor );
459 observer->OnWindowHidden();
461 Dali::Window handle( this );
462 mVisibilityChangedSignal.Emit( handle, false );
466 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
467 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
470 eglGraphics->SetFullSwapNextFrame();
473 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
476 bool Window::IsVisible() const
478 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
479 return mVisible && !mIconified;
482 unsigned int Window::GetSupportedAuxiliaryHintCount() const
484 return mWindowBase->GetSupportedAuxiliaryHintCount();
487 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
489 return mWindowBase->GetSupportedAuxiliaryHint( index );
492 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
494 return mWindowBase->AddAuxiliaryHint( hint, value );
497 bool Window::RemoveAuxiliaryHint( unsigned int id )
499 return mWindowBase->RemoveAuxiliaryHint( id );
502 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
504 return mWindowBase->SetAuxiliaryHintValue( id, value );
507 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
509 return mWindowBase->GetAuxiliaryHintValue( id );
512 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
514 return mWindowBase->GetAuxiliaryHintId( hint );
517 void Window::SetInputRegion( const Rect< int >& inputRegion )
519 mWindowBase->SetInputRegion( inputRegion );
521 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
522 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
525 eglGraphics->SetFullSwapNextFrame();
528 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 );
531 void Window::SetType( Dali::Window::Type type )
535 mWindowBase->SetType( type );
541 Dali::Window::Type Window::GetType() const
546 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
548 if( mType != Dali::Window::NOTIFICATION )
550 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
554 return mWindowBase->SetNotificationLevel( level );
557 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
559 if( mType != Dali::Window::NOTIFICATION )
561 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
562 return Dali::Window::NotificationLevel::NONE;
565 return mWindowBase->GetNotificationLevel();
568 void Window::SetOpaqueState( bool opaque )
570 mOpaqueState = opaque;
572 mWindowBase->SetOpaqueState( opaque );
574 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
577 bool Window::IsOpaqueState() const
582 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
584 return mWindowBase->SetScreenOffMode( screenOffMode );
587 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
589 return mWindowBase->GetScreenOffMode();
592 bool Window::SetBrightness( int brightness )
594 if( brightness < 0 || brightness > 100 )
596 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
600 return mWindowBase->SetBrightness( brightness );
603 int Window::GetBrightness() const
605 return mWindowBase->GetBrightness();
608 void Window::SetSize( Dali::Window::WindowSize size )
610 if( !mResizeEnabled )
612 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
613 mResizeEnabled = true;
616 PositionSize oldRect = mSurface->GetPositionSize();
618 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
620 PositionSize newRect = mSurface->GetPositionSize();
622 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
623 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
625 Uint16Pair newSize( newRect.width, newRect.height );
629 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
631 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
633 Dali::Window handle( this );
634 mResizedSignal.Emit( newSize );
635 mResizeSignal.Emit( handle, newSize );
637 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
640 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
641 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
644 eglGraphics->SetFullSwapNextFrame();
648 Dali::Window::WindowSize Window::GetSize() const
650 PositionSize positionSize = mSurface->GetPositionSize();
652 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
655 void Window::SetPosition( Dali::Window::WindowPosition position )
657 if( !mResizeEnabled )
659 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
660 mResizeEnabled = true;
663 PositionSize oldRect = mSurface->GetPositionSize();
665 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
667 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
668 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
671 eglGraphics->SetFullSwapNextFrame();
675 Dali::Window::WindowPosition Window::GetPosition() const
677 PositionSize positionSize = mSurface->GetPositionSize();
679 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
682 void Window::SetPositionSize( PositionSize positionSize )
684 if( !mResizeEnabled )
686 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
687 mResizeEnabled = true;
690 PositionSize oldRect = mSurface->GetPositionSize();
692 mWindowSurface->MoveResize( positionSize );
694 PositionSize newRect = mSurface->GetPositionSize();
696 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
697 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
699 Uint16Pair newSize( newRect.width, newRect.height );
703 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
705 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
706 Dali::Window handle( this );
707 mResizedSignal.Emit( newSize );
708 mResizeSignal.Emit( handle, newSize );
709 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
712 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
713 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
716 eglGraphics->SetFullSwapNextFrame();
720 Dali::Layer Window::GetRootLayer() const
722 return mScene.GetRootLayer();
725 void Window::SetTransparency( bool transparent )
727 mWindowSurface->SetTransparency( transparent );
730 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
732 return mWindowBase->GrabKey( key, grabMode );
735 bool Window::UngrabKey( Dali::KEY key )
737 return mWindowBase->UngrabKey( key );
740 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
742 return mWindowBase->GrabKeyList( key, grabMode, result );
745 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
747 return mWindowBase->UngrabKeyList( key, result );
750 void Window::OnIconifyChanged( bool iconified )
758 WindowVisibilityObserver* observer( mAdaptor );
759 observer->OnWindowHidden();
761 Dali::Window handle( this );
762 mVisibilityChangedSignal.Emit( handle, false );
765 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
773 WindowVisibilityObserver* observer( mAdaptor );
774 observer->OnWindowShown();
776 Dali::Window handle( this );
777 mVisibilityChangedSignal.Emit( handle, true );
780 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
783 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
784 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
787 eglGraphics->SetFullSwapNextFrame();
791 void Window::OnFocusChanged( bool focusIn )
793 Dali::Window handle( this );
794 mFocusChangedSignal.Emit( focusIn );
795 mFocusChangeSignal.Emit( handle, focusIn );
797 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
798 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
801 eglGraphics->SetFullSwapNextFrame();
805 void Window::OnOutputTransformed()
807 PositionSize positionSize = mSurface->GetPositionSize();
809 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
810 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
813 void Window::OnDeleteRequest()
815 mDeleteRequestSignal.Emit();
818 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
820 Dali::Window handle( this );
821 mTransitionEffectEventSignal.Emit( handle, state, type );
824 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
826 FeedTouchPoint( point, timeStamp );
829 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
831 FeedWheelEvent( wheelEvent );
834 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
836 FeedKeyEvent( keyEvent );
839 void Window::OnRotation( const RotationEvent& rotation )
841 mRotationAngle = rotation.angle;
842 mWindowWidth = rotation.width;
843 mWindowHeight = rotation.height;
845 // Notify that the orientation is changed
846 mOrientation->OnOrientationChange( rotation );
848 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
852 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
854 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
856 Dali::Window handle( this );
857 mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
858 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
860 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
863 void Window::OnPause()
867 mEventHandler->Pause();
870 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
871 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
874 eglGraphics->SetFullSwapNextFrame();
878 void Window::OnResume()
882 mEventHandler->Resume();
885 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
886 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
889 eglGraphics->SetFullSwapNextFrame();
893 void Window::RecalculateTouchPosition( Integration::Point& point )
895 Vector2 position = point.GetScreenPosition();
896 Vector2 convertedPosition;
898 switch( mRotationAngle )
902 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
903 convertedPosition.y = position.x;
908 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
909 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
914 convertedPosition.x = position.y;
915 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
920 convertedPosition = position;
925 point.SetScreenPosition( convertedPosition );
928 Dali::Window Window::Get( Dali::Actor actor )
930 Internal::Adaptor::Window* windowImpl = nullptr;
932 if ( Internal::Adaptor::Adaptor::IsAvailable() )
934 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
935 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
938 return Dali::Window( windowImpl );
942 return Dali::Window();
945 void Window::SetParent( Dali::Window& parent )
947 if ( DALI_UNLIKELY( parent ) )
949 mParentWindow = parent;
950 Dali::Window self = Dali::Window( this );
951 // check circular parent window setting
952 if ( Dali::DevelWindow::GetParent( parent ) == self )
954 Dali::DevelWindow::Unparent( parent );
956 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
960 void Window::Unparent()
962 mWindowBase->SetParent( nullptr );
963 mParentWindow.Reset();
966 Dali::Window Window::GetParent()
968 return mParentWindow;
971 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
973 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
974 return ConvertToOrientation( mRotationAngle );
977 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
979 Dali::Vector<float>::SizeType count = orientations.Count();
980 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
982 if( IsOrientationAvailable( orientations[index] ) == false )
984 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
989 int convertedAngle = ConvertToAngle( orientations[index] );
991 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
993 if( mAvailableAngles[i] == convertedAngle )
1002 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
1003 mAvailableAngles.push_back( convertedAngle );
1006 SetAvailableAnlges( mAvailableAngles );
1009 int32_t Window::GetNativeId() const
1011 return mWindowBase->GetNativeWindowId();
1014 void Window::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
1016 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
1017 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
1020 eglGraphics->SetDamagedAreas(areas);