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 );
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::SetClass( std::string name, std::string className )
168 mClassName = className;
169 mWindowBase->SetClass( name, className );
172 std::string Window::GetClassName() const
179 mWindowBase->Raise();
181 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
182 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
185 eglGraphics->SetFullSwapNextFrame();
188 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
193 mWindowBase->Lower();
195 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
196 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
199 eglGraphics->SetFullSwapNextFrame();
202 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
205 void Window::Activate()
207 mWindowBase->Activate();
209 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
210 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
213 eglGraphics->SetFullSwapNextFrame();
216 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
219 uint32_t Window::GetLayerCount() const
221 return mScene.GetLayerCount();
224 Dali::Layer Window::GetLayer( uint32_t depth ) const
226 return mScene.GetLayer( depth );
229 Dali::RenderTaskList Window::GetRenderTaskList() const
231 return mScene.GetRenderTaskList();
234 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
236 if( IsOrientationAvailable( orientation ) == false )
242 int convertedAngle = ConvertToAngle( orientation );
243 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
244 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
246 if( mAvailableAngles[i] == convertedAngle )
255 mAvailableAngles.push_back( convertedAngle );
256 SetAvailableAnlges( mAvailableAngles );
260 void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
262 if( IsOrientationAvailable( orientation ) == false )
267 int convertedAngle = ConvertToAngle( orientation );
268 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
269 for( std::vector< int >::iterator iter = mAvailableAngles.begin();
270 iter != mAvailableAngles.end(); ++iter )
272 if( *iter == convertedAngle )
274 mAvailableAngles.erase( iter );
279 SetAvailableAnlges( mAvailableAngles );
282 void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
284 if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
286 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
289 mPreferredAngle = ConvertToAngle( orientation );
290 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
291 mWindowBase->SetPreferredAngle( mPreferredAngle );
294 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
296 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
297 Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
298 return preferredOrientation;
301 void Window::SetAvailableAnlges( const std::vector< int >& angles )
303 if( angles.size() > 4 )
305 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
309 mWindowBase->SetAvailableAnlges( angles );
312 int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
314 int convertAngle = static_cast< int >( orientation );
315 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
317 switch( orientation )
319 case Dali::Window::LANDSCAPE:
324 case Dali::Window::PORTRAIT:
329 case Dali::Window::LANDSCAPE_INVERSE:
334 case Dali::Window::PORTRAIT_INVERSE:
339 case Dali::Window::NO_ORIENTATION_PREFERENCE:
349 Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
351 Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
352 if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
358 orientation = Dali::Window::LANDSCAPE;
363 orientation = Dali::Window::PORTRAIT;
368 orientation = Dali::Window::LANDSCAPE_INVERSE;
373 orientation = Dali::Window::PORTRAIT_INVERSE;
378 orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
386 bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
388 if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
390 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
396 Dali::Any Window::GetNativeHandle() const
398 return mWindowSurface->GetNativeWindow();
401 void Window::SetAcceptFocus( bool accept )
403 mIsFocusAcceptable = accept;
405 mWindowBase->SetAcceptFocus( accept );
408 bool Window::IsFocusAcceptable() const
410 return mIsFocusAcceptable;
421 WindowVisibilityObserver* observer( mAdaptor );
422 observer->OnWindowShown();
424 Dali::Window handle( this );
425 mVisibilityChangedSignal.Emit( handle, true );
428 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
429 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
432 eglGraphics->SetFullSwapNextFrame();
435 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
446 WindowVisibilityObserver* observer( mAdaptor );
447 observer->OnWindowHidden();
449 Dali::Window handle( this );
450 mVisibilityChangedSignal.Emit( handle, false );
454 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
455 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
458 eglGraphics->SetFullSwapNextFrame();
461 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
464 bool Window::IsVisible() const
466 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
467 return mVisible && !mIconified;
470 unsigned int Window::GetSupportedAuxiliaryHintCount() const
472 return mWindowBase->GetSupportedAuxiliaryHintCount();
475 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
477 return mWindowBase->GetSupportedAuxiliaryHint( index );
480 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
482 return mWindowBase->AddAuxiliaryHint( hint, value );
485 bool Window::RemoveAuxiliaryHint( unsigned int id )
487 return mWindowBase->RemoveAuxiliaryHint( id );
490 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
492 return mWindowBase->SetAuxiliaryHintValue( id, value );
495 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
497 return mWindowBase->GetAuxiliaryHintValue( id );
500 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
502 return mWindowBase->GetAuxiliaryHintId( hint );
505 void Window::SetInputRegion( const Rect< int >& inputRegion )
507 mWindowBase->SetInputRegion( inputRegion );
509 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
510 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
513 eglGraphics->SetFullSwapNextFrame();
516 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 );
519 void Window::SetType( Dali::Window::Type type )
523 mWindowBase->SetType( type );
529 Dali::Window::Type Window::GetType() const
534 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
536 if( mType != Dali::Window::NOTIFICATION )
538 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
542 return mWindowBase->SetNotificationLevel( level );
545 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
547 if( mType != Dali::Window::NOTIFICATION )
549 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
550 return Dali::Window::NotificationLevel::NONE;
553 return mWindowBase->GetNotificationLevel();
556 void Window::SetOpaqueState( bool opaque )
558 mOpaqueState = opaque;
560 mWindowBase->SetOpaqueState( opaque );
562 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
565 bool Window::IsOpaqueState() const
570 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
572 return mWindowBase->SetScreenOffMode( screenOffMode );
575 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
577 return mWindowBase->GetScreenOffMode();
580 bool Window::SetBrightness( int brightness )
582 if( brightness < 0 || brightness > 100 )
584 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
588 return mWindowBase->SetBrightness( brightness );
591 int Window::GetBrightness() const
593 return mWindowBase->GetBrightness();
596 void Window::SetSize( Dali::Window::WindowSize size )
598 if( !mResizeEnabled )
600 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
601 mResizeEnabled = true;
604 PositionSize oldRect = mSurface->GetPositionSize();
606 mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
608 PositionSize newRect = mSurface->GetPositionSize();
610 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
611 if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
613 Uint16Pair newSize( newRect.width, newRect.height );
617 mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
619 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
621 Dali::Window handle( this );
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 mResizeSignal.Emit( handle, newSize );
695 mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
698 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
699 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
702 eglGraphics->SetFullSwapNextFrame();
706 Dali::Layer Window::GetRootLayer() const
708 return mScene.GetRootLayer();
711 void Window::SetTransparency( bool transparent )
713 mWindowSurface->SetTransparency( transparent );
716 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
718 return mWindowBase->GrabKey( key, grabMode );
721 bool Window::UngrabKey( Dali::KEY key )
723 return mWindowBase->UngrabKey( key );
726 bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
728 return mWindowBase->GrabKeyList( key, grabMode, result );
731 bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
733 return mWindowBase->UngrabKeyList( key, result );
736 void Window::OnIconifyChanged( bool iconified )
744 WindowVisibilityObserver* observer( mAdaptor );
745 observer->OnWindowHidden();
747 Dali::Window handle( this );
748 mVisibilityChangedSignal.Emit( handle, false );
751 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
759 WindowVisibilityObserver* observer( mAdaptor );
760 observer->OnWindowShown();
762 Dali::Window handle( this );
763 mVisibilityChangedSignal.Emit( handle, true );
766 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
769 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
770 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
773 eglGraphics->SetFullSwapNextFrame();
777 void Window::OnFocusChanged( bool focusIn )
779 Dali::Window handle( this );
780 mFocusChangeSignal.Emit( handle, focusIn );
782 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
783 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
786 eglGraphics->SetFullSwapNextFrame();
790 void Window::OnOutputTransformed()
792 PositionSize positionSize = mSurface->GetPositionSize();
794 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
795 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
798 void Window::OnDeleteRequest()
800 mDeleteRequestSignal.Emit();
803 void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
805 Dali::Window handle( this );
806 mTransitionEffectEventSignal.Emit( handle, state, type );
809 void Window::OnKeyboardRepeatSettingsChanged()
811 Dali::Window handle( this );
812 mKeyboardRepeatSettingsChangedSignal.Emit();
815 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
817 FeedTouchPoint( point, timeStamp );
820 void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
822 FeedWheelEvent( wheelEvent );
825 void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
827 FeedKeyEvent( keyEvent );
830 void Window::OnRotation( const RotationEvent& rotation )
832 mRotationAngle = rotation.angle;
833 mWindowWidth = rotation.width;
834 mWindowHeight = rotation.height;
836 // Notify that the orientation is changed
837 mOrientation->OnOrientationChange( rotation );
839 mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
843 mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
845 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
847 Dali::Window handle( this );
848 mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
850 mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
853 void Window::OnPause()
857 mEventHandler->Pause();
860 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
861 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
864 eglGraphics->SetFullSwapNextFrame();
868 void Window::OnResume()
872 mEventHandler->Resume();
875 GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
876 EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
879 eglGraphics->SetFullSwapNextFrame();
883 void Window::RecalculateTouchPosition( Integration::Point& point )
885 Vector2 position = point.GetScreenPosition();
886 Vector2 convertedPosition;
888 switch( mRotationAngle )
892 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
893 convertedPosition.y = position.x;
898 convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
899 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
904 convertedPosition.x = position.y;
905 convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
910 convertedPosition = position;
915 point.SetScreenPosition( convertedPosition );
918 Dali::Window Window::Get( Dali::Actor actor )
920 Internal::Adaptor::Window* windowImpl = nullptr;
922 if ( Internal::Adaptor::Adaptor::IsAvailable() )
924 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
925 windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
928 return Dali::Window( windowImpl );
932 return Dali::Window();
935 void Window::SetParent( Dali::Window& parent )
937 if ( DALI_UNLIKELY( parent ) )
939 mParentWindow = parent;
940 Dali::Window self = Dali::Window( this );
941 // check circular parent window setting
942 if ( Dali::DevelWindow::GetParent( parent ) == self )
944 Dali::DevelWindow::Unparent( parent );
946 mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
950 void Window::Unparent()
952 mWindowBase->SetParent( nullptr );
953 mParentWindow.Reset();
956 Dali::Window Window::GetParent()
958 return mParentWindow;
961 Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
963 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
964 return ConvertToOrientation( mRotationAngle );
967 void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
969 Dali::Vector<float>::SizeType count = orientations.Count();
970 for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
972 if( IsOrientationAvailable( orientations[index] ) == false )
974 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
979 int convertedAngle = ConvertToAngle( orientations[index] );
981 for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
983 if( mAvailableAngles[i] == convertedAngle )
992 DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
993 mAvailableAngles.push_back( convertedAngle );
996 SetAvailableAnlges( mAvailableAngles );
999 int32_t Window::GetNativeId() const
1001 return mWindowBase->GetNativeWindowId();