From b33cf8f8c44bc1be428692eba5859354c57f4d11 Mon Sep 17 00:00:00 2001 From: "xb.teng" Date: Mon, 25 Jun 2018 21:04:02 +0800 Subject: [PATCH] Add AllowTextPrediction/IsTextPredictionAllowed api Change-Id: I7fb9aacf7d2e38ebc16f3e8fb652632bdc16963f --- .../adaptor-framework/input-method-context.cpp | 10 ++++++++++ .../adaptor-framework/input-method-context.h | 13 +++++++++++++ .../input/common/input-method-context-impl.h | 9 +++++++++ .../input-method-context-impl-ecore-wl.cpp | 21 +++++++++++++++++++++ .../input-method-context-impl-ecore-wl.h | 9 +++++++++ .../ubuntu-x11/input-method-context-impl-x.cpp | 21 +++++++++++++++++++++ .../input/ubuntu-x11/input-method-context-impl-x.h | 9 +++++++++ 7 files changed, 92 insertions(+) diff --git a/dali/devel-api/adaptor-framework/input-method-context.cpp b/dali/devel-api/adaptor-framework/input-method-context.cpp index 11ef92e..427ae6c 100755 --- a/dali/devel-api/adaptor-framework/input-method-context.cpp +++ b/dali/devel-api/adaptor-framework/input-method-context.cpp @@ -186,6 +186,16 @@ bool InputMethodContext::FilterEventKey( const Dali::KeyEvent& keyEvent ) return Internal::Adaptor::InputMethodContext::GetImplementation(*this).FilterEventKey( keyEvent ); } +void InputMethodContext::AllowTextPrediction( bool prediction ) +{ + Internal::Adaptor::InputMethodContext::GetImplementation(*this).AllowTextPrediction( prediction ); +} + +bool InputMethodContext::IsTextPredictionAllowed() const +{ + return Internal::Adaptor::InputMethodContext::GetImplementation(*this).IsTextPredictionAllowed(); +} + InputMethodContext::ActivatedSignalType& InputMethodContext::ActivatedSignal() { return Internal::Adaptor::InputMethodContext::GetImplementation(*this).ActivatedSignal(); diff --git a/dali/devel-api/adaptor-framework/input-method-context.h b/dali/devel-api/adaptor-framework/input-method-context.h index 49901a1..6775ef2 100755 --- a/dali/devel-api/adaptor-framework/input-method-context.h +++ b/dali/devel-api/adaptor-framework/input-method-context.h @@ -399,6 +399,19 @@ public: */ bool FilterEventKey( const Dali::KeyEvent& keyEvent ); + /** + * @brief Sets whether the IM context should allow to use the text prediction. + * + * @param[in] prediction Whether to allow text prediction or not. + */ + void AllowTextPrediction( bool prediction ); + + /** + * @brief Gets whether the IM context allow to use the text prediction. + * + * @return Whether the IM allow text prediction or not. + */ + bool IsTextPredictionAllowed() const; public: // Signals diff --git a/dali/internal/input/common/input-method-context-impl.h b/dali/internal/input/common/input-method-context-impl.h index 5e7cc34..a46cdb5 100755 --- a/dali/internal/input/common/input-method-context-impl.h +++ b/dali/internal/input/common/input-method-context-impl.h @@ -236,6 +236,15 @@ public: */ virtual bool FilterEventKey( const Dali::KeyEvent& keyEvent ) { return false; } + /** + * @copydoc Dali::InputMethodContext::AllowTextPrediction() + */ + virtual void AllowTextPrediction( bool prediction ) {} + + /** + * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed() + */ + virtual bool IsTextPredictionAllowed() const { return false; } public: // Signals /** diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp index 6a83c43..ff46c94 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp @@ -920,6 +920,27 @@ bool InputMethodContextEcoreWl::FilterEventKey( const Dali::KeyEvent& keyEvent ) return eventHandled; } +void InputMethodContextEcoreWl::AllowTextPrediction( bool prediction ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::AllowTextPrediction\n" ); + + if( mIMFContext ) + { + ecore_imf_context_prediction_allow_set( mIMFContext, prediction ); + } +} + +bool InputMethodContextEcoreWl::IsTextPredictionAllowed() const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::IsTextPredictionAllowed\n" ); + bool prediction = false; + if( mIMFContext ) + { + prediction = ecore_imf_context_prediction_allow_get( mIMFContext ); + } + return prediction; +} + bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent ) { bool eventHandled( false ); diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h index 24fcd0b..4630637 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h @@ -226,6 +226,15 @@ public: */ bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override; + /** + * @copydoc Dali::InputMethodContext::AllowTextPrediction() + */ + void AllowTextPrediction( bool prediction ) override; + + /** + * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed() + */ + bool IsTextPredictionAllowed() const override; private: /** * Context created the first time and kept until deleted. diff --git a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp index 7afcf5a..3b7fcda 100755 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp @@ -727,6 +727,27 @@ bool InputMethodContextX::FilterEventKey( const Dali::KeyEvent& keyEvent ) return eventHandled; } +void InputMethodContextX::AllowTextPrediction( bool prediction ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::AllowTextPrediction\n" ); + + if( mIMFContext ) + { + ecore_imf_context_prediction_allow_set( mIMFContext, prediction ); + } +} + +bool InputMethodContextX::IsTextPredictionAllowed() const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::IsTextPredictionAllowed\n" ); + bool prediction = false; + if( mIMFContext ) + { + prediction = ecore_imf_context_prediction_allow_get( mIMFContext ); + } + return prediction; +} + bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent ) { bool eventHandled( false ); diff --git a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h index ff3d5c4..95ea0d5 100755 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h @@ -231,6 +231,15 @@ public: */ bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override; + /** + * @copydoc Dali::InputMethodContext::AllowTextPrediction() + */ + void AllowTextPrediction( bool prediction ) override; + + /** + * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed() + */ + bool IsTextPredictionAllowed() const override; private: /** * Context created the first time and kept until deleted. -- 2.7.4