2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
23 #include <dali/integration-api/core.h>
24 #include <dali/public-api/actors/actor.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/actors/camera-actor.h>
27 #include <dali/public-api/render-tasks/render-task.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
29 #include <dali/public-api/rendering/frame-buffer.h>
30 #include <dali/devel-api/adaptor-framework/orientation.h>
31 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
35 #include <dali/internal/graphics/gles/egl-graphics.h>
36 #include <dali/internal/window-system/common/event-handler.h>
37 #include <dali/internal/window-system/common/orientation-impl.h>
38 #include <dali/internal/window-system/common/render-surface-factory.h>
39 #include <dali/internal/window-system/common/window-factory.h>
40 #include <dali/internal/window-system/common/window-base.h>
41 #include <dali/internal/window-system/common/window-system.h>
42 #include <dali/internal/window-system/common/window-render-surface.h>
43 #include <dali/internal/window-system/common/window-visibility-observer.h>
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
59 } // unnamed namespace
61 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
64 return Window::New(surface, positionSize, name, className, isTransparent);
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
69 Window* window = new Window();
70 window->mIsTransparent = isTransparent;
71 window->Initialize(surface, positionSize, name, className);
76 : mWindowSurface( nullptr ),
78 mIsTransparent( false ),
79 mIsFocusAcceptable( true ),
81 mOpaqueState( false ),
82 mResizeEnabled( false ),
83 mType( Dali::Window::NORMAL ),
84 mParentWindow( NULL ),
85 mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ),
89 mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
90 mNativeWindowId( -1 ),
91 mDeleteRequestSignal(),
94 mVisibilityChangedSignal(),
95 mTransitionEffectEventSignal(),
96 mKeyboardRepeatSettingsChangedSignal()
104 mEventHandler->RemoveObserver( *this );
108 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
110 // Create a window render surface
111 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
112 mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
113 mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
116 mWindowBase = mWindowSurface->GetWindowBase();
119 mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
120 mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
121 mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
122 mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
123 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
124 mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
126 mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
128 if( !positionSize.IsEmpty() )
130 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
131 mResizeEnabled = true;
134 SetClass( name, className );
136 mWindowSurface->Map();
138 mOrientation = Orientation::New( this );
140 // Get OrientationMode
141 int screenWidth, screenHeight;
142 WindowSystem::GetScreenSize( screenWidth, screenHeight );
143 if( screenWidth > screenHeight )
145 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
149 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
152 mNativeWindowId = mWindowBase->GetNativeWindowId();
155 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
157 mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface, *mAdaptor ) );
158 mEventHandler->AddObserver( *this );
161 void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
163 mWindowSurface = static_cast<WindowRenderSurface*>( surface );
166 void Window::SetClass( std::string name, std::string className )
169 mClassName = className;
170 mWindowBase->SetClass( name, className );
173 std::string Window::GetClassName() const
180 mWindowBase->Raise();
182 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
183 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
186 eglGraphics->SetFullSwapNextFrame();
189 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
194 mWindowBase->Lower();
196 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
197 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
200 eglGraphics->SetFullSwapNextFrame();
203 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
206 void Window::Activate()
208 mWindowBase->Activate();
210 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
211 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
214 eglGraphics->SetFullSwapNextFrame();
217 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
220 uint32_t Window::GetLayerCount() const
222 return mScene.GetLayerCount();
225 Dali::Layer Window::GetLayer( uint32_t depth ) const
227 return mScene.GetLayer( depth );
230 Dali::RenderTaskList Window::GetRenderTaskList() const
232 return mScene.GetRenderTaskList();
235 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
237 if( IsOrientationAvailable( orientation ) == false )
243 int convertedAngle = ConvertToAngle( orientation );
244 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
245 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
247 if( mAvailableAngles[i] == convertedAngle )
256 mAvailableAngles.push_back( convertedAngle );
257 SetAvailableAnlges( mAvailableAngles );
261 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
263 if( IsOrientationAvailable( orientation ) == false )
268 int convertedAngle = ConvertToAngle( orientation );
269 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
270 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
271 iter != mAvailableAngles.end(); ++iter )
273 if( *iter == convertedAngle )
275 mAvailableAngles.erase( iter );
280 SetAvailableAnlges( mAvailableAngles );
283 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
285 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
287 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
290 mPreferredAngle = ConvertToAngle( orientation );
291 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
292 mWindowBase->SetPreferredAngle( mPreferredAngle );
295 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
297 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
298 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
299 return preferredOrientation;
302 void Window::SetAvailableAnlges( const std::vector< int >& angles )
304 if( angles.size() > 4 )
306 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
310 mWindowBase->SetAvailableAnlges( angles );
313 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
315 int convertAngle = static_cast< int >( orientation );
316 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
318 switch( orientation )
320 case Dali::Window::LANDSCAPE:
325 case Dali::Window::PORTRAIT:
330 case Dali::Window::LANDSCAPE_INVERSE:
335 case Dali::Window::PORTRAIT_INVERSE:
340 case Dali::Window::NO_ORIENTATION_PREFERENCE:
350 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
352 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
353 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
359 orientation = Dali::Window::LANDSCAPE;
364 orientation = Dali::Window::PORTRAIT;
369 orientation = Dali::Window::LANDSCAPE_INVERSE;
374 orientation = Dali::Window::PORTRAIT_INVERSE;
379 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
387 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
389 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
391 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
397 Dali::Any Window::GetNativeHandle() const
399 return mWindowSurface->GetNativeWindow();
402 void Window::SetAcceptFocus( bool accept )
404 mIsFocusAcceptable = accept;
406 mWindowBase->SetAcceptFocus( accept );
409 bool Window::IsFocusAcceptable() const
411 return mIsFocusAcceptable;
422 WindowVisibilityObserver* observer( mAdaptor );
423 observer->OnWindowShown();
425 Dali::Window handle( this );
426 mVisibilityChangedSignal.Emit( handle, true );
429 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
430 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
433 eglGraphics->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 );
455 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
456 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
459 eglGraphics->SetFullSwapNextFrame();
462 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
465 bool Window::IsVisible() const
467 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
468 return mVisible && !mIconified;
471 unsigned int Window::GetSupportedAuxiliaryHintCount() const
473 return mWindowBase->GetSupportedAuxiliaryHintCount();
476 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
478 return mWindowBase->GetSupportedAuxiliaryHint( index );
481 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
483 return mWindowBase->AddAuxiliaryHint( hint, value );
486 bool Window::RemoveAuxiliaryHint( unsigned int id )
488 return mWindowBase->RemoveAuxiliaryHint( id );
491 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
493 return mWindowBase->SetAuxiliaryHintValue( id, value );
496 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
498 return mWindowBase->GetAuxiliaryHintValue( id );
501 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
503 return mWindowBase->GetAuxiliaryHintId( hint );
506 void Window::SetInputRegion( const Rect< int >& inputRegion )
508 mWindowBase->SetInputRegion( inputRegion );
510 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
511 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
514 eglGraphics->SetFullSwapNextFrame();
517 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 );
520 void Window::SetType( Dali::Window::Type type )
524 mWindowBase->SetType( type );
530 Dali::Window::Type Window::GetType() const
535 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
537 if( mType != Dali::Window::NOTIFICATION )
539 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
543 return mWindowBase->SetNotificationLevel( level );
546 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
548 if( mType != Dali::Window::NOTIFICATION )
550 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
551 return Dali::Window::NotificationLevel::NONE;
554 return mWindowBase->GetNotificationLevel();
557 void Window::SetOpaqueState( bool opaque )
559 mOpaqueState = opaque;
561 mWindowBase->SetOpaqueState( opaque );
563 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
566 bool Window::IsOpaqueState() const
571 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
573 return mWindowBase->SetScreenOffMode( screenOffMode );
576 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
578 return mWindowBase->GetScreenOffMode();
581 bool Window::SetBrightness( int brightness )
583 if( brightness < 0 || brightness > 100 )
585 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
589 return mWindowBase->SetBrightness( brightness );
592 int Window::GetBrightness() const
594 return mWindowBase->GetBrightness();
597 void Window::SetSize( Dali::Window::WindowSize size )
599 if( !mResizeEnabled )
601 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
602 mResizeEnabled = true;
605 PositionSize oldRect = mSurface->GetPositionSize();
607 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
609 PositionSize newRect = mSurface->GetPositionSize();
611 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
612 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
614 Uint16Pair newSize( newRect.width, newRect.height );
618 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
620 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
622 Dali::Window handle( this );
623 mResizeSignal.Emit( handle, newSize );
625 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
628 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
629 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
632 eglGraphics->SetFullSwapNextFrame();
636 Dali::Window::WindowSize Window::GetSize() const
638 PositionSize positionSize = mSurface->GetPositionSize();
640 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
643 void Window::SetPosition( Dali::Window::WindowPosition position )
645 if( !mResizeEnabled )
647 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
648 mResizeEnabled = true;
651 PositionSize oldRect = mSurface->GetPositionSize();
653 mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
655 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
656 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
659 eglGraphics->SetFullSwapNextFrame();
663 Dali::Window::WindowPosition Window::GetPosition() const
665 PositionSize positionSize = mSurface->GetPositionSize();
667 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
670 void Window::SetPositionSize( PositionSize positionSize )
672 if( !mResizeEnabled )
674 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
675 mResizeEnabled = true;
678 PositionSize oldRect = mSurface->GetPositionSize();
680 mWindowSurface->MoveResize( positionSize );
682 PositionSize newRect = mSurface->GetPositionSize();
684 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
685 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
687 Uint16Pair newSize( newRect.width, newRect.height );
691 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
693 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
694 Dali::Window handle( this );
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::OnKeyboardRepeatSettingsChanged()
812 Dali::Window handle( this );
813 mKeyboardRepeatSettingsChangedSignal.Emit();
816 void Window::OnWindowRedrawRequest()
818 mAdaptor->RenderOnce();
821 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
823 FeedTouchPoint( point, timeStamp );
826 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
828 FeedWheelEvent( wheelEvent );
831 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
833 FeedKeyEvent( keyEvent );
836 void Window::OnRotation( const RotationEvent& rotation )
838 mRotationAngle = rotation.angle;
839 mWindowWidth = rotation.width;
840 mWindowHeight = rotation.height;
842 // Notify that the orientation is changed
843 mOrientation->OnOrientationChange( rotation );
845 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
849 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
851 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
853 Dali::Window handle( this );
854 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
856 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
859 void Window::OnPause()
863 mEventHandler->Pause();
866 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
867 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
870 eglGraphics->SetFullSwapNextFrame();
874 void Window::OnResume()
878 mEventHandler->Resume();
881 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
882 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
885 eglGraphics->SetFullSwapNextFrame();
889 void Window::RecalculateTouchPosition( Integration::Point& point )
891 Vector2 position = point.GetScreenPosition();
892 Vector2 convertedPosition;
894 switch( mRotationAngle )
898 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
899 convertedPosition.y = position.x;
904 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
905 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
910 convertedPosition.x = position.y;
911 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
916 convertedPosition = position;
921 point.SetScreenPosition( convertedPosition );
924 Dali::Window Window::Get( Dali::Actor actor )
926 Internal::Adaptor::Window* windowImpl = nullptr;
928 if ( Internal::Adaptor::Adaptor::IsAvailable() )
930 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
931 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
934 return Dali::Window( windowImpl );
938 return Dali::Window();
941 void Window::SetParent( Dali::Window& parent )
943 if ( DALI_UNLIKELY( parent ) )
945 mParentWindow = parent;
946 Dali::Window self = Dali::Window( this );
947 // check circular parent window setting
948 if ( Dali::DevelWindow::GetParent( parent ) == self )
950 Dali::DevelWindow::Unparent( parent );
952 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
956 void Window::Unparent()
958 mWindowBase->SetParent( nullptr );
959 mParentWindow.Reset();
962 Dali::Window Window::GetParent()
964 return mParentWindow;
967 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
969 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
970 return ConvertToOrientation( mRotationAngle );
973 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
975 Dali::Vector<float>::SizeType count = orientations.Count();
976 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
978 if( IsOrientationAvailable( orientations[index] ) == false )
980 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
985 int convertedAngle = ConvertToAngle( orientations[index] );
987 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
989 if( mAvailableAngles[i] == convertedAngle )
998 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
999 mAvailableAngles.push_back( convertedAngle );
1002 SetAvailableAnlges( mAvailableAngles );
1005 int32_t Window::GetNativeId() const
1007 return mWindowBase->GetNativeWindowId();
1010 void Window::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
1012 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
1013 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
1016 eglGraphics->SetDamagedAreas(areas);