From: Wonsik Jung Date: Wed, 24 Jul 2019 07:43:27 +0000 (+0900) Subject: [Tizen] Support screen and client rotation X-Git-Tag: accepted/tizen/unified/20190725.042855^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d1664abe78262c8a9bcf25d703581e347a8dc29;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [Tizen] Support screen and client rotation This patch is to support client and screen rotation. It is for the enhancement rendering performance. Change-Id: I3c07f4ad47b2d1fc70b0d1929f04cf771e12cb08 --- diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp index 7ffb5e5..6e55909 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp @@ -79,7 +79,8 @@ void TestApplication::CreateScene() { mRenderSurface = new TestRenderSurface( Dali::PositionSize( 0, 0, mSurfaceWidth, mSurfaceHeight ) ); mScene = Dali::Integration::Scene::New( Vector2( static_cast( mSurfaceWidth ), static_cast( mSurfaceHeight ) ) ); - mScene.SetSurface( *mRenderSurface ); + + mScene.SetSurface( *mRenderSurface, false ); mScene.SetDpi( Vector2( static_cast( mDpi.x ), static_cast( mDpi.y ) ) ); } diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.cpp index 332d77e..066b37e 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.cpp @@ -40,6 +40,11 @@ void TestRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVe dpiHorizontal = dpiVertical = 96; }; +int TestRenderSurface::GetOrientation() const +{ + return 0; +}; + void TestRenderSurface::InitializeGraphics() { } diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.h index fba89c2..be38d00 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.h @@ -53,6 +53,11 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ); /** + * @copydoc Dali::Integration::RenderSurface::GetOrientation + */ + virtual int GetOrientation() const; + + /** * @copydoc Dali::Integration::RenderSurface::InitializeGraphics */ virtual void InitializeGraphics(); diff --git a/dali/integration-api/render-surface-interface.h b/dali/integration-api/render-surface-interface.h index 501bf62..3fc746c 100644 --- a/dali/integration-api/render-surface-interface.h +++ b/dali/integration-api/render-surface-interface.h @@ -89,6 +89,12 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const = 0; + + /** * @brief InitializeGraphics the platform specific graphics surface interfaces */ virtual void InitializeGraphics() = 0; diff --git a/dali/integration-api/scene-holder-impl.cpp b/dali/integration-api/scene-holder-impl.cpp index f785a1b..cf56042 100644 --- a/dali/integration-api/scene-holder-impl.cpp +++ b/dali/integration-api/scene-holder-impl.cpp @@ -188,7 +188,7 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) { mSurface.reset( surface ); - mScene.SetSurface( *mSurface.get() ); + mScene.SetSurface( *mSurface.get(), false ); unsigned int dpiHorizontal, dpiVertical; dpiHorizontal = dpiVertical = 0; @@ -201,9 +201,9 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) OnSurfaceSet( surface ); } -void SceneHolder::SurfaceResized() +void SceneHolder::SurfaceResized( bool forceUpdate ) { - mScene.SurfaceResized(); + mScene.SurfaceResized( forceUpdate ); } Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const @@ -237,7 +237,7 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) // Create the scene PositionSize positionSize = mSurface->GetPositionSize(); mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) ); - mScene.SetSurface( *mSurface.get() ); + mScene.SetSurface( *mSurface.get(), false ); Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( adaptor ); mAdaptor = &adaptorImpl; diff --git a/dali/integration-api/scene-holder-impl.h b/dali/integration-api/scene-holder-impl.h index 6b4e488..351197a 100644 --- a/dali/integration-api/scene-holder-impl.h +++ b/dali/integration-api/scene-holder-impl.h @@ -118,7 +118,7 @@ public: /** * @brief Called when the surface set is resized. */ - void SurfaceResized(); + void SurfaceResized( bool forceUpdate ); /** * @brief Get the render surface diff --git a/dali/internal/window-system/common/window-base.h b/dali/internal/window-system/common/window-base.h index 165a69a..381af61 100644 --- a/dali/internal/window-system/common/window-base.h +++ b/dali/internal/window-system/common/window-base.h @@ -309,6 +309,12 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const = 0; + + /** * @brief Get the screen rotation angle of the window */ virtual int GetScreenRotationAngle() = 0; @@ -318,6 +324,11 @@ public: */ virtual void SetWindowRotationAngle( int degree ) = 0; + /** + * @brief Get the rotation angle of the window + */ + virtual int GetWindowRotationAngle() = 0; + /** * @brief Inform the window rotation is completed */ diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 95f342b..abdee73 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -451,7 +451,7 @@ void Window::SetSize( Dali::Window::WindowSize size ) { Uint16Pair newSize( newRect.width, newRect.height ); - SurfaceResized(); + SurfaceResized( false ); mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize ); @@ -580,7 +580,14 @@ void Window::OnFocusChanged( bool focusIn ) void Window::OnOutputTransformed() { + bool forceUpdate = false; + if( mWindowBase->IsEglWindowRotationSupported() ) + { + forceUpdate = true; + } PositionSize positionSize = mSurface->GetPositionSize(); + + SurfaceResized( forceUpdate ); mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) ); mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) ); } @@ -616,6 +623,14 @@ void Window::OnRotation( const RotationEvent& rotation ) mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight ); + bool forceUpdate = false; + if( mWindowBase->IsEglWindowRotationSupported() ) + { + forceUpdate = true; + } + + SurfaceResized( forceUpdate ); + mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mRotationAngle, mWindowHeight ) ); // Emit signal diff --git a/dali/internal/window-system/common/window-render-surface.cpp b/dali/internal/window-system/common/window-render-surface.cpp index 3a316f8..a89b444 100644 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -114,6 +114,7 @@ void WindowRenderSurface::Initialize( Any surface ) if( mScreenRotationAngle != 0 ) { mScreenRotationFinished = false; + mResizeFinished = false; } } @@ -144,12 +145,6 @@ void WindowRenderSurface::SetTransparency( bool transparent ) void WindowRenderSurface::RequestRotation( int angle, int width, int height ) { - if( !mRotationSupported ) - { - DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: Rotation is not supported!\n" ); - return; - } - if( !mRotationTrigger ) { TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface(); @@ -187,6 +182,11 @@ void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpi mWindowBase->GetDpi( dpiHorizontal, dpiVertical ); } +int WindowRenderSurface::GetOrientation() const +{ + return mWindowBase->GetOrientation(); +} + void WindowRenderSurface::InitializeGraphics() { @@ -339,11 +339,11 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) if( resizingSurface ) { + int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; + // Window rotate or screen rotate if( !mRotationFinished || !mScreenRotationFinished ) { - int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; - mWindowBase->SetEglWindowRotation( totalAngle ); mWindowBase->SetEglWindowBufferTransform( totalAngle ); @@ -360,9 +360,23 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) } // Resize case - if( !mResizeFinished ) + if ( !mResizeFinished ) { - mWindowBase->ResizeEglWindow( mPositionSize ); + Dali::PositionSize positionSize; + positionSize.x = mPositionSize.x; + positionSize.y = mPositionSize.y; + if( totalAngle == 0 || totalAngle == 180 ) + { + positionSize.width = mPositionSize.width; + positionSize.height = mPositionSize.height; + } + else + { + positionSize.width = mPositionSize.height; + positionSize.height = mPositionSize.width; + } + + mWindowBase->ResizeEglWindow( positionSize ); mResizeFinished = true; DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PreRender: Set resize\n" ); @@ -469,6 +483,7 @@ void WindowRenderSurface::OutputTransformed() { mScreenRotationAngle = screenRotationAngle; mScreenRotationFinished = false; + mResizeFinished = false; mOutputTransformedSignal.Emit(); diff --git a/dali/internal/window-system/common/window-render-surface.h b/dali/internal/window-system/common/window-render-surface.h index 55bc955..76c8d19 100644 --- a/dali/internal/window-system/common/window-render-surface.h +++ b/dali/internal/window-system/common/window-render-surface.h @@ -130,6 +130,12 @@ public: // from Dali::Integration::RenderSurface virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Integration::RenderSurface::InitializeGraphics() */ virtual void InitializeGraphics() override; diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp index 06490d2..1b4e54b 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp @@ -584,7 +584,10 @@ WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surfa mBrightness( 0 ), mBrightnessChangeState( 0 ), mBrightnessChangeDone( true ), - mOwnSurface( false ) + mOwnSurface( false ), + mWindowRotationAngle( 0 ), + mScreenRotationAngle( 0 ), + mSupportedPreProtation( 0 ) #ifdef DALI_ELDBUS_AVAILABLE , mSystemConnection( NULL ) #endif @@ -1316,9 +1319,10 @@ bool WindowBaseEcoreWl::IsEglWindowRotationSupported() wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) ); if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { + mSupportedPreProtation = true; return true; } - + mSupportedPreProtation = false; return false; } @@ -2059,6 +2063,16 @@ void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVe dpiVertical = int( yres + 0.5f ); } +int WindowBaseEcoreWl::GetOrientation() const +{ + int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360; + if( mSupportedPreProtation ) + { + orientation = 0; + } + return orientation; +} + int WindowBaseEcoreWl::GetScreenRotationAngle() { int transform = 0; @@ -2072,14 +2086,21 @@ int WindowBaseEcoreWl::GetScreenRotationAngle() transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) ); } - return transform * 90; + mScreenRotationAngle = transform * 90; + return mScreenRotationAngle; } void WindowBaseEcoreWl::SetWindowRotationAngle( int degree ) { + mWindowRotationAngle = degree; ecore_wl_window_rotation_set( mEcoreWindow, degree ); } +int WindowBaseEcoreWl::GetWindowRotationAngle() +{ + return mWindowRotationAngle; +} + void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height ) { ecore_wl_window_rotation_change_done_send( mEcoreWindow ); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h index 48ab90c..1570c5d 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h @@ -395,6 +395,12 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle() */ virtual int GetScreenRotationAngle() override; @@ -405,6 +411,11 @@ public: virtual void SetWindowRotationAngle( int degree ) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle() + */ + virtual int GetWindowRotationAngle() override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() */ virtual void WindowRotationCompleted( int degree, int width, int height ) override; @@ -470,6 +481,9 @@ private: bool mOwnSurface; + int mWindowRotationAngle; + int mScreenRotationAngle; + int mSupportedPreProtation; #ifdef DALI_ELDBUS_AVAILABLE Eldbus_Connection* mSystemConnection; #endif // DALI_ELDBUS_AVAILABLE diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index 5d1a51a..2400ad6 100755 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -601,7 +601,10 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any sur mBrightnessChangeDone( true ), mOwnSurface( false ), mMoveResizeSerial( 0 ), - mLastSubmittedMoveResizeSerial( 0 ) + mLastSubmittedMoveResizeSerial( 0 ), + mWindowRotationAngle( 0 ), + mScreenRotationAngle( 0 ), + mSupportedPreProtation( 0 ) #ifdef DALI_ELDBUS_AVAILABLE , mSystemConnection( NULL ) #endif @@ -830,7 +833,7 @@ void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event ) if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnRotation\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnRotation\n" ); RotationEvent rotationEvent; rotationEvent.angle = ev->angle; @@ -969,7 +972,7 @@ void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event mTouchEventSignal.Emit( point, touchEvent->timestamp ); - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" ); } } @@ -979,7 +982,7 @@ void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event ) if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z ); WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp ); @@ -991,7 +994,7 @@ void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event ) { Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event ); - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" ); int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1; int timeStamp = detentEvent->timestamp; @@ -1007,7 +1010,7 @@ void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event ) if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" ); std::string keyName( keyEvent->keyname ); std::string logicalKey( "" ); @@ -1061,7 +1064,7 @@ void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event ) if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" ); std::string keyName( keyEvent->keyname ); std::string logicalKey( "" ); @@ -1361,9 +1364,10 @@ bool WindowBaseEcoreWl2::IsEglWindowRotationSupported() wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) ); if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED ) { + mSupportedPreProtation = true; return true; } - + mSupportedPreProtation = false; return false; } @@ -2105,6 +2109,16 @@ void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiV dpiVertical = int( yres + 0.5f ); } +int WindowBaseEcoreWl2::GetOrientation() const +{ + int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360; + if( mSupportedPreProtation ) + { + orientation = 0; + } + return orientation; +} + int WindowBaseEcoreWl2::GetScreenRotationAngle() { int transform = 0; @@ -2117,15 +2131,21 @@ int WindowBaseEcoreWl2::GetScreenRotationAngle() { transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) ); } - - return transform * 90; + mScreenRotationAngle = transform * 90; + return mScreenRotationAngle; } void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree ) { + mWindowRotationAngle = degree; ecore_wl2_window_rotation_set( mEcoreWindow, degree ); } +int WindowBaseEcoreWl2::GetWindowRotationAngle() +{ + return mWindowRotationAngle; +} + void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height ) { ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height ); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index 6a4694c..7744545 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -400,6 +400,12 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle() */ virtual int GetScreenRotationAngle() override; @@ -410,6 +416,11 @@ public: virtual void SetWindowRotationAngle( int degree ) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle() + */ + virtual int GetWindowRotationAngle() override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() */ virtual void WindowRotationCompleted( int degree, int width, int height ) override; @@ -478,6 +489,9 @@ private: volatile uint32_t mMoveResizeSerial; uint32_t mLastSubmittedMoveResizeSerial; + int mWindowRotationAngle; + int mScreenRotationAngle; + int mSupportedPreProtation; #ifdef DALI_ELDBUS_AVAILABLE Eldbus_Connection* mSystemConnection; #endif // DALI_ELDBUS_AVAILABLE diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp index 54004b1..e69e8f1 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp @@ -142,6 +142,11 @@ void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned i dpiVertical = int( yres + 0.5f ); } +int NativeRenderSurfaceEcoreWl::GetOrientation() const +{ + return 0; +} + void NativeRenderSurfaceEcoreWl::InitializeGraphics() { DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter ); diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h index 1a1affc..00e7133 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h @@ -84,6 +84,12 @@ public: // from Dali::Integration::RenderSurface virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Integration::RenderSurface::InitializeGraphics() */ virtual void InitializeGraphics() override; diff --git a/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.cpp index 514b049..41a44da 100644 --- a/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.cpp @@ -150,6 +150,11 @@ void PixmapRenderSurfaceEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned in dpiVertical = int( yres + 0.5f ); } +int PixmapRenderSurfaceEcoreX::GetOrientation() const +{ + return 0; +} + void PixmapRenderSurfaceEcoreX::InitializeGraphics() { mGraphics = &mAdaptor->GetGraphicsInterface(); diff --git a/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h b/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h index 1e51708..c9d8da7 100644 --- a/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h +++ b/dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h @@ -83,6 +83,12 @@ public: // from Dali::Integration::RenderSurface virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Integration::RenderSurface::InitializeGraphics() */ virtual void InitializeGraphics() override; diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp index e2f650b..76395e2 100755 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp @@ -829,6 +829,11 @@ void WindowBaseEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVer dpiVertical = ecore_x_dpi_get(); } +int WindowBaseEcoreX::GetOrientation() const +{ + return 0; +} + int WindowBaseEcoreX::GetScreenRotationAngle() { return 0; @@ -838,6 +843,11 @@ void WindowBaseEcoreX::SetWindowRotationAngle( int degree ) { } +int WindowBaseEcoreX::GetWindowRotationAngle() +{ + return 0; +} + void WindowBaseEcoreX::WindowRotationCompleted( int degree, int width, int height ) { } diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h index c30eba6..1a91766 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h @@ -329,6 +329,12 @@ public: virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle() */ virtual int GetScreenRotationAngle() override; @@ -339,6 +345,11 @@ public: virtual void SetWindowRotationAngle( int degree ) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle() + */ + virtual int GetWindowRotationAngle() override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() */ virtual void WindowRotationCompleted( int degree, int width, int height ) override; diff --git a/dali/internal/window-system/windows/platform-implement-win.cpp b/dali/internal/window-system/windows/platform-implement-win.cpp index 1d79ce8..e6075f3 100755 --- a/dali/internal/window-system/windows/platform-implement-win.cpp +++ b/dali/internal/window-system/windows/platform-implement-win.cpp @@ -1,33 +1,33 @@ -/* -* Copyright (c) 2018 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include - -static constexpr float INCH = 25.4; - -using namespace std; - +/* +* Copyright (c) 2018 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +static constexpr float INCH = 25.4; + +using namespace std; + namespace Dali { @@ -36,350 +36,355 @@ namespace Internal namespace Adaptor { - -namespace WindowsPlatformImplementation -{ - -void RunLoop() -{ - MSG nMsg = { 0 }; - - while( GetMessage( &nMsg, 0, NULL, NULL ) ) - { - if( WIN_CALLBACK_EVENT == nMsg.message ) - { - Dali::CallbackBase *callback = ( Dali::CallbackBase* )nMsg.wParam; - Dali::CallbackBase::Execute( *callback ); - } - - TranslateMessage( &nMsg ); - DispatchMessage( &nMsg ); - - if( WM_CLOSE == nMsg.message ) - { - break; - } - } -} - -void GetDPI( uint64_t hWnd, float &xDpi, float &yDpi ) -{ - HDC hdcScreen = GetDC( reinterpret_cast( hWnd ) ); - - int32_t iX = GetDeviceCaps( hdcScreen, HORZRES ); // pixel - int32_t iY = GetDeviceCaps( hdcScreen, VERTRES ); // pixel - int32_t iPhsX = GetDeviceCaps( hdcScreen, HORZSIZE ); // mm - int32_t iPhsY = GetDeviceCaps( hdcScreen, VERTSIZE ); // mm - - xDpi = static_cast( iX ) / static_cast( iPhsX ) * INCH; - yDpi = static_cast( iY ) / static_cast( iPhsY ) * INCH; -} - -CallbackBase *listener = NULL; - -LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if( NULL != listener ) - { - TWinEventInfo eventInfo( reinterpret_cast( hWnd ), uMsg, wParam, lParam); - CallbackBase::Execute( *listener, &eventInfo ); - } - - LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam ); - return ret; -} - -DWORD windowStyle = WS_OVERLAPPED; - -int32_t GetEdgeWidth() -{ - switch( windowStyle ) - { - case WS_OVERLAPPED: - { - return 8; - } - default: - { - return 0; - } - } -} - -int32_t GetEdgeHeight() -{ - switch( windowStyle ) - { - case WS_OVERLAPPED: - { - return 18; - } - default: - { - return 0; - } - } -} - -class WindowsDisplayInfo -{ -public: - static int GetColorDepth() - { - DALI_ASSERT_DEBUG(colorDepth >= 0 && "HWND hasn't been created, no color depth"); - return colorDepth; - } - - static void SetHWND( HWND inHWnd ) - { - if( hWnd != inHWnd ) - { - hWnd = inHWnd; - hdc = GetDC( hWnd ); - colorDepth = GetDeviceCaps( WindowsDisplayInfo::hdc, BITSPIXEL ) * GetDeviceCaps( WindowsDisplayInfo::hdc, PLANES ); - } - } - -private: - static int colorDepth; - static HWND hWnd; - static HDC hdc; -}; - -int WindowsDisplayInfo::colorDepth = -1; -HWND WindowsDisplayInfo::hWnd = NULL; -HDC WindowsDisplayInfo::hdc = NULL; - -int GetColorDepth() -{ - return WindowsDisplayInfo::GetColorDepth(); -} - -uint64_t CreateHwnd( - _In_opt_ const char *lpClassName, - _In_opt_ const char *lpWindowName, - _In_ int X, - _In_ int Y, - _In_ int nWidth, - _In_ int nHeight, - _In_opt_ uint64_t parent) -{ - WNDCLASS cs = { 0 }; - cs.cbClsExtra = 0; - cs.cbWndExtra = 0; - cs.hbrBackground = (HBRUSH)( COLOR_WINDOW + 2 ); - cs.hCursor = NULL; - cs.hIcon = NULL; - cs.hInstance = GetModuleHandle( NULL ); - cs.lpfnWndProc = (WNDPROC)WinProc; - cs.lpszClassName = lpClassName; - cs.lpszMenuName = NULL; - cs.style = CS_VREDRAW | CS_HREDRAW; - RegisterClass( &cs ); - - HWND hWnd = CreateWindow( lpClassName, lpWindowName, windowStyle, X, Y, nWidth + 2 * GetEdgeWidth(), nHeight + 2 * GetEdgeHeight(), NULL, NULL, cs.hInstance, NULL ); - ShowWindow( hWnd, SW_SHOW ); - - WindowsDisplayInfo::SetHWND( hWnd ); - - return reinterpret_cast( hWnd ); -} - -void SetListener( CallbackBase *callback ) -{ - listener = callback; -} - -bool PostWinMessage( - _In_ uint32_t Msg, - _In_ uint32_t wParam, - _In_ uint64_t lParam, - _In_ uint64_t hWnd) -{ - return (bool)PostMessage( reinterpret_cast( hWnd ), Msg, wParam, lParam ); -} - -bool PostWinThreadMessage( - _In_ uint32_t Msg, - _In_ uint32_t wParam, - _In_ uint64_t lParam, - _In_ uint64_t threadID/* = -1*/ ) -{ - if( -1 == threadID ) - { - threadID = GetCurrentThreadId(); - } - - return (bool)PostThreadMessage( threadID, Msg, wParam, lParam ); -} - -void ShowWindow( uint64_t hWnd) -{ - ::ShowWindow( reinterpret_cast( hWnd ), SW_SHOW); -} - -void HideWindow( uint64_t hWnd) -{ - ::ShowWindow( reinterpret_cast( hWnd ), SW_HIDE); -} - -struct TTimerCallbackInfo -{ - void *data; - timerCallback callback; - HWND hWnd; -}; - -void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime) -{ - TTimerCallbackInfo *info = (TTimerCallbackInfo*)nTimerid; - info->callback( info->data ); -} - -int SetTimer(int interval, timerCallback callback, void *data) -{ - TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo; - callbackInfo->data = data; - callbackInfo->callback = callback; - callbackInfo->hWnd = ::GetActiveWindow(); - - UINT_PTR timerID = (UINT_PTR)callbackInfo; - ::SetTimer( callbackInfo->hWnd, timerID, interval, TimerProc ); - - return timerID; -} - -void KillTimer(int id) -{ - TTimerCallbackInfo *info = (TTimerCallbackInfo*)id; - ::KillTimer( info->hWnd, id ); - delete info; -} - -const char* GetKeyName( int keyCode ) -{ - switch( keyCode ) - { - case VK_BACK: - { - return "Backspace"; - } - case VK_TAB: - { - return "Tab"; - } - case VK_RETURN: - { - return "Return"; - } - case VK_ESCAPE: - { - return "Escape"; - } - case VK_SPACE: - { - return "Space"; - } - case VK_LEFT: - { - return "Left"; - } - case VK_UP: - { - return "Up"; - } - case VK_RIGHT: - { - return "Right"; - } - case VK_DOWN: - { - return "Down"; - } - case 48: - { - return "0"; - } - case 49: - { - return "1"; - } - case 50: - { - return "2"; - } - case 51: - { - return "3"; - } - case 52: - { - return "4"; - } - case 53: - { - return "5"; - } - case 54: - { - return "6"; - } - case 55: - { - return "7"; - } - case 56: - { - return "8"; - } - case 57: - { - return "9"; - } - default: - { - break; - } - } - - return ""; -} - -static LARGE_INTEGER cpuFrequency; -static LARGE_INTEGER *pCpuFrequency = NULL; - -uint64_t GetCurrentThreadId() -{ - return ::GetCurrentThreadId(); -} - -void GetNanoseconds( uint64_t& timeInNanoseconds ) -{ - if( NULL == pCpuFrequency ) - { - pCpuFrequency = &cpuFrequency; - QueryPerformanceFrequency( pCpuFrequency ); - } - - LARGE_INTEGER curTime; - QueryPerformanceCounter( &curTime ); - - timeInNanoseconds = static_cast(curTime.QuadPart) / static_cast(pCpuFrequency->QuadPart) * 1000000000; -} - -unsigned int GetCurrentMilliSeconds( void ) -{ - if( NULL == pCpuFrequency ) - { - pCpuFrequency = &cpuFrequency; - QueryPerformanceFrequency( pCpuFrequency ); - } - - LARGE_INTEGER curTime; - QueryPerformanceCounter( &curTime ); - - return curTime.QuadPart * 1000 / pCpuFrequency->QuadPart; -} + +namespace WindowsPlatformImplementation +{ + +void RunLoop() +{ + MSG nMsg = { 0 }; + + while( GetMessage( &nMsg, 0, NULL, NULL ) ) + { + if( WIN_CALLBACK_EVENT == nMsg.message ) + { + Dali::CallbackBase *callback = ( Dali::CallbackBase* )nMsg.wParam; + Dali::CallbackBase::Execute( *callback ); + } + + TranslateMessage( &nMsg ); + DispatchMessage( &nMsg ); + + if( WM_CLOSE == nMsg.message ) + { + break; + } + } +} + +void GetDPI( uint64_t hWnd, float &xDpi, float &yDpi ) +{ + HDC hdcScreen = GetDC( reinterpret_cast( hWnd ) ); + + int32_t iX = GetDeviceCaps( hdcScreen, HORZRES ); // pixel + int32_t iY = GetDeviceCaps( hdcScreen, VERTRES ); // pixel + int32_t iPhsX = GetDeviceCaps( hdcScreen, HORZSIZE ); // mm + int32_t iPhsY = GetDeviceCaps( hdcScreen, VERTSIZE ); // mm + + xDpi = static_cast( iX ) / static_cast( iPhsX ) * INCH; + yDpi = static_cast( iY ) / static_cast( iPhsY ) * INCH; +} + +int GetOrientation() +{ + return 0; +} + +CallbackBase *listener = NULL; + +LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if( NULL != listener ) + { + TWinEventInfo eventInfo( reinterpret_cast( hWnd ), uMsg, wParam, lParam); + CallbackBase::Execute( *listener, &eventInfo ); + } + + LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam ); + return ret; +} + +DWORD windowStyle = WS_OVERLAPPED; + +int32_t GetEdgeWidth() +{ + switch( windowStyle ) + { + case WS_OVERLAPPED: + { + return 8; + } + default: + { + return 0; + } + } +} + +int32_t GetEdgeHeight() +{ + switch( windowStyle ) + { + case WS_OVERLAPPED: + { + return 18; + } + default: + { + return 0; + } + } +} + +class WindowsDisplayInfo +{ +public: + static int GetColorDepth() + { + DALI_ASSERT_DEBUG(colorDepth >= 0 && "HWND hasn't been created, no color depth"); + return colorDepth; + } + + static void SetHWND( HWND inHWnd ) + { + if( hWnd != inHWnd ) + { + hWnd = inHWnd; + hdc = GetDC( hWnd ); + colorDepth = GetDeviceCaps( WindowsDisplayInfo::hdc, BITSPIXEL ) * GetDeviceCaps( WindowsDisplayInfo::hdc, PLANES ); + } + } + +private: + static int colorDepth; + static HWND hWnd; + static HDC hdc; +}; + +int WindowsDisplayInfo::colorDepth = -1; +HWND WindowsDisplayInfo::hWnd = NULL; +HDC WindowsDisplayInfo::hdc = NULL; + +int GetColorDepth() +{ + return WindowsDisplayInfo::GetColorDepth(); +} + +uint64_t CreateHwnd( + _In_opt_ const char *lpClassName, + _In_opt_ const char *lpWindowName, + _In_ int X, + _In_ int Y, + _In_ int nWidth, + _In_ int nHeight, + _In_opt_ uint64_t parent) +{ + WNDCLASS cs = { 0 }; + cs.cbClsExtra = 0; + cs.cbWndExtra = 0; + cs.hbrBackground = (HBRUSH)( COLOR_WINDOW + 2 ); + cs.hCursor = NULL; + cs.hIcon = NULL; + cs.hInstance = GetModuleHandle( NULL ); + cs.lpfnWndProc = (WNDPROC)WinProc; + cs.lpszClassName = lpClassName; + cs.lpszMenuName = NULL; + cs.style = CS_VREDRAW | CS_HREDRAW; + RegisterClass( &cs ); + + HWND hWnd = CreateWindow( lpClassName, lpWindowName, windowStyle, X, Y, nWidth + 2 * GetEdgeWidth(), nHeight + 2 * GetEdgeHeight(), NULL, NULL, cs.hInstance, NULL ); + ShowWindow( hWnd, SW_SHOW ); + + WindowsDisplayInfo::SetHWND( hWnd ); + + return reinterpret_cast( hWnd ); +} + +void SetListener( CallbackBase *callback ) +{ + listener = callback; +} + +bool PostWinMessage( + _In_ uint32_t Msg, + _In_ uint32_t wParam, + _In_ uint64_t lParam, + _In_ uint64_t hWnd) +{ + return (bool)PostMessage( reinterpret_cast( hWnd ), Msg, wParam, lParam ); +} + +bool PostWinThreadMessage( + _In_ uint32_t Msg, + _In_ uint32_t wParam, + _In_ uint64_t lParam, + _In_ uint64_t threadID/* = -1*/ ) +{ + if( -1 == threadID ) + { + threadID = GetCurrentThreadId(); + } + + return (bool)PostThreadMessage( threadID, Msg, wParam, lParam ); +} + +void ShowWindow( uint64_t hWnd) +{ + ::ShowWindow( reinterpret_cast( hWnd ), SW_SHOW); +} + +void HideWindow( uint64_t hWnd) +{ + ::ShowWindow( reinterpret_cast( hWnd ), SW_HIDE); +} + +struct TTimerCallbackInfo +{ + void *data; + timerCallback callback; + HWND hWnd; +}; + +void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime) +{ + TTimerCallbackInfo *info = (TTimerCallbackInfo*)nTimerid; + info->callback( info->data ); +} + +int SetTimer(int interval, timerCallback callback, void *data) +{ + TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo; + callbackInfo->data = data; + callbackInfo->callback = callback; + callbackInfo->hWnd = ::GetActiveWindow(); + + UINT_PTR timerID = (UINT_PTR)callbackInfo; + ::SetTimer( callbackInfo->hWnd, timerID, interval, TimerProc ); + + return timerID; +} + +void KillTimer(int id) +{ + TTimerCallbackInfo *info = (TTimerCallbackInfo*)id; + ::KillTimer( info->hWnd, id ); + delete info; +} + +const char* GetKeyName( int keyCode ) +{ + switch( keyCode ) + { + case VK_BACK: + { + return "Backspace"; + } + case VK_TAB: + { + return "Tab"; + } + case VK_RETURN: + { + return "Return"; + } + case VK_ESCAPE: + { + return "Escape"; + } + case VK_SPACE: + { + return "Space"; + } + case VK_LEFT: + { + return "Left"; + } + case VK_UP: + { + return "Up"; + } + case VK_RIGHT: + { + return "Right"; + } + case VK_DOWN: + { + return "Down"; + } + case 48: + { + return "0"; + } + case 49: + { + return "1"; + } + case 50: + { + return "2"; + } + case 51: + { + return "3"; + } + case 52: + { + return "4"; + } + case 53: + { + return "5"; + } + case 54: + { + return "6"; + } + case 55: + { + return "7"; + } + case 56: + { + return "8"; + } + case 57: + { + return "9"; + } + default: + { + break; + } + } + + return ""; +} + +static LARGE_INTEGER cpuFrequency; +static LARGE_INTEGER *pCpuFrequency = NULL; + +uint64_t GetCurrentThreadId() +{ + return ::GetCurrentThreadId(); +} + +void GetNanoseconds( uint64_t& timeInNanoseconds ) +{ + if( NULL == pCpuFrequency ) + { + pCpuFrequency = &cpuFrequency; + QueryPerformanceFrequency( pCpuFrequency ); + } + + LARGE_INTEGER curTime; + QueryPerformanceCounter( &curTime ); + + timeInNanoseconds = static_cast(curTime.QuadPart) / static_cast(pCpuFrequency->QuadPart) * 1000000000; +} + +unsigned int GetCurrentMilliSeconds( void ) +{ + if( NULL == pCpuFrequency ) + { + pCpuFrequency = &cpuFrequency; + QueryPerformanceFrequency( pCpuFrequency ); + } + + LARGE_INTEGER curTime; + QueryPerformanceCounter( &curTime ); + + return curTime.QuadPart * 1000 / pCpuFrequency->QuadPart; +} } // namespace WindowsPlatformImplement @@ -387,4 +392,4 @@ unsigned int GetCurrentMilliSeconds( void ) } // namespace internal -} // namespace Dali +} // namespace Dali diff --git a/dali/internal/window-system/windows/platform-implement-win.h b/dali/internal/window-system/windows/platform-implement-win.h index 18b33c1..51e40f8 100755 --- a/dali/internal/window-system/windows/platform-implement-win.h +++ b/dali/internal/window-system/windows/platform-implement-win.h @@ -1,21 +1,21 @@ #ifndef PLATFORM_IMPLEMENT_WIN_INCLUDE #define PLATFORM_IMPLEMENT_WIN_INCLUDE -/* -* Copyright (c) 2018 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* +/* +* Copyright (c) 2018 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* */ // EXTERNAL_HEADERS @@ -25,14 +25,14 @@ typedef uint64_t WinWindowHandle; typedef uint64_t WinPixmap; -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ namespace WindowsPlatformImplementation { @@ -77,6 +77,8 @@ void KillTimer(int id); void GetDPI( uint64_t hWnd, float &xDpi, float &yDpi ); +int GetOrientation() const; + const char* GetKeyName( int keyCode ); uint64_t GetCurrentThreadId(); @@ -85,12 +87,12 @@ void GetNanoseconds( uint64_t& timeInNanoseconds ); unsigned int GetCurrentMilliSeconds( void ); -} // namespace WindowsPlatformImplement - -} // namespace Adaptor - -} // namespace internal - -} // namespace Dali - +} // namespace WindowsPlatformImplement + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + #endif // WIN32_WINDOWS_SYSTEM_INCLUDE diff --git a/dali/internal/window-system/windows/window-base-win.cpp b/dali/internal/window-system/windows/window-base-win.cpp index b1d6f1c..48da44c 100755 --- a/dali/internal/window-system/windows/window-base-win.cpp +++ b/dali/internal/window-system/windows/window-base-win.cpp @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL_HEADERS -#include -#include - -// INTERNAL HEADERS -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -namespace -{ - -const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE; -const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE; - -const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 ); - -#if defined(DEBUG_ENABLED) -Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" ); -#endif - -} // unnamed namespace - -WindowBaseWin::WindowBaseWin( Dali::PositionSize positionSize, Any surface, bool isTransparent ) -: mWin32Window( 0 ), - mOwnSurface( false ), - mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is. - mRotationAppSet( false ) -{ - Initialize( positionSize, surface, isTransparent ); -} - -WindowBaseWin::~WindowBaseWin() -{ - WindowsPlatformImplementation::PostWinMessage( WM_CLOSE, 0, 0, mWin32Window ); -} - -void WindowBaseWin::Initialize( PositionSize positionSize, Any surface, bool isTransparent ) -{ - // see if there is a surface in Any surface - unsigned int surfaceId = GetSurfaceId( surface ); - - // if the surface is empty, create a new one. - if( surfaceId == 0 ) - { - // we own the surface about to created - mOwnSurface = true; - CreateWinWindow( positionSize, isTransparent ); - } - else - { - // XLib should already be initialized so no point in calling XInitThreads - mWin32Window = static_cast< WinWindowHandle >( surfaceId ); - } - - WindowsPlatformImplementation::SetListener( MakeCallback( this, &WindowBaseWin::EventEntry ) ); -} - -void WindowBaseWin::OnDeleteRequest() -{ - mDeleteRequestSignal.Emit(); -} - -void WindowBaseWin::OnFocusIn( int type, TWinEventInfo *event ) -{ -} - -void WindowBaseWin::OnFocusOut( int type, TWinEventInfo *event ) -{ -} - -void WindowBaseWin::OnWindowDamaged( int type, TWinEventInfo *event ) -{ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL_HEADERS +#include +#include + +// INTERNAL HEADERS +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ + +const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE; +const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE; + +const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 ); + +#if defined(DEBUG_ENABLED) +Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" ); +#endif + +} // unnamed namespace + +WindowBaseWin::WindowBaseWin( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +: mWin32Window( 0 ), + mOwnSurface( false ), + mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is. + mRotationAppSet( false ) +{ + Initialize( positionSize, surface, isTransparent ); +} + +WindowBaseWin::~WindowBaseWin() +{ + WindowsPlatformImplementation::PostWinMessage( WM_CLOSE, 0, 0, mWin32Window ); +} + +void WindowBaseWin::Initialize( PositionSize positionSize, Any surface, bool isTransparent ) +{ + // see if there is a surface in Any surface + unsigned int surfaceId = GetSurfaceId( surface ); + + // if the surface is empty, create a new one. + if( surfaceId == 0 ) + { + // we own the surface about to created + mOwnSurface = true; + CreateWinWindow( positionSize, isTransparent ); + } + else + { + // XLib should already be initialized so no point in calling XInitThreads + mWin32Window = static_cast< WinWindowHandle >( surfaceId ); + } + + WindowsPlatformImplementation::SetListener( MakeCallback( this, &WindowBaseWin::EventEntry ) ); +} + +void WindowBaseWin::OnDeleteRequest() +{ + mDeleteRequestSignal.Emit(); +} + +void WindowBaseWin::OnFocusIn( int type, TWinEventInfo *event ) +{ +} + +void WindowBaseWin::OnFocusOut( int type, TWinEventInfo *event ) +{ +} + +void WindowBaseWin::OnWindowDamaged( int type, TWinEventInfo *event ) +{ Event_Mouse_Button* windowDamagedEvent( (Event_Mouse_Button*)event ); if( windowDamagedEvent->window == mWin32Window ) @@ -111,386 +111,394 @@ void WindowBaseWin::OnWindowDamaged( int type, TWinEventInfo *event ) mWindowDamagedSignal.Emit( area ); } -} - -void WindowBaseWin::OnMouseButtonDown( int type, TWinEventInfo *event ) -{ - Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); - touchEvent.timestamp = GetTickCount(); +} + +void WindowBaseWin::OnMouseButtonDown( int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); + touchEvent.timestamp = GetTickCount(); touchEvent.x = LOWORD( event->lParam ); touchEvent.y = HIWORD( event->lParam ); - touchEvent.multi.device = DEVICE_MOUSE; - - if( touchEvent.window == mWin32Window ) - { - PointState::Type state ( PointState::DOWN ); - - Integration::Point point; - point.SetDeviceId( touchEvent.multi.device ); - point.SetState( state ); - point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); - point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); - point.SetPressure( touchEvent.multi.pressure ); - point.SetAngle( Degree( touchEvent.multi.angle ) ); - - mTouchEventSignal.Emit( point, touchEvent.timestamp ); - } -} - -void WindowBaseWin::OnMouseButtonUp( int type, TWinEventInfo *event ) -{ - Event_Mouse_Button touchEvent = *( (Event_Mouse_Button*)event ); - touchEvent.timestamp = GetTickCount(); + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state ( PointState::DOWN ); + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseButtonUp( int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *( (Event_Mouse_Button*)event ); + touchEvent.timestamp = GetTickCount(); touchEvent.x = LOWORD( event->lParam ); touchEvent.y = HIWORD( event->lParam ); - touchEvent.multi.device = DEVICE_MOUSE; - - if( touchEvent.window == mWin32Window ) - { - PointState::Type state( PointState::UP ); - - Integration::Point point; - point.SetDeviceId( touchEvent.multi.device ); - point.SetState( state ); - point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); - point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); - point.SetPressure( touchEvent.multi.pressure ); - point.SetAngle( Degree( touchEvent.multi.angle ) ); - - mTouchEventSignal.Emit( point, touchEvent.timestamp ); - } -} - -void WindowBaseWin::OnMouseButtonMove( int type, TWinEventInfo *event ) -{ - Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); - touchEvent.timestamp = GetTickCount(); + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state( PointState::UP ); + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseButtonMove( int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); + touchEvent.timestamp = GetTickCount(); touchEvent.x = LOWORD( event->lParam ); touchEvent.y = HIWORD( event->lParam ); - touchEvent.multi.device = DEVICE_MOUSE; - - if( touchEvent.window == mWin32Window ) - { - PointState::Type state( PointState::MOTION ); - - Integration::Point point; - point.SetDeviceId( touchEvent.multi.device ); - point.SetState( state ); - point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); - point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); - point.SetPressure( touchEvent.multi.pressure ); - point.SetAngle( Degree( touchEvent.multi.angle ) ); - - mTouchEventSignal.Emit( point, touchEvent.timestamp ); - } -} - -void WindowBaseWin::OnMouseWheel( int type, TWinEventInfo *event ) -{ - Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)( event )); - - if( mouseWheelEvent.window == mWin32Window ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z ); - - WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2( mouseWheelEvent.x, mouseWheelEvent.y ), mouseWheelEvent.z, mouseWheelEvent.timestamp ); - - mWheelEventSignal.Emit( wheelEvent ); - } -} - -void WindowBaseWin::OnKeyDown( int type, TWinEventInfo *event ) -{ - if( event->mWindow == mWin32Window ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); - - int keyCode = event->wParam; - std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) ); - std::string keyString; - std::string emptyString; - - int modifier( 0 ); - unsigned long time( 0 ); - - // Ensure key event string is not NULL as keys like SHIFT have a null string. - keyString.push_back( event->wParam ); - - Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); - - mKeyEventSignal.Emit( keyEvent ); - } -} - -void WindowBaseWin::OnKeyUp( int type, TWinEventInfo *event ) -{ - if( event->mWindow == mWin32Window ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); - - int keyCode = event->wParam; - std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) ); - std::string keyString; - std::string emptyString; - - int modifier( 0 ); - unsigned long time( 0 ); - - // Ensure key event string is not NULL as keys like SHIFT have a null string. - keyString.push_back( event->wParam ); - - Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); - - mKeyEventSignal.Emit( keyEvent ); - } -} - -Any WindowBaseWin::GetNativeWindow() -{ - return mWin32Window; -} - -int WindowBaseWin::GetNativeWindowId() -{ - return mWin32Window; -} - -EGLNativeWindowType WindowBaseWin::CreateEglWindow( int width, int height ) -{ - return reinterpret_cast< EGLNativeWindowType >( mWin32Window ); -} - -void WindowBaseWin::DestroyEglWindow() -{ -} - -void WindowBaseWin::SetEglWindowRotation( int angle ) -{ -} - -void WindowBaseWin::SetEglWindowBufferTransform( int angle ) -{ -} - -void WindowBaseWin::SetEglWindowTransform( int angle ) -{ -} - -void WindowBaseWin::ResizeEglWindow( PositionSize positionSize ) -{ -} - -bool WindowBaseWin::IsEglWindowRotationSupported() -{ - return false; -} - -void WindowBaseWin::Move( PositionSize positionSize ) -{ -} - -void WindowBaseWin::Resize( PositionSize positionSize ) -{ -} - -void WindowBaseWin::MoveResize( PositionSize positionSize ) -{ -} - -void WindowBaseWin::SetClass( const std::string& name, const std::string& className ) -{ -} - -void WindowBaseWin::Raise() -{ -} - -void WindowBaseWin::Lower() -{ -} - -void WindowBaseWin::Activate() -{ -} - -void WindowBaseWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) -{ -} - -void WindowBaseWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) -{ -} - -void WindowBaseWin::SetAcceptFocus( bool accept ) -{ -} - -void WindowBaseWin::Show() -{ -} - -void WindowBaseWin::Hide() -{ -} - -unsigned int WindowBaseWin::GetSupportedAuxiliaryHintCount() const -{ - return 0; -} - -std::string WindowBaseWin::GetSupportedAuxiliaryHint( unsigned int index ) const -{ - return std::string(); -} - -unsigned int WindowBaseWin::AddAuxiliaryHint( const std::string& hint, const std::string& value ) -{ - return 0; -} - -bool WindowBaseWin::RemoveAuxiliaryHint( unsigned int id ) -{ - return false; -} - -bool WindowBaseWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) -{ - return false; -} - -std::string WindowBaseWin::GetAuxiliaryHintValue( unsigned int id ) const -{ - return std::string(); -} - -unsigned int WindowBaseWin::GetAuxiliaryHintId( const std::string& hint ) const -{ - return 0; -} - -void WindowBaseWin::SetInputRegion( const Rect< int >& inputRegion ) -{ -} - -void WindowBaseWin::SetType( Dali::Window::Type type ) -{ -} - -bool WindowBaseWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) -{ - return false; -} - -Dali::Window::NotificationLevel::Type WindowBaseWin::GetNotificationLevel() const -{ - return Dali::Window::NotificationLevel::NONE; -} - -void WindowBaseWin::SetOpaqueState( bool opaque ) -{ -} - -bool WindowBaseWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) -{ - return false; -} - -Dali::Window::ScreenOffMode::Type WindowBaseWin::GetScreenOffMode() const -{ - return Dali::Window::ScreenOffMode::TIMEOUT; -} - -bool WindowBaseWin::SetBrightness( int brightness ) -{ - return false; -} - -int WindowBaseWin::GetBrightness() const -{ - return 0; -} - -bool WindowBaseWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) -{ - return false; -} - -bool WindowBaseWin::UngrabKey( Dali::KEY key ) -{ - return false; -} - -bool WindowBaseWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) -{ - return false; -} - -bool WindowBaseWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) -{ - return false; -} - -void WindowBaseWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) -{ - // calculate DPI - float xres, yres; - - //// 1 inch = 25.4 millimeters - WindowsPlatformImplementation::GetDPI( mWin32Window, xres, yres ); - - xres *= 1.5f; - yres *= 1.5f; - - dpiHorizontal = static_cast( xres + 0.5f ); // rounding - dpiVertical = static_cast( yres + 0.5f ); -} - -int WindowBaseWin::GetScreenRotationAngle() -{ - return 0; -} - -void WindowBaseWin::SetWindowRotationAngle( int degree ) -{ -} - -void WindowBaseWin::WindowRotationCompleted( int degree, int width, int height ) -{ -} - -void WindowBaseWin::SetTransparency( bool transparent ) -{ -} - -unsigned int WindowBaseWin::GetSurfaceId( Any surface ) const -{ - unsigned int surfaceId = 0; - - if ( surface.Empty() == false ) - { - // check we have a valid type - DALI_ASSERT_ALWAYS( (surface.GetType() == typeid ( WinWindowHandle ) ) - && "Surface type is invalid" ); - - surfaceId = AnyCast< WinWindowHandle >( surface ); - } - return surfaceId; -} - -void WindowBaseWin::CreateWinWindow( PositionSize positionSize, bool isTransparent ) -{ + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state( PointState::MOTION ); + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseWheel( int type, TWinEventInfo *event ) +{ + Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)( event )); + + if( mouseWheelEvent.window == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z ); + + WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2( mouseWheelEvent.x, mouseWheelEvent.y ), mouseWheelEvent.z, mouseWheelEvent.timestamp ); + + mWheelEventSignal.Emit( wheelEvent ); + } +} + +void WindowBaseWin::OnKeyDown( int type, TWinEventInfo *event ) +{ + if( event->mWindow == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); + + int keyCode = event->wParam; + std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) ); + std::string keyString; + std::string emptyString; + + int modifier( 0 ); + unsigned long time( 0 ); + + // Ensure key event string is not NULL as keys like SHIFT have a null string. + keyString.push_back( event->wParam ); + + Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +void WindowBaseWin::OnKeyUp( int type, TWinEventInfo *event ) +{ + if( event->mWindow == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); + + int keyCode = event->wParam; + std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) ); + std::string keyString; + std::string emptyString; + + int modifier( 0 ); + unsigned long time( 0 ); + + // Ensure key event string is not NULL as keys like SHIFT have a null string. + keyString.push_back( event->wParam ); + + Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +Any WindowBaseWin::GetNativeWindow() +{ + return mWin32Window; +} + +int WindowBaseWin::GetNativeWindowId() +{ + return mWin32Window; +} + +EGLNativeWindowType WindowBaseWin::CreateEglWindow( int width, int height ) +{ + return reinterpret_cast< EGLNativeWindowType >( mWin32Window ); +} + +void WindowBaseWin::DestroyEglWindow() +{ +} + +void WindowBaseWin::SetEglWindowRotation( int angle ) +{ +} + +void WindowBaseWin::SetEglWindowBufferTransform( int angle ) +{ +} + +void WindowBaseWin::SetEglWindowTransform( int angle ) +{ +} + +void WindowBaseWin::ResizeEglWindow( PositionSize positionSize ) +{ +} + +bool WindowBaseWin::IsEglWindowRotationSupported() +{ + return false; +} + +void WindowBaseWin::Move( PositionSize positionSize ) +{ +} + +void WindowBaseWin::Resize( PositionSize positionSize ) +{ +} + +void WindowBaseWin::MoveResize( PositionSize positionSize ) +{ +} + +void WindowBaseWin::SetClass( const std::string& name, const std::string& className ) +{ +} + +void WindowBaseWin::Raise() +{ +} + +void WindowBaseWin::Lower() +{ +} + +void WindowBaseWin::Activate() +{ +} + +void WindowBaseWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) +{ +} + +void WindowBaseWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) +{ +} + +void WindowBaseWin::SetAcceptFocus( bool accept ) +{ +} + +void WindowBaseWin::Show() +{ +} + +void WindowBaseWin::Hide() +{ +} + +unsigned int WindowBaseWin::GetSupportedAuxiliaryHintCount() const +{ + return 0; +} + +std::string WindowBaseWin::GetSupportedAuxiliaryHint( unsigned int index ) const +{ + return std::string(); +} + +unsigned int WindowBaseWin::AddAuxiliaryHint( const std::string& hint, const std::string& value ) +{ + return 0; +} + +bool WindowBaseWin::RemoveAuxiliaryHint( unsigned int id ) +{ + return false; +} + +bool WindowBaseWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) +{ + return false; +} + +std::string WindowBaseWin::GetAuxiliaryHintValue( unsigned int id ) const +{ + return std::string(); +} + +unsigned int WindowBaseWin::GetAuxiliaryHintId( const std::string& hint ) const +{ + return 0; +} + +void WindowBaseWin::SetInputRegion( const Rect< int >& inputRegion ) +{ +} + +void WindowBaseWin::SetType( Dali::Window::Type type ) +{ +} + +bool WindowBaseWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) +{ + return false; +} + +Dali::Window::NotificationLevel::Type WindowBaseWin::GetNotificationLevel() const +{ + return Dali::Window::NotificationLevel::NONE; +} + +void WindowBaseWin::SetOpaqueState( bool opaque ) +{ +} + +bool WindowBaseWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) +{ + return false; +} + +Dali::Window::ScreenOffMode::Type WindowBaseWin::GetScreenOffMode() const +{ + return Dali::Window::ScreenOffMode::TIMEOUT; +} + +bool WindowBaseWin::SetBrightness( int brightness ) +{ + return false; +} + +int WindowBaseWin::GetBrightness() const +{ + return 0; +} + +bool WindowBaseWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) +{ + return false; +} + +bool WindowBaseWin::UngrabKey( Dali::KEY key ) +{ + return false; +} + +bool WindowBaseWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) +{ + return false; +} + +bool WindowBaseWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) +{ + return false; +} + +void WindowBaseWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; + + //// 1 inch = 25.4 millimeters + WindowsPlatformImplementation::GetDPI( mWin32Window, xres, yres ); + + xres *= 1.5f; + yres *= 1.5f; + + dpiHorizontal = static_cast( xres + 0.5f ); // rounding + dpiVertical = static_cast( yres + 0.5f ); +} + +int WindowBaseWin::GetScreenRotationAngle() +{ + return 0; +} + +void WindowBaseWin::SetWindowRotationAngle( int degree ) +{ +} + +int WindowBaseWin::GetWindowRotationAngle() +{ +} + +void WindowBaseWin::WindowRotationCompleted( int degree, int width, int height ) +{ +} + +void WindowBaseWin::SetTransparency( bool transparent ) +{ +} + +int WindowBaseWin::GetOrientation() const +{ +} + +unsigned int WindowBaseWin::GetSurfaceId( Any surface ) const +{ + unsigned int surfaceId = 0; + + if ( surface.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( (surface.GetType() == typeid ( WinWindowHandle ) ) + && "Surface type is invalid" ); + + surfaceId = AnyCast< WinWindowHandle >( surface ); + } + return surfaceId; +} + +void WindowBaseWin::CreateWinWindow( PositionSize positionSize, bool isTransparent ) +{ long hWnd = WindowsPlatformImplementation::CreateHwnd( "Demo", "Demo", positionSize.x, positionSize.y, positionSize.width, positionSize.height, NULL ); WindowsPlatformImplementation::ShowWindow( hWnd ); mWin32Window = (WinWindowHandle)hWnd; - DALI_ASSERT_ALWAYS( mWin32Window != 0 && "There is no Windows window" ); -} - -void WindowBaseWin::EventEntry( TWinEventInfo *event ) -{ - unsigned int uMsg = event->uMsg; - + DALI_ASSERT_ALWAYS( mWin32Window != 0 && "There is no Windows window" ); +} + +void WindowBaseWin::EventEntry( TWinEventInfo *event ) +{ + unsigned int uMsg = event->uMsg; + switch( uMsg ) { case WM_SETFOCUS: @@ -547,14 +555,14 @@ void WindowBaseWin::EventEntry( TWinEventInfo *event ) break; } - default: + default: break; - } -} - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali - + } +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + diff --git a/dali/internal/window-system/windows/window-base-win.h b/dali/internal/window-system/windows/window-base-win.h index b0e48c6..0712188 100755 --- a/dali/internal/window-system/windows/window-base-win.h +++ b/dali/internal/window-system/windows/window-base-win.h @@ -327,6 +327,11 @@ public: virtual void SetWindowRotationAngle( int degree ) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle() + */ + virtual void GetWindowRotationAngle() override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() */ virtual void WindowRotationCompleted( int degree, int width, int height ) override; @@ -336,6 +341,11 @@ public: */ virtual void SetTransparency( bool transparent ) override; + /** + * @brief Return the orientation of the surface. + * @return The orientation + */ + virtual int GetOrientation() const override; private: /**