From da04fa4fe75a739dcd4588de19ac2dcbd8c5684a Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 26 Apr 2022 13:55:59 +0900 Subject: [PATCH] Add ECORE_IMF_CALLBACK_SELECTION_SET to IMFContext added selection callback from IMF for tizen 7.0 new feature support Change-Id: Iaafe802a67cda24d06935e29b55d04c53dbf8b16 Signed-off-by: Bowon Ryu --- .../adaptor-framework/input-method-context.h | 32 ++++++++++++++++--- .../input/common/input-method-context-impl.h | 9 +++++- .../generic/input-method-context-impl-generic.cpp | 7 ++++- .../generic/input-method-context-impl-generic.h | 7 ++++- .../input/macos/input-method-context-impl-mac.h | 9 +++++- .../input-method-context-impl-ecore-wl.cpp | 36 +++++++++++++++++++++- .../input-method-context-impl-ecore-wl.h | 7 ++++- .../input/ubuntu-x11/input-method-context-impl-x.h | 9 +++++- .../input/windows/input-method-context-impl-win.h | 9 +++++- 9 files changed, 113 insertions(+), 12 deletions(-) diff --git a/dali/devel-api/adaptor-framework/input-method-context.h b/dali/devel-api/adaptor-framework/input-method-context.h index 78556d8..0487b06 100644 --- a/dali/devel-api/adaptor-framework/input-method-context.h +++ b/dali/devel-api/adaptor-framework/input-method-context.h @@ -2,7 +2,7 @@ #define DALI_INPUT_METHOD_CONTEXT_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -66,7 +66,8 @@ public: COMMIT, ///< Commit recieved DELETE_SURROUNDING, ///< Event to delete a range of characters from the string GET_SURROUNDING, ///< Event to query string and cursor position - PRIVATE_COMMAND ///< Private command sent from the input panel + PRIVATE_COMMAND, ///< Private command sent from the input panel + SELECTION_SET ///< input method needs to set the selection }; /** @@ -142,7 +143,9 @@ public: : predictiveString(), eventName(VOID), cursorOffset(0), - numberOfChars(0){}; + numberOfChars(0), + startIndex(0), + endIndex(0){}; /** * @brief Constructor @@ -156,7 +159,26 @@ public: : predictiveString(aPredictiveString), eventName(aEventName), cursorOffset(aCursorOffset), - numberOfChars(aNumberOfChars) + numberOfChars(aNumberOfChars), + startIndex(0), + endIndex(0) + { + } + + /** + * @brief Constructor + * + * @param[in] aEventName The name of the event from the InputMethodContext. + * @param[in] aStartIndex The start index of selection. + * @param[in] aEndIndex The end index of selection. + */ + EventData(EventType aEventName, int aStartIndex, int aEndIndex) + : predictiveString(), + eventName(aEventName), + cursorOffset(0), + numberOfChars(0), + startIndex(aStartIndex), + endIndex(aEndIndex) { } @@ -165,6 +187,8 @@ public: EventType eventName; ///< The name of the event from the InputMethodContext. int cursorOffset; ///< Start position from the current cursor position to start deleting characters. int numberOfChars; ///< number of characters to delete from the cursorOffset. + int startIndex; ///< The start index of selection. + int endIndex; ///< The end index of selection. }; /** diff --git a/dali/internal/input/common/input-method-context-impl.h b/dali/internal/input/common/input-method-context-impl.h index eba7424..6791e28 100644 --- a/dali/internal/input/common/input-method-context-impl.h +++ b/dali/internal/input/common/input-method-context-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_INPUT_COMMON_INPUT_METHOD_CONTEXT_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -177,6 +177,13 @@ public: { } + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + virtual void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) + { + } + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() diff --git a/dali/internal/input/generic/input-method-context-impl-generic.cpp b/dali/internal/input/generic/input-method-context-impl-generic.cpp index 38003b8..91db602 100644 --- a/dali/internal/input/generic/input-method-context-impl-generic.cpp +++ b/dali/internal/input/generic/input-method-context-impl-generic.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -146,6 +146,11 @@ void InputMethodContextGeneric::SendCommitContent(void* data, ImfContext* imfCon DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SendCommitContent\n"); } +void InputMethodContextGeneric::SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) +{ + DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SendSelectionSet\n"); +} + void InputMethodContextGeneric::NotifyCursorPosition() { DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::NotifyCursorPosition\n"); diff --git a/dali/internal/input/generic/input-method-context-impl-generic.h b/dali/internal/input/generic/input-method-context-impl-generic.h index ff83e50..34f3039 100644 --- a/dali/internal/input/generic/input-method-context-impl-generic.h +++ b/dali/internal/input/generic/input-method-context-impl-generic.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_GENERIC_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -134,6 +134,11 @@ public: */ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override; + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override; + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() diff --git a/dali/internal/input/macos/input-method-context-impl-mac.h b/dali/internal/input/macos/input-method-context-impl-mac.h index a651c08..978446d 100644 --- a/dali/internal/input/macos/input-method-context-impl-mac.h +++ b/dali/internal/input/macos/input-method-context-impl-mac.h @@ -1,7 +1,7 @@ #pragma once /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -136,6 +136,13 @@ public: { } + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override + { + } + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() 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 c15f14b..6945b15 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -272,6 +272,18 @@ void CommitContent(void* data, Ecore_IMF_Context* imfContext, void* eventInfo) } } +/** + * Called when the input method sends a selection set. + */ +void SelectionSet(void* data, Ecore_IMF_Context* imfContext, void* eventInfo) +{ + if(data) + { + InputMethodContextEcoreWl* inputMethodContext = static_cast(data); + inputMethodContext->SendSelectionSet(data, imfContext, eventInfo); + } +} + int GetWindowIdFromActor(Dali::Actor actor) { int windowId = kUninitializedWindowId; @@ -397,6 +409,7 @@ void InputMethodContextEcoreWl::ConnectCallbacks() ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this); ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this); ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent, this); + ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_SELECTION_SET, SelectionSet, this); ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this); ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this); @@ -418,6 +431,7 @@ void InputMethodContextEcoreWl::DisconnectCallbacks() ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding); ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand); ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent); + ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_SELECTION_SET, SelectionSet); ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback); ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback); @@ -743,6 +757,26 @@ void InputMethodContextEcoreWl::SendCommitContent(void* data, ImfContext* imfCon } } +/** + * Called when the input method selection set. + */ +void InputMethodContextEcoreWl::SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) +{ + DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendCommitContent\n"); + + if(Dali::Adaptor::IsAvailable()) + { + Ecore_IMF_Event_Selection* selection = static_cast(eventInfo); + if(selection) + { + DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendSelectionSet selection start index : %d, end index : %d\n", selection->start, selection->end); + Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::SELECTION_SET, selection->start, selection->end); + Dali::InputMethodContext handle(this); + mEventSignal.Emit(handle, imfData); + } + } +} + void InputMethodContextEcoreWl::NotifyCursorPosition() { DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::NotifyCursorPosition\n"); 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 e133a42..0cdfcb7 100644 --- 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 @@ -2,7 +2,7 @@ #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -131,6 +131,11 @@ public: */ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override; + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override; + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() 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 8727249..4e028c2 100644 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -140,6 +140,13 @@ public: { } + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override + { + } + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() diff --git a/dali/internal/input/windows/input-method-context-impl-win.h b/dali/internal/input/windows/input-method-context-impl-win.h index e89a502..a36d0bd 100644 --- a/dali/internal/input/windows/input-method-context-impl-win.h +++ b/dali/internal/input/windows/input-method-context-impl-win.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -138,6 +138,13 @@ public: { } + /** + * @copydoc Dali::InputMethodContext::SendSelectionSet() + */ + void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override + { + } + // Cursor related /** * @copydoc Dali::InputMethodContext::NotifyCursorPosition() -- 2.7.4