2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <dali/internal/input/windows/input-method-context-impl-win.h>
\r
21 // EXTERNAL INCLUDES
\r
22 //#include <Ecore_IMF.h>
\r
23 //#include <Ecore_Input.h>
\r
24 #include <dali/public-api/events/key-event.h>
\r
25 #include <dali/public-api/adaptor-framework/key.h>
\r
26 #include <dali/public-api/object/type-registry.h>
\r
27 #include <dali/integration-api/debug.h>
\r
29 // INTERNAL INCLUDES
\r
30 #include <dali/integration-api/adaptor.h>
\r
31 #include <dali/internal/adaptor/common/adaptor-impl.h>
\r
32 #include <dali/internal/system/common/locale-utils.h>
\r
33 #include <dali/internal/system/common/singleton-service-impl.h>
\r
34 #include <dali/internal/input/common/virtual-keyboard-impl.h>
\r
35 #include <dali/internal/input/common/key-impl.h>
\r
36 // Ecore is littered with C style cast
\r
37 #pragma GCC diagnostic push
\r
38 #pragma GCC diagnostic ignored "-Wold-style-cast"
\r
39 //#include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>
\r
52 #if defined(DEBUG_ENABLED)
\r
53 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");
\r
56 // Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
\r
57 size_t Utf8SequenceLength(const unsigned char leadByte)
\r
61 if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
\r
65 else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
\r
69 else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
\r
73 else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
\r
81 //// Static function calls used by ecore 'c' style callback registration
\r
82 //void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
\r
86 // InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );
\r
87 // inputMethodContext->CommitReceived( data, imfContext, event_info );
\r
91 //void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
\r
95 // InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );
\r
96 // inputMethodContext->PreEditChanged( data, imfContext, event_info );
\r
100 //Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
\r
104 // InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );
\r
105 // return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition );
\r
114 // * Called when an InputMethodContext delete surrounding event is received.
\r
115 // * Here we tell the application that it should delete a certain range.
\r
117 //void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
\r
121 // InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );
\r
122 // inputMethodContext->DeleteSurrounding( data, imfContext, event_info );
\r
126 } // unnamed namespace
\r
128 InputMethodContextPtr InputMethodContextWin::New()
\r
130 InputMethodContextPtr manager;
\r
132 if ( Adaptor::IsAvailable() )
\r
134 // Create instance and register singleton only if the adaptor is available
\r
135 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
\r
136 Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
\r
138 // The Ecore_X_Window needs to use the InputMethodContext.
\r
139 // Only when the render surface is window, we can get the Ecore_X_Window.
\r
140 Ecore_X_Window ecoreXwin( AnyCast<Ecore_X_Window>(nativeWindow) );
\r
143 // If we fail to get Ecore_X_Window, we can't use the InputMethodContext correctly.
\r
144 // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
\r
145 // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
\r
147 manager = new InputMethodContextWin( ecoreXwin );
\r
151 DALI_LOG_ERROR("Failed to get native window handle\n");
\r
158 void InputMethodContextWin::Finalize()
\r
160 //DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Finalize\n" );
\r
161 //VirtualKeyboard::DisconnectCallbacks( mIMFContext );
\r
162 //DisconnectCallbacks();
\r
166 InputMethodContextWin::InputMethodContextWin( Ecore_X_Window ecoreXwin )
\r
168 : mEcoreXwin( ecoreXwin ),
\r
169 mIMFCursorPosition( 0 ),
\r
170 mSurroundingText(),
\r
171 mRestoreAfterFocusLost( false ),
\r
172 mIdleCallbackConnected( false )
\r
174 //ecore_imf_init();
\r
177 InputMethodContextWin::~InputMethodContextWin()
\r
180 //ecore_imf_shutdown();
\r
183 void InputMethodContextWin::Initialize()
\r
185 CreateContext( mEcoreXwin );
\r
186 ConnectCallbacks();
\r
187 //VirtualKeyboard::ConnectCallbacks( mIMFContext );
\r
190 void InputMethodContextWin::CreateContext( Ecore_X_Window ecoreXwin )
\r
192 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n" );
\r
194 //const char *contextId = ecore_imf_context_default_id_get();
\r
197 // mIMFContext = ecore_imf_context_add( contextId );
\r
199 // if( mIMFContext )
\r
203 // ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( ecoreXwin ) );
\r
208 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
\r
213 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
\r
217 void InputMethodContextWin::DeleteContext()
\r
219 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n" );
\r
221 //if ( mIMFContext )
\r
223 // ecore_imf_context_del( mIMFContext );
\r
224 // mIMFContext = NULL;
\r
228 // Callbacks for predicitive text support.
\r
229 void InputMethodContextWin::ConnectCallbacks()
\r
231 //if ( mIMFContext )
\r
233 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ConnectCallbacks\n" );
\r
235 // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
\r
236 // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
\r
237 // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
\r
239 // ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
\r
243 void InputMethodContextWin::DisconnectCallbacks()
\r
245 //if ( mIMFContext )
\r
247 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DisconnectCallbacks\n" );
\r
249 // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
\r
250 // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
\r
251 // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
\r
253 // // We do not need to unset the retrieve surrounding callback.
\r
257 void InputMethodContextWin::Activate()
\r
259 // Reset mIdleCallbackConnected
\r
260 mIdleCallbackConnected = false;
\r
262 //if ( mIMFContext )
\r
264 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Activate\n" );
\r
266 // ecore_imf_context_focus_in( mIMFContext );
\r
268 // // emit keyboard activated signal
\r
269 // Dali::InputMethodContext handle( this );
\r
270 // mActivatedSignal.Emit( handle );
\r
274 void InputMethodContextWin::Deactivate()
\r
276 //if( mIMFContext )
\r
278 // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Deactivate\n" );
\r
281 // ecore_imf_context_focus_out( mIMFContext );
\r
284 // Reset mIdleCallbackConnected
\r
285 mIdleCallbackConnected = false;
\r
288 void InputMethodContextWin::Reset()
\r
290 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Reset\n" );
\r
292 //if ( mIMFContext )
\r
294 // ecore_imf_context_reset( mIMFContext );
\r
298 ImfContext* InputMethodContextWin::GetContext()
\r
300 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n" );
\r
302 //return mIMFContext;
\r
306 bool InputMethodContextWin::RestoreAfterFocusLost() const
\r
308 return mRestoreAfterFocusLost;
\r
311 void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle )
\r
313 mRestoreAfterFocusLost = toggle;
\r
317 * Called when an InputMethodContext Pre-Edit changed event is received.
\r
318 * We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks
\r
319 * the user wants to type.
\r
321 void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* event_info )
\r
323 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" );
\r
324 // auto context = reinterpret_cast<Ecore_IMF_Context*>(imfContext);
\r
326 // char* preEditString( NULL );
\r
327 // int cursorPosition( 0 );
\r
328 // Eina_List* attrs = NULL;
\r
329 // Eina_List* l = NULL;
\r
331 // Ecore_IMF_Preedit_Attr* attr;
\r
333 // // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
\r
334 // // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
\r
335 // ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition );
\r
339 // // iterate through the list of attributes getting the type, start and end position.
\r
340 // for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
\r
342 //#ifdef DALI_PROFILE_UBUNTU
\r
343 // if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
\r
344 //#else // DALI_PROFILE_UBUNTU
\r
345 // if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
\r
346 //#endif // DALI_PROFILE_UBUNTU
\r
348 // // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
\r
350 // size_t visualCharacterIndex = 0;
\r
351 // size_t byteIndex = 0;
\r
353 // // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
\r
354 // const char leadByte = preEditString[byteIndex];
\r
355 // while( leadByte != '\0' )
\r
357 // // attr->end_index is provided as a byte position not character and we need to know the character position.
\r
358 // const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
\r
359 // if ( byteIndex == attr->end_index )
\r
361 // cursorPosition = visualCharacterIndex;
\r
363 // // end loop as found cursor position that matches byte position
\r
367 // byteIndex += currentSequenceLength; // jump to next character
\r
368 // visualCharacterIndex++; // increment character count so we know our position for when we get a match
\r
371 // DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
\r
377 //if ( Dali::Adaptor::IsAvailable() )
\r
379 // Dali::InputMethodContext handle( this );
\r
380 // Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 );
\r
381 // Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
\r
383 // if( callbackData.update )
\r
385 // mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
\r
387 // NotifyCursorPosition();
\r
390 // if( callbackData.preeditResetRequired )
\r
395 //free( preEditString );
\r
398 void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* event_info )
\r
400 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" );
\r
402 if ( Dali::Adaptor::IsAvailable() )
\r
404 const std::string keyString( static_cast<char*>( event_info ) );
\r
406 Dali::InputMethodContext handle( this );
\r
407 Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );
\r
408 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
\r
410 if( callbackData.update )
\r
412 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
\r
414 NotifyCursorPosition();
\r
420 * Called when an InputMethodContext retrieve surround event is received.
\r
421 * Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is
\r
422 * We need to signal the application to tell us this information.
\r
424 bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
\r
426 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n" );
\r
428 Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );
\r
429 Dali::InputMethodContext handle( this );
\r
430 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
\r
432 if( callbackData.update )
\r
436 *text = strdup( callbackData.currentText.c_str() );
\r
439 if( cursorPosition )
\r
441 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
\r
442 *cursorPosition = mIMFCursorPosition;
\r
446 //return EINA_TRUE;
\r
451 * Called when an InputMethodContext delete surrounding event is received.
\r
452 * Here we tell the application that it should delete a certain range.
\r
454 void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )
\r
456 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" );
\r
458 //if( Dali::Adaptor::IsAvailable() )
\r
460 // Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
\r
462 // Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
\r
463 // Dali::InputMethodContext handle( this );
\r
464 // Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
\r
466 // if( callbackData.update )
\r
468 // mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
\r
470 // NotifyCursorPosition();
\r
475 void InputMethodContextWin::NotifyCursorPosition()
\r
477 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n" );
\r
479 //if( mIMFContext )
\r
481 // ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
\r
485 void InputMethodContextWin::SetCursorPosition( unsigned int cursorPosition )
\r
487 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n" );
\r
489 mIMFCursorPosition = static_cast<int>( cursorPosition );
\r
492 unsigned int InputMethodContextWin::GetCursorPosition() const
\r
494 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n" );
\r
496 return static_cast<unsigned int>( mIMFCursorPosition );
\r
499 void InputMethodContextWin::SetSurroundingText( const std::string& text )
\r
501 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n" );
\r
503 mSurroundingText = text;
\r
506 const std::string& InputMethodContextWin::GetSurroundingText() const
\r
508 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n" );
\r
510 return mSurroundingText;
\r
513 void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine )
\r
517 Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection()
\r
519 Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );
\r
521 //if ( mIMFContext )
\r
523 // char* locale( NULL );
\r
524 // ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
\r
528 // direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
\r
536 Rect<int> InputMethodContextWin::GetInputMethodArea()
\r
538 int xPos, yPos, width, height;
\r
540 width = height = xPos = yPos = 0;
\r
542 //if( mIMFContext )
\r
544 // ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
\r
548 // DALI_LOG_WARNING("VKB Unable to get InputMethodContext Context so GetSize unavailable\n");
\r
551 return Rect<int>(xPos,yPos,width,height);
\r
554 void InputMethodContextWin::ApplyOptions( const InputMethodOptions& options )
\r
556 using namespace Dali::InputMethod::Category;
\r
560 //if (mIMFContext == NULL)
\r
562 // DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
\r
566 if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
\r
569 if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )
\r
572 if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )
\r
575 if ( mOptions.CompareAndSet(VARIATION, options, index) )
\r
580 void InputMethodContextWin::SetInputPanelData( const std::string& data )
\r
582 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n" );
\r
584 //if( mIMFContext )
\r
586 // int length = data.length();
\r
587 // ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
\r
591 void InputMethodContextWin::GetInputPanelData( std::string& data )
\r
593 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n" );
\r
595 //if( mIMFContext )
\r
597 // int length = 4096; // The max length is 4096 bytes
\r
598 // Dali::Vector< char > buffer;
\r
599 // buffer.Resize( length );
\r
600 // ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
\r
601 // data = std::string( buffer.Begin(), buffer.End() );
\r
605 Dali::InputMethodContext::State InputMethodContextWin::GetInputPanelState()
\r
607 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n" );
\r
609 //if( mIMFContext )
\r
612 // value = ecore_imf_context_input_panel_state_get( mIMFContext );
\r
616 // case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
\r
618 // return Dali::InputMethodContext::SHOW;
\r
622 // case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
\r
624 // return Dali::InputMethodContext::HIDE;
\r
628 // case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
\r
630 // return Dali::InputMethodContext::WILL_SHOW;
\r
636 // return Dali::InputMethodContext::DEFAULT;
\r
640 return Dali::InputMethodContext::DEFAULT;
\r
643 void InputMethodContextWin::SetReturnKeyState( bool visible )
\r
645 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n" );
\r
647 //if( mIMFContext )
\r
649 // ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
\r
653 void InputMethodContextWin::AutoEnableInputPanel( bool enabled )
\r
655 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n" );
\r
657 //if( mIMFContext )
\r
659 // ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
\r
663 void InputMethodContextWin::ShowInputPanel()
\r
665 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n" );
\r
667 //if( mIMFContext )
\r
669 // ecore_imf_context_input_panel_show( mIMFContext );
\r
673 void InputMethodContextWin::HideInputPanel()
\r
675 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n" );
\r
677 //if( mIMFContext )
\r
679 // ecore_imf_context_input_panel_hide( mIMFContext );
\r
683 Dali::InputMethodContext::KeyboardType InputMethodContextWin::GetKeyboardType()
\r
685 return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;
\r
688 std::string InputMethodContextWin::GetInputPanelLocale()
\r
690 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n" );
\r
692 std::string locale = "";
\r
694 //if( mIMFContext )
\r
696 // char* value = NULL;
\r
697 // ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
\r
701 // std::string valueCopy( value );
\r
702 // locale = valueCopy;
\r
704 // // The locale string retrieved must be freed with free().
\r
711 bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )
\r
713 bool eventHandled( false );
\r
715 // If a device key then skip ecore_imf_context_filter_event.
\r
716 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))
\r
718 //check whether it's key down or key up event
\r
719 if ( keyEvent.state == KeyEvent::Down )
\r
721 eventHandled = ProcessEventKeyDown( keyEvent );
\r
723 else if ( keyEvent.state == KeyEvent::Up )
\r
725 eventHandled = ProcessEventKeyUp( keyEvent );
\r
729 return eventHandled;
\r
732 bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )
\r
734 bool eventHandled( false );
\r
735 // if ( mIMFContext )
\r
737 // // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
\r
738 // Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
\r
739 // ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str();
\r
740 // ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str();
\r
741 // ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();
\r
742 // ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str();
\r
743 // ecoreKeyDownEvent.timestamp = keyEvent.time;
\r
744 // ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
\r
745 // ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
\r
746 //#ifdef ECORE_IMF_1_13
\r
747 // ecoreKeyDownEvent.dev_name = "";
\r
748 // ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
\r
749 // ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
\r
750 //#endif // ECORE_IMF_1_13
\r
752 // // If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.
\r
753 // if ((keyEvent.GetDeviceName() == "ime") && ((!strncmp(keyEvent.keyPressedName.c_str(), "Left", 4)) ||
\r
754 // (!strncmp(keyEvent.keyPressedName.c_str(), "Right", 5)) ||
\r
755 // (!strncmp(keyEvent.keyPressedName.c_str(), "Up", 2)) ||
\r
756 // (!strncmp(keyEvent.keyPressedName.c_str(), "Down", 4))))
\r
758 // eventHandled = 0;
\r
762 // eventHandled = ecore_imf_context_filter_event(mIMFContext,
\r
763 // ECORE_IMF_EVENT_KEY_DOWN,
\r
764 // (Ecore_IMF_Event *) &ecoreKeyDownEvent);
\r
767 // // If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext
\r
768 // if (!eventHandled)
\r
770 // if (!strcmp(keyEvent.keyPressedName.c_str(), "Escape") ||
\r
771 // !strcmp(keyEvent.keyPressedName.c_str(), "Return") ||
\r
772 // !strcmp(keyEvent.keyPressedName.c_str(), "KP_Enter"))
\r
774 // ecore_imf_context_reset(mIMFContext);
\r
778 return eventHandled;
\r
781 bool InputMethodContextWin::ProcessEventKeyUp( const KeyEvent& keyEvent )
\r
783 bool eventHandled( false );
\r
784 // if( mIMFContext )
\r
786 // // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
\r
787 // Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
\r
788 // ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str();
\r
789 // ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str();
\r
790 // ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();
\r
791 // ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str();
\r
792 // ecoreKeyUpEvent.timestamp = keyEvent.time;
\r
793 // ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
\r
794 // ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
\r
795 //#ifdef ECORE_IMF_1_13
\r
796 // ecoreKeyUpEvent.dev_name = "";
\r
797 //#endif // ECORE_IMF_1_13
\r
799 // eventHandled = ecore_imf_context_filter_event(mIMFContext,
\r
800 // ECORE_IMF_EVENT_KEY_UP,
\r
801 // (Ecore_IMF_Event *) &ecoreKeyUpEvent);
\r
803 return eventHandled;
\r
806 //Ecore_IMF_Keyboard_Modifiers InputMethodContextWin::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier )
\r
808 // unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
\r
810 // if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
\r
812 // modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
\r
815 // if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
\r
817 // modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
\r
820 // if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
\r
822 // modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
\r
825 // if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
\r
827 // modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
\r
830 // if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
\r
832 // modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
\r
835 // return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
\r
838 //Ecore_IMF_Keyboard_Locks InputMethodContextWin::EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
\r
840 // unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
\r
842 // if( modifier & ECORE_EVENT_LOCK_NUM )
\r
844 // lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
\r
847 // if( modifier & ECORE_EVENT_LOCK_CAPS )
\r
849 // lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
\r
852 // if( modifier & ECORE_EVENT_LOCK_SCROLL )
\r
854 // lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
\r
857 // return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
\r
866 #pragma GCC diagnostic pop
\r