2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUi_InputConnectionImpl.cpp
20 * @brief This is the implementation file for the _InputConnectionImpl class.
23 #include <Elementary.h>
24 #include <FBaseDataType.h>
25 #include <FBaseSysLog.h>
26 #include <FUiInputConnection.h>
28 #include "FUi_Control.h"
29 #include "FUi_ControlImpl.h"
30 #include "FUi_ControlManager.h"
31 #include "FUi_CoordinateSystemUtils.h"
32 #include "FUi_EcoreEvas.h"
33 #include "FUi_EcoreEvasMgr.h"
34 #include "FUi_InputConnectionImpl.h"
35 #include "FUi_UiEventManager.h"
36 #include "FUiAnim_EflNode.h"
37 #include "FUiAnim_VisualElement.h"
38 #include "FUi_Window.h"
39 #include "FUiAnim_EflLayer.h"
40 #include "FUiAnim_RootVisualElement.h"
42 using namespace Tizen::Base;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Locales;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Animations;
50 const int LANGUAGE_CODE_START = 0;
51 const int LANGUAGE_CODE_MAX = 2;
54 OnInputPanelShowStateEvent(void* pData, Ecore_IMF_Context* pContext, int value)
56 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pData is null ");
57 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pContext is null ");
59 SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelShowStateEvent is called.[ctx=0x%x, showState=%d]\n", pContext, value);
61 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
62 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
63 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
64 InputConnection* pInputConnection = pImpl->GetInputConnection();
68 Ecore_IMF_Input_Panel_State ecoreInputPanelShowState = static_cast<Ecore_IMF_Input_Panel_State>(value);
69 InputPanelShowState inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
71 switch (ecoreInputPanelShowState)
73 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
74 inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW;
76 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
77 inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
79 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
85 r = pImpl->SetInputPanelShowState(inputPanelState);
86 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
90 pListener->OnInputConnectionPanelShowStateChanged(*pInputConnection, inputPanelState);
94 pListenerF->OnInputConnectionPanelShowStateChanged(*pInputConnection, inputPanelState);
96 SetLastResult(E_SUCCESS);
102 OnInputPanelLanguageEvent(void* pData, Ecore_IMF_Context* pContext, int value)
104 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pData is null ");
105 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pContext is null ");
107 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
108 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
109 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
110 InputConnection* pInputConnection = pImpl->GetInputConnection();
112 char* pLocale = null;
113 ecore_imf_context_input_panel_language_locale_get(pContext, &pLocale);
114 String tempBuffer(pLocale);
116 tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language);
117 LanguageCode newLanguageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(language);
121 pListener->OnInputConnectionPanelLanguageChanged(*pInputConnection, newLanguageCode);
125 pListenerF->OnInputConnectionPanelLanguageChanged(*pInputConnection, newLanguageCode);
132 SetLastResult(E_SUCCESS);
138 OnInputPanelSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value)
140 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pData is null ");
141 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pContext is null ");
143 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
144 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
145 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
146 InputConnection* pInputConnection = pImpl->GetInputConnection();
148 Rectangle bounds = pImpl->GetInputPanelBounds();
150 SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelSizeChangedEvent is called.[ctx=0x%x][x = %d, y = %d, width = %d, height = %d]\n", pContext, bounds.x, bounds.y, bounds.width, bounds.height);
154 pListener->OnInputConnectionPanelBoundsChanged(*pInputConnection, bounds);
158 pListenerF->OnInputConnectionPanelBoundsChanged(*pInputConnection, _CoordinateSystemUtils::ConvertToFloat(bounds));
161 SetLastResult(E_SUCCESS);
167 OnInputPanelPredictionModeEvent(void* pData, Ecore_IMF_Context* pContext, int value)
169 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pData is null ");
170 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pContext is null ");
172 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
173 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
174 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
175 InputConnection* pInputConnection = pImpl->GetInputConnection();
179 pListener->OnInputConnectionTextPredictionShowStateChanged(*pInputConnection, static_cast<bool>(value));
183 pListenerF->OnInputConnectionTextPredictionShowStateChanged(*pInputConnection, static_cast<bool>(value));
185 SetLastResult(E_SUCCESS);
191 OnInputPanelPredictionSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value)
193 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pData is null ");
194 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pContext is null ");
196 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
197 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
198 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
199 InputConnection* pInputConnection = pImpl->GetInputConnection();
201 Rectangle bounds = pImpl->GetPredictionBounds();
205 pListener->OnInputConnectionTextPredictionBoundsChanged(*pInputConnection, bounds);
209 pListenerF->OnInputConnectionTextPredictionBoundsChanged(*pInputConnection, _CoordinateSystemUtils::ConvertToFloat(bounds));
211 SetLastResult(E_SUCCESS);
217 OnRetrieveSurrounding(void* pData, Ecore_IMF_Context* pContext, char** pText, int* pCursorPostion)
219 SysTryReturn(NID_UI, pData != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pData == null.");
220 SysTryReturn(NID_UI, pContext != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pContext is null ");
222 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
223 IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider();
225 InputConnection* pInputConnection = pImpl->GetInputConnection();
227 char* pSurroundingText = null;
230 pProvider->GetPreviousText(*pInputConnection, string, *pCursorPostion);
232 int len = wcstombs(0, static_cast<const wchar_t*>(string.GetPointer()), 0);
233 //SysTryReturn(NID_BASE, len != -1, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid string.");
237 return ECORE_CALLBACK_PASS_ON;
243 return ECORE_CALLBACK_DONE;
245 //This memory will be released by ECORE IMF
246 pSurroundingText = (char*)malloc(len+1);
247 SysTryReturn(NID_UI, pSurroundingText, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] OnRetrieveSurrounding pSurroundingText == null.");
249 len = wcstombs(pSurroundingText, static_cast<const wchar_t*>(string.GetPointer()), len);
250 pSurroundingText[len] = null;
251 *pText = pSurroundingText;
253 SetLastResult(E_SUCCESS);
255 return ECORE_CALLBACK_PASS_ON;
259 OnCommitTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
261 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pData is null ");
262 SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pEventInfo is null ");
264 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
265 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
266 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
268 String commitText(static_cast<char*>(pEventInfo));
269 InputConnection* pInputConnection = pImpl->GetInputConnection();
273 pListener->OnInputConnectionTextCommitted(*pInputConnection, commitText);
277 pListenerF->OnInputConnectionTextCommitted(*pInputConnection, commitText);
280 SetLastResult(E_SUCCESS);
286 OnComposeTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
288 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pData is null ");
289 //SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pEventInfo is null ");
291 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
292 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
293 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
295 int cursorPosition = 0;
297 ecore_imf_context_preedit_string_get(pContext, &pText, &cursorPosition);
298 String composingText(pText);
304 InputConnection* pInputConnection = pImpl->GetInputConnection();
308 pListener->OnInputConnectionComposingTextChanged(*pInputConnection, composingText, cursorPosition);
312 pListenerF->OnInputConnectionComposingTextChanged(*pInputConnection, composingText, cursorPosition);
315 SetLastResult(E_SUCCESS);
321 OnDeleteSurroundingTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
323 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pData is null ");
324 SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pEventInfo is null ");
326 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
327 IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider();
328 Ecore_IMF_Event_Delete_Surrounding* pEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(pEventInfo);
330 InputConnection* pInputConnection = pImpl->GetInputConnection();
331 pProvider->DeleteSurroundingText(*pInputConnection, pEvent->offset, pEvent->n_chars);
333 SetLastResult(E_SUCCESS);
340 OnUSBKeyboardEcoreEvent(void* pData, int eventType, void* pEventInfo)
342 return ECORE_CALLBACK_PASS_ON;
348 namespace Tizen { namespace Ui {
350 _InputConnectionImpl::_InputConnectionImpl(InputConnection* pInputConnection)
357 , __pInputConnection(pInputConnection)
358 , __inputPanelAction(INPUT_PANEL_ACTION_ENTER)
359 , __inputPanelState(INPUT_PANEL_SHOW_STATE_HIDE)
360 , __inputPanelStyle(INPUT_PANEL_STYLE_NORMAL)
361 , __pUSBEventHandler(null)
362 , __IsKeyEventSkipped(false)
367 _InputConnectionImpl::~_InputConnectionImpl(void)
369 __pInputConnection = null;
375 RemoveInputPanelCallback();
376 RemoveEcoreEventCallback();
377 RemoveEvasObjectEventCallback();
378 ecore_imf_context_focus_out(__pContext);
379 ecore_imf_context_del(__pContext);
380 ecore_imf_shutdown();
385 _InputConnectionImpl*
386 _InputConnectionImpl::CreateInputConnectionImplN(InputConnection* pInputConnection)
390 _InputConnectionImpl* pImpl = new (std::nothrow) _InputConnectionImpl(pInputConnection);
391 SysTryReturn(NID_UI, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
398 _InputConnectionImpl::Initialize(const _Control& control, const IInputConnectionEventListener& listener, const IInputConnectionProvider& provider)
400 result r = E_SUCCESS;
402 __controlHandle = control.GetHandle();
404 __pListener = const_cast<IInputConnectionEventListener*>(&listener);
406 __pProvider = const_cast<IInputConnectionProvider*>(&provider);
409 const char* pId = ecore_imf_context_default_id_get();
410 SysTryReturnResult(NID_UI, pId != null, E_SYSTEM, "A system error occurred.");
413 __pContext = (Ecore_IMF_Context*)ecore_imf_context_add(pId);
414 SysTryReturnResult(NID_UI, __pContext, E_SYSTEM, "A system error occurred.");
416 AddInputPanelCallback();
417 AddEcoreEventCallback();
418 AddEvasObjectEventCallback();
425 _InputConnectionImpl::Initialize(const _Control& control, const IInputConnectionEventListenerF& listener, const IInputConnectionProvider& provider)
427 result r = E_SUCCESS;
429 __controlHandle = control.GetHandle();
432 __pListenerF = const_cast<IInputConnectionEventListenerF*>(&listener);
433 __pProvider = const_cast<IInputConnectionProvider*>(&provider);
436 const char* pId = ecore_imf_context_default_id_get();
437 SysTryReturnResult(NID_UI, pId != null, E_SYSTEM, "A system error occurred.");
440 __pContext = (Ecore_IMF_Context*)ecore_imf_context_add(pId);
441 SysTryReturnResult(NID_UI, __pContext, E_SYSTEM, "A system error occurred.");
443 AddInputPanelCallback();
444 AddEcoreEventCallback();
445 AddEvasObjectEventCallback();
452 _InputConnectionImpl::BindInputMethod(void)
454 result r = E_SUCCESS;
456 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
458 _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
460 _Window* pWindow = pControl->GetRootWindow();
463 _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
464 _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
468 ecore_imf_context_client_window_set(__pContext, (void*)ecore_evas_window_get(pLayer->GetEcoreEvas()));
469 ecore_imf_context_client_canvas_set(__pContext, pLayer->GetEvas());
470 ecore_imf_context_input_panel_enabled_set(__pContext, EINA_FALSE);
474 ecore_imf_context_focus_in(__pContext);
477 SysLog(NID_UI_CTRL, "[InputConnection] BindInputMethod is called.[ctx=0x%x]\n", __pContext);
483 _InputConnectionImpl::UnbindInputMethod(void)
485 result r = E_SUCCESS;
487 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
489 ecore_imf_context_focus_out(__pContext);
491 SysLog(NID_UI_CTRL, "[InputConnection] UnbindInputMethod is called.[ctx=0x%x]\n", __pContext);
499 _InputConnectionImpl::ShowInputPanel(void)
501 result r = E_SUCCESS;
503 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
504 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
506 ecore_imf_context_input_panel_show(__pContext);
507 __inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW;
509 SysLog(NID_UI_CTRL, "[InputConnection] ShowInputPanel is called.[ctx=0x%x]\n", __pContext);
515 _InputConnectionImpl::HideInputPanel(void)
517 result r = E_SUCCESS;
519 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
520 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
522 ecore_imf_context_input_panel_hide(__pContext);
523 __inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
525 SysLog(NID_UI_CTRL, "[InputConnection] HideInputPanel is called.[ctx=0x%x]\n", __pContext);
531 _InputConnectionImpl::SetInputPanelStyle(InputPanelStyle style)
533 result r = E_SUCCESS;
535 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
537 __inputPanelStyle = style;
539 Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
543 case INPUT_PANEL_STYLE_NORMAL:
544 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
546 case INPUT_PANEL_STYLE_NUMBER:
547 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
549 case INPUT_PANEL_STYLE_EMAIL:
550 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
552 case INPUT_PANEL_STYLE_URL:
553 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
555 case INPUT_PANEL_STYLE_PHONE_NUMBER:
556 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
558 case INPUT_PANEL_STYLE_IP:
559 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_IP;
561 case INPUT_PANEL_STYLE_NUMBER_ONLY:
562 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY;
568 ecore_imf_context_input_panel_layout_set(__pContext, ecorePanelLayout);
573 _InputConnectionImpl::GetInputPanelStyle(void) const
577 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
579 Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ecore_imf_context_input_panel_layout_get(__pContext);
580 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
582 switch (ecorePanelLayout)
584 case ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL:
585 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
587 case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER:
588 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
590 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
591 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
593 case ECORE_IMF_INPUT_PANEL_LAYOUT_URL:
594 inputPanelStyle = INPUT_PANEL_STYLE_URL;
596 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
597 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
599 case ECORE_IMF_INPUT_PANEL_LAYOUT_IP:
600 inputPanelStyle = INPUT_PANEL_STYLE_IP;
602 case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY:
603 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
609 return inputPanelStyle;
613 _InputConnectionImpl::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode)
615 result r = E_SUCCESS;
617 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
619 Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
621 switch (autoCapitalizationMode)
623 case AUTO_CAPITALIZATION_MODE_NONE:
624 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
626 case AUTO_CAPITALIZATION_MODE_WORD:
627 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_WORD;
629 case AUTO_CAPITALIZATION_MODE_SENTENCE:
630 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
632 case AUTO_CAPITALIZATION_MODE_ALL:
633 ecoreAutoCapitalization =ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER;
639 ecore_imf_context_autocapital_type_set(__pContext, ecoreAutoCapitalization);
643 AutoCapitalizationMode
644 _InputConnectionImpl::GetAutoCapitalizationMode(void) const
648 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
650 Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ecore_imf_context_autocapital_type_get(__pContext);
651 AutoCapitalizationMode autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE;
653 switch (ecoreAutoCapitalization)
655 case ECORE_IMF_AUTOCAPITAL_TYPE_NONE:
656 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_NONE;
658 case ECORE_IMF_AUTOCAPITAL_TYPE_WORD:
659 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_WORD;
661 case ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE:
662 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE;
664 case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER:
665 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_ALL;
671 return autoCapitalizationMode;
675 _InputConnectionImpl::GetInputPanelShowState(void) const
679 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
681 return __inputPanelState;
685 _InputConnectionImpl::SetInputPanelShowState(InputPanelShowState state)
687 result r = E_SUCCESS;
689 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
691 __inputPanelState = state;
696 _InputConnectionImpl::FinishTextComposition(void)
698 result r = E_SUCCESS;
700 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
701 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
703 ecore_imf_context_reset(__pContext);
708 _InputConnectionImpl::SetInputPanelAction(InputPanelAction inputPanelAction)
710 result r = E_SUCCESS;
712 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
714 __inputPanelAction = inputPanelAction;
715 Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
717 switch (inputPanelAction)
719 case INPUT_PANEL_ACTION_GO:
720 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
722 case INPUT_PANEL_ACTION_NEXT:
723 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
725 case INPUT_PANEL_ACTION_SEND:
726 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
728 case INPUT_PANEL_ACTION_SEARCH:
729 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
731 case INPUT_PANEL_ACTION_LOGIN:
732 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
734 case INPUT_PANEL_ACTION_SIGN_IN:
735 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
737 case INPUT_PANEL_ACTION_JOIN:
738 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
740 case INPUT_PANEL_ACTION_DONE:
741 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
743 case INPUT_PANEL_ACTION_ENTER:
744 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
750 ecore_imf_context_input_panel_return_key_type_set(__pContext, ecorePanelAction);
756 _InputConnectionImpl::GetInputPanelAction(void) const
760 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
762 Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ecore_imf_context_input_panel_return_key_type_get(__pContext);
763 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
765 switch (ecorePanelAction)
767 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
768 inputPanelAction = INPUT_PANEL_ACTION_GO;
770 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
771 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
773 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
774 inputPanelAction = INPUT_PANEL_ACTION_SEND;
776 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
777 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
779 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
780 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
782 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
783 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
785 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
786 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
788 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
789 inputPanelAction = INPUT_PANEL_ACTION_DONE;
791 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
792 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
798 return inputPanelAction;
802 _InputConnectionImpl::SetInputPanelActionEnabled(bool enable)
804 result r = E_SUCCESS;
806 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
808 ecore_imf_context_input_panel_return_key_disabled_set(__pContext, (!enable ? EINA_TRUE : EINA_FALSE));
813 _InputConnectionImpl::IsInputPanelActionEnabled(void) const
817 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
819 Eina_Bool enabled = ecore_imf_context_input_panel_return_key_disabled_get(__pContext);
821 return static_cast<bool>(!enabled);
825 _InputConnectionImpl::SetCursorPosition(int position)
827 result r = E_SUCCESS;
829 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
830 SysTryReturnResult(NID_UI, position >= 0, E_INVALID_ARG, "The input parameter is invalid.");
831 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
833 ecore_imf_context_cursor_position_set(__pContext, position);
838 _InputConnectionImpl::SetCursorBounds(const Rectangle& rect)
840 result r = E_SUCCESS;
842 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
844 SysTryReturnResult(NID_UI, (rect.width > 0)&&(rect.height > 0), E_INVALID_ARG, "The input parameter is invalid.");
845 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
848 Rectangle cursorRectangle;
849 cursorRectangle = rect;
851 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
855 Rectangle absoluteControlRectangle;
856 absoluteControlRectangle = pControl->GetAbsoluteBounds();
857 cursorRectangle.x += absoluteControlRectangle.x;
858 cursorRectangle.y += absoluteControlRectangle.y;
861 Rectangle physicalRect = _CoordinateSystemUtils::Transform(cursorRectangle);
863 ecore_imf_context_cursor_location_set(__pContext, physicalRect.x, physicalRect.y, physicalRect.width, physicalRect.height);
868 _InputConnectionImpl::SetCursorBounds(const FloatRectangle& rect)
870 result r = E_SUCCESS;
872 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
874 SysTryReturnResult(NID_UI, (rect.width > 0)&&(rect.height > 0), E_INVALID_ARG, "The input parameter is invalid.");
875 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
878 FloatRectangle cursorRectangle;
879 cursorRectangle = rect;
881 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
885 FloatRectangle absoluteControlRectangle;
886 absoluteControlRectangle = pControl->GetAbsoluteBoundsF();
887 cursorRectangle.x += absoluteControlRectangle.x;
888 cursorRectangle.y += absoluteControlRectangle.y;
891 FloatRectangle physicalFloatRect = _CoordinateSystemUtils::Transform(cursorRectangle);
892 Rectangle physicalRect = _CoordinateSystemUtils::ConvertToInteger(physicalFloatRect);
894 ecore_imf_context_cursor_location_set(__pContext, physicalRect.x, physicalRect.y, physicalRect.width, physicalRect.height);
899 _InputConnectionImpl::GetInputPanelBounds(void) const
903 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
910 ecore_imf_context_input_panel_geometry_get(__pContext, &x, &y, &w, &h);
911 return Rectangle(x, y, w, h);
915 _InputConnectionImpl::GetInputPanelBoundsF(void) const
919 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
926 ecore_imf_context_input_panel_geometry_get(__pContext, &x, &y, &w, &h);
927 FloatRectangle inputPanelFloatRect;
928 inputPanelFloatRect.x = _CoordinateSystemUtils::ConvertToFloat(x);
929 inputPanelFloatRect.y = _CoordinateSystemUtils::ConvertToFloat(y);
930 inputPanelFloatRect.width = _CoordinateSystemUtils::ConvertToFloat(w);
931 inputPanelFloatRect.height = _CoordinateSystemUtils::ConvertToFloat(h);
933 return inputPanelFloatRect;
937 _InputConnectionImpl::GetPredictionBounds(void) const
941 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
948 ecore_imf_context_candidate_panel_geometry_get(__pContext, &x, &y, &w, &h);
949 return Rectangle(x, y, w, h);
953 _InputConnectionImpl::GetPredictionBoundsF(void) const
957 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
964 ecore_imf_context_candidate_panel_geometry_get(__pContext, &x, &y, &w, &h);
965 FloatRectangle inputPredictionFloatRect;
966 inputPredictionFloatRect.x = _CoordinateSystemUtils::ConvertToFloat(x);
967 inputPredictionFloatRect.y = _CoordinateSystemUtils::ConvertToFloat(y);
968 inputPredictionFloatRect.width = _CoordinateSystemUtils::ConvertToFloat(w);
969 inputPredictionFloatRect.height = _CoordinateSystemUtils::ConvertToFloat(h);
971 return inputPredictionFloatRect;
975 _InputConnectionImpl::SetTextPredictionEnabled(bool enable)
977 result r = E_SUCCESS;
979 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
981 ecore_imf_context_prediction_allow_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE));
987 _InputConnectionImpl::IsTextPredictionEnabled(void) const
991 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
993 Eina_Bool enabled = ecore_imf_context_prediction_allow_get(__pContext);
995 return static_cast<bool>(enabled);
999 _InputConnectionImpl::SetCapsLockEnabled(bool enable)
1001 result r = E_SUCCESS;
1003 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1005 ecore_imf_context_input_panel_caps_lock_mode_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE));
1011 _InputConnectionImpl::IsCapsLockEnabled(void) const
1015 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1017 Eina_Bool enabled = ecore_imf_context_input_panel_caps_lock_mode_get(__pContext);
1019 return static_cast<bool>(enabled);
1023 _InputConnectionImpl::SetInputPanelLanguage(LanguageCode languageCode)
1025 result r = E_SUCCESS;
1027 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1029 char* pLanguage = null;
1031 String code = Locale::LanguageCodeToTwoLetterLanguageCodeString(languageCode);
1032 r = code.Insert("LANG:", 0);
1033 SysTryReturnResult(NID_UI, r == E_SUCCESS, E_OUT_OF_MEMORY, "A system error occurred.");
1035 length = wcstombs(0, static_cast<const wchar_t*>(code.GetPointer()), 0);
1036 SysTryReturnResult(NID_UI, length != -1, E_OUT_OF_MEMORY, "A system error occurred.");
1038 pLanguage = (char*)malloc(length+1);
1039 SysTryReturn(NID_UI, pLanguage, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1041 length = wcstombs(pLanguage, static_cast<const wchar_t*>(code.GetPointer()), length);
1042 pLanguage[length] = null;
1044 ecore_imf_context_input_panel_imdata_set(__pContext, pLanguage, length);
1052 _InputConnectionImpl::GetInputPanelLanguage(void) const
1054 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1058 char* pLocale = null;
1060 ecore_imf_context_input_panel_language_locale_get(__pContext, &pLocale);
1062 String tempBuffer(pLocale);
1064 tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language);
1071 return Locale::TwoLetterLanguageCodeStringToLanguageCode(language);
1075 _InputConnectionImpl::SendOpaqueCommand(const String& command)
1077 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1079 char* pCommand = null;
1082 length = wcstombs(0, static_cast<const wchar_t*>(command.GetPointer()), 0);
1083 SysTryReturnVoidResult(NID_UI, length != -1, E_OUT_OF_MEMORY, "A system error occurred.");
1085 pCommand = (char*)malloc(length+1);
1086 SysTryReturnVoidResult(NID_UI, pCommand, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1088 length = wcstombs(pCommand, static_cast<const wchar_t*>(command.GetPointer()), length);
1089 pCommand[length] = null;
1091 ecore_imf_context_input_panel_imdata_set(__pContext, pCommand, length);
1097 _InputConnectionImpl::GetInputConnection(void) const
1099 return __pInputConnection;
1102 IInputConnectionEventListener*
1103 _InputConnectionImpl::GetInputConnectionListener(void) const
1108 IInputConnectionEventListenerF*
1109 _InputConnectionImpl::GetInputConnectionListenerF(void) const
1111 return __pListenerF;
1114 IInputConnectionProvider*
1115 _InputConnectionImpl::GetInputConnectionProvider(void) const
1121 _InputConnectionImpl::CheckContextEvent(Ecore_IMF_Event_Type type, void* pEventInfo)
1125 if (type == ECORE_IMF_EVENT_KEY_DOWN)
1127 Evas_Event_Key_Down* pDownEvent = static_cast<Evas_Event_Key_Down*>(pEventInfo);
1128 SysTryReturn(NID_UI, pDownEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1129 Ecore_IMF_Event_Key_Down ecoreEvent;
1130 ecore_imf_evas_event_key_down_wrap(pDownEvent, &ecoreEvent);
1131 if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE)
1136 else if (type == ECORE_IMF_EVENT_KEY_UP)
1138 Evas_Event_Key_Up* pUpEvent = static_cast<Evas_Event_Key_Up*>(pEventInfo);
1139 SysTryReturn(NID_UI, pUpEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1140 Ecore_IMF_Event_Key_Up ecoreEvent;
1141 ecore_imf_evas_event_key_up_wrap(pUpEvent, &ecoreEvent);
1142 if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE)
1151 _InputConnectionImpl::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1153 if (__IsKeyEventSkipped)
1158 Ecore_Event_Key* pEvent = static_cast<Ecore_Event_Key*>(keyInfo.GetUserData());
1159 SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1161 Ecore_IMF_Event_Key_Down* pKeyDown = (Ecore_IMF_Event_Key_Down*)malloc(sizeof(Ecore_IMF_Event_Key_Down));
1162 SysTryReturn(NID_UI, pKeyDown, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1164 pKeyDown->keyname = pEvent->keyname;
1166 //need to check with SLP
1167 int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE;
1169 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
1171 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;
1173 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL)
1175 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
1177 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT)
1179 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
1181 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN)
1183 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
1185 pKeyDown->modifiers = static_cast<Ecore_IMF_Keyboard_Modifiers>(modifiers);
1187 int locks = ECORE_IMF_KEYBOARD_LOCK_NONE;
1188 if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL)
1190 locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL;
1192 if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM)
1194 locks |= ECORE_IMF_KEYBOARD_LOCK_NUM;
1196 if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS)
1198 locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS;
1200 pKeyDown->locks = static_cast<Ecore_IMF_Keyboard_Locks>(locks);
1202 pKeyDown->key = pEvent->key;
1203 pKeyDown->string = pEvent->string;
1204 pKeyDown->compose = pEvent->compose;
1205 pKeyDown->timestamp = pEvent->timestamp;
1207 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
1209 if (&source == pControl)
1211 if(CheckUSBKeyboardStatus() && pKeyDown->string)//usb keyboard exist
1213 const char* key = const_cast<char*>(pKeyDown->string);
1214 if(FilterKeyOnUSBMode(GetInputPanelStyle(), key, true) == E_SUCCESS)
1221 if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event*)pKeyDown) == EINA_TRUE)
1229 if ((pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_WIN))
1234 if (!pEvent->compose)
1239 InputConnection* pInputConnection = GetInputConnection();
1240 String commitText(pEvent->compose);
1241 wchar_t commitChar= '\0';
1242 commitText.GetCharAt(0, commitChar);
1243 IInputConnectionEventListener* pListener = GetInputConnectionListener();
1244 IInputConnectionEventListenerF* pListenerF = GetInputConnectionListenerF();
1245 if (Character::IsAlphaNumeric(commitChar))
1249 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1253 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1256 if (commitText == L" " || commitText == L"\t")
1260 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1264 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1267 if (commitText == L"\n" || commitText == L"\r")
1271 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1275 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1278 if ( (commitChar >= 0x21 && commitChar <= 0x2F) || (commitChar >= 0x3A && commitChar <= 0x40) ||
1279 (commitChar >= 0x5B && commitChar <= 0x60) || (commitChar >= 0x7B && commitChar<= 0x7E) )
1283 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1287 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1299 SetLastResult(E_SUCCESS);
1305 _InputConnectionImpl::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1307 if (__IsKeyEventSkipped)
1312 Ecore_Event_Key* pEvent = static_cast<Ecore_Event_Key*>(keyInfo.GetUserData());
1313 SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1315 Ecore_IMF_Event_Key_Up* pKeyUp = (Ecore_IMF_Event_Key_Up*)malloc(sizeof(Ecore_IMF_Event_Key_Up));
1316 SysTryReturn(NID_UI, pKeyUp, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1318 pKeyUp->keyname = pEvent->keyname;
1320 //need to check with SLP
1321 int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE;
1323 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
1325 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;
1327 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL)
1329 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
1331 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT)
1333 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
1335 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN)
1337 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
1339 pKeyUp->modifiers = static_cast<Ecore_IMF_Keyboard_Modifiers>(modifiers);
1341 int locks = ECORE_IMF_KEYBOARD_LOCK_NONE;
1342 if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL)
1344 locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL;
1346 if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM)
1348 locks |= ECORE_IMF_KEYBOARD_LOCK_NUM;
1350 if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS)
1352 locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS;
1354 pKeyUp->locks = static_cast<Ecore_IMF_Keyboard_Locks>(locks);
1356 pKeyUp->key = pEvent->key;
1357 pKeyUp->string = pEvent->string;
1358 pKeyUp->compose = pEvent->compose;
1359 pKeyUp->timestamp = pEvent->timestamp;
1361 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
1363 if (&source == pControl)
1365 if(CheckUSBKeyboardStatus() && pKeyUp->string)//usb keyboard exist
1367 const char* key = const_cast<char*>(pKeyUp->string);
1368 if(FilterKeyOnUSBMode(GetInputPanelStyle(), key) == E_SUCCESS)
1375 if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event*)pKeyUp) == EINA_TRUE)
1385 SetLastResult(E_SUCCESS);
1391 _InputConnectionImpl::AddInputPanelCallback(void)
1393 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent, this);
1394 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent, this);
1395 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent, this);
1396 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent, this);
1397 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent, this);
1398 ecore_imf_context_retrieve_surrounding_callback_set(__pContext, OnRetrieveSurrounding, this);
1404 _InputConnectionImpl::AddEcoreEventCallback(void)
1406 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent, this);
1407 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent, this);
1408 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent, this);
1411 //Internal USB Check
1412 Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
1413 ecore_x_event_mask_set(rootWindow, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
1414 __pUSBEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnUSBKeyboardEcoreEvent, this);
1420 _InputConnectionImpl::AddEvasObjectEventCallback(void)
1422 result r = _UiEventManager::GetInstance()->AddPostKeyEventListener(*this);
1423 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1429 _InputConnectionImpl::RemoveInputPanelCallback(void)
1431 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent);
1432 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent);
1433 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent);
1434 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent);
1435 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent);
1441 _InputConnectionImpl::RemoveEcoreEventCallback(void)
1443 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent);
1444 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent);
1445 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent);
1448 //Internal USB Check Release
1449 if (__pUSBEventHandler)
1451 ecore_event_handler_del(__pUSBEventHandler);
1452 __pUSBEventHandler = null;
1459 _InputConnectionImpl::RemoveEvasObjectEventCallback(void)
1461 result r = _UiEventManager::GetInstance()->RemovePostKeyEventListener(*this);
1462 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1467 _InputConnectionImpl*
1468 _InputConnectionImpl::GetInstance(InputConnection& inputConnection)
1470 return inputConnection.__pInputConnectionImpl;
1472 const _InputConnectionImpl*
1473 _InputConnectionImpl::GetInstance(const InputConnection& inputConnection)
1475 return inputConnection.__pInputConnectionImpl;
1479 _InputConnectionImpl::CheckUSBKeyboardStatus(void)
1481 Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
1482 Ecore_X_Atom keyboardExist = 0;
1483 unsigned int keyboardNumber = 0;
1488 keyboardExist = ecore_x_atom_get("X External Keyboard Exist");
1490 ret = ecore_x_window_prop_card32_get(rootWindow, keyboardExist, &keyboardNumber, 1);
1492 return keyboardNumber;
1496 _InputConnectionImpl::FilterKeyOnUSBMode(InputPanelStyle style, const char* key, bool commit)
1498 if(!(style == INPUT_PANEL_STYLE_NUMBER_ONLY || style == INPUT_PANEL_STYLE_PHONE_NUMBER || style == INPUT_PANEL_STYLE_IP))
1500 return E_INVALID_ARG;
1503 SysTryReturn(NID_UI, key, E_INVALID_ARG, E_INVALID_ARG, "key is null");
1505 char TempKey[20] = {0,};
1506 const char keyOnNumOnlyStyle[10] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/};
1507 const char keyOnPhoneNumStyle[13] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
1508 0x2a/***/, 0x2b/*+*/, 0x23/*#*/};
1509 const char keyOnIPStyle[18] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
1510 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/};
1511 bool isExist = false;
1514 if(style == INPUT_PANEL_STYLE_NUMBER_ONLY)
1517 memcpy(TempKey, keyOnNumOnlyStyle, keyCount*sizeof(char));
1519 else if(style == INPUT_PANEL_STYLE_PHONE_NUMBER)
1522 memcpy(TempKey, keyOnPhoneNumStyle, keyCount*sizeof(char));
1524 else if(style == INPUT_PANEL_STYLE_IP)
1527 memcpy(TempKey, keyOnIPStyle, keyCount*sizeof(char));
1530 for (int i = 0; i < keyCount ; i++)
1532 if(TempKey[i] == key[0])
1539 if (isExist == true && commit == true)
1541 String commitText(key);
1542 if (commitText.GetLength() > 1)
1546 InputConnection* pInputConnection = GetInputConnection();
1547 IInputConnectionEventListener* pListener = GetInputConnectionListener();
1548 IInputConnectionEventListenerF* pListenerF = GetInputConnectionListenerF();
1551 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1555 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1563 _InputConnectionImpl::SetKeyEventSkipped(bool enabled)
1565 __IsKeyEventSkipped = enabled;