2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/input/ubuntu-x11/input-method-context-impl-x.h>
22 #include <Ecore_IMF.h>
23 #include <Ecore_Input.h>
24 #include <dali/public-api/events/key-event.h>
25 #include <dali/public-api/adaptor-framework/key.h>
26 #include <dali/public-api/object/type-registry.h>
27 #include <dali/integration-api/debug.h>
30 #include <dali/integration-api/adaptor.h>
31 #include <dali/internal/adaptor/common/adaptor-impl.h>
32 #include <dali/internal/system/common/locale-utils.h>
33 #include <dali/internal/system/common/singleton-service-impl.h>
34 #include <dali/internal/input/common/virtual-keyboard-impl.h>
35 #include <dali/internal/input/common/key-impl.h>
36 // Ecore is littered with C style cast
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wold-style-cast"
39 #include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>
52 #if defined(DEBUG_ENABLED)
53 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");
56 // Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
57 size_t Utf8SequenceLength(const unsigned char leadByte)
61 if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
65 else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
69 else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
73 else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
81 // Static function calls used by ecore 'c' style callback registration
82 void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
86 InputMethodContextX* inputMethodContext = reinterpret_cast< InputMethodContextX* > ( data );
87 inputMethodContext->CommitReceived( data, imfContext, event_info );
91 void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
95 InputMethodContextX* inputMethodContext = reinterpret_cast< InputMethodContextX* > ( data );
96 inputMethodContext->PreEditChanged( data, imfContext, event_info );
100 Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
104 InputMethodContextX* inputMethodContext = reinterpret_cast< InputMethodContextX* > ( data );
105 return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition );
114 * Called when an InputMethodContext delete surrounding event is received.
115 * Here we tell the application that it should delete a certain range.
117 void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
121 InputMethodContextX* inputMethodContext = reinterpret_cast< InputMethodContextX* > ( data );
122 inputMethodContext->DeleteSurrounding( data, imfContext, event_info );
126 } // unnamed namespace
128 InputMethodContextPtr InputMethodContextX::New()
130 InputMethodContextPtr manager;
132 if ( Adaptor::IsAvailable() )
134 // Create instance and register singleton only if the adaptor is available
135 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
136 Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
138 // The Ecore_X_Window needs to use the InputMethodContext.
139 // Only when the render surface is window, we can get the Ecore_X_Window.
140 Ecore_X_Window ecoreXwin( AnyCast<Ecore_X_Window>(nativeWindow) );
143 // If we fail to get Ecore_X_Window, we can't use the InputMethodContext correctly.
144 // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
145 // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
147 manager = new InputMethodContextX( ecoreXwin );
151 DALI_LOG_ERROR("Failed to get native window handle\n");
158 void InputMethodContextX::Finalize()
160 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Finalize\n" );
161 VirtualKeyboard::DisconnectCallbacks( mIMFContext );
162 DisconnectCallbacks();
166 InputMethodContextX::InputMethodContextX( Ecore_X_Window ecoreXwin )
168 mEcoreXwin( ecoreXwin ),
169 mIMFCursorPosition( 0 ),
171 mRestoreAfterFocusLost( false ),
172 mIdleCallbackConnected( false )
177 InputMethodContextX::~InputMethodContextX()
180 ecore_imf_shutdown();
183 void InputMethodContextX::Initialize()
185 CreateContext( mEcoreXwin );
187 VirtualKeyboard::ConnectCallbacks( mIMFContext );
190 void InputMethodContextX::CreateContext( Ecore_X_Window ecoreXwin )
192 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::CreateContext\n" );
194 const char *contextId = ecore_imf_context_default_id_get();
197 mIMFContext = ecore_imf_context_add( contextId );
203 ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( ecoreXwin ) );
208 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
213 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
217 void InputMethodContextX::DeleteContext()
219 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DeleteContext\n" );
223 ecore_imf_context_del( mIMFContext );
228 // Callbacks for predicitive text support.
229 void InputMethodContextX::ConnectCallbacks()
233 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::ConnectCallbacks\n" );
235 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
236 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
237 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
239 ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
243 void InputMethodContextX::DisconnectCallbacks()
247 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DisconnectCallbacks\n" );
249 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
250 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
251 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
253 // We do not need to unset the retrieve surrounding callback.
257 void InputMethodContextX::Activate()
259 // Reset mIdleCallbackConnected
260 mIdleCallbackConnected = false;
264 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Activate\n" );
266 ecore_imf_context_focus_in( mIMFContext );
268 // emit keyboard activated signal
269 Dali::InputMethodContext handle( this );
270 mActivatedSignal.Emit( handle );
274 void InputMethodContextX::Deactivate()
278 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Deactivate\n" );
281 ecore_imf_context_focus_out( mIMFContext );
284 // Reset mIdleCallbackConnected
285 mIdleCallbackConnected = false;
288 void InputMethodContextX::Reset()
290 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Reset\n" );
294 ecore_imf_context_reset( mIMFContext );
298 ImfContext* InputMethodContextX::GetContext()
300 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetContext\n" );
305 bool InputMethodContextX::RestoreAfterFocusLost() const
307 return mRestoreAfterFocusLost;
310 void InputMethodContextX::SetRestoreAfterFocusLost( bool toggle )
312 mRestoreAfterFocusLost = toggle;
316 * Called when an InputMethodContext Pre-Edit changed event is received.
317 * We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks
318 * the user wants to type.
320 void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* event_info )
322 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::PreEditChanged\n" );
323 auto context = reinterpret_cast<Ecore_IMF_Context*>(imfContext);
325 char* preEditString( NULL );
326 int cursorPosition( 0 );
327 Eina_List* attrs = NULL;
330 Ecore_IMF_Preedit_Attr* attr;
332 // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
333 // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
334 ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition );
338 // iterate through the list of attributes getting the type, start and end position.
339 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) ) ))
341 #ifdef DALI_PROFILE_UBUNTU
342 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
343 #else // DALI_PROFILE_UBUNTU
344 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
345 #endif // DALI_PROFILE_UBUNTU
347 // 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.
349 size_t visualCharacterIndex = 0;
350 size_t byteIndex = 0;
352 // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
353 const char leadByte = preEditString[byteIndex];
354 while( leadByte != '\0' )
356 // attr->end_index is provided as a byte position not character and we need to know the character position.
357 const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
358 if ( byteIndex == attr->end_index )
360 cursorPosition = visualCharacterIndex;
362 // end loop as found cursor position that matches byte position
366 byteIndex += currentSequenceLength; // jump to next character
367 visualCharacterIndex++; // increment character count so we know our position for when we get a match
370 DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
376 if ( Dali::Adaptor::IsAvailable() )
378 Dali::InputMethodContext handle( this );
379 Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 );
380 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
382 if( callbackData.update )
384 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
386 NotifyCursorPosition();
389 if( callbackData.preeditResetRequired )
394 free( preEditString );
397 void InputMethodContextX::CommitReceived( void*, ImfContext* imfContext, void* event_info )
399 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::CommitReceived\n" );
401 if ( Dali::Adaptor::IsAvailable() )
403 const std::string keyString( static_cast<char*>( event_info ) );
405 Dali::InputMethodContext handle( this );
406 Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );
407 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
409 if( callbackData.update )
411 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
413 NotifyCursorPosition();
419 * Called when an InputMethodContext retrieve surround event is received.
420 * Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is
421 * We need to signal the application to tell us this information.
423 bool InputMethodContextX::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
425 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::RetrieveSurrounding\n" );
427 Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );
428 Dali::InputMethodContext handle( this );
429 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
431 if( callbackData.update )
435 *text = strdup( callbackData.currentText.c_str() );
440 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
441 *cursorPosition = mIMFCursorPosition;
449 * Called when an InputMethodContext delete surrounding event is received.
450 * Here we tell the application that it should delete a certain range.
452 void InputMethodContextX::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )
454 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DeleteSurrounding\n" );
456 if( Dali::Adaptor::IsAvailable() )
458 Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
460 Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
461 Dali::InputMethodContext handle( this );
462 Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
464 if( callbackData.update )
466 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
468 NotifyCursorPosition();
473 void InputMethodContextX::NotifyCursorPosition()
475 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::NotifyCursorPosition\n" );
479 ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
483 void InputMethodContextX::SetCursorPosition( unsigned int cursorPosition )
485 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetCursorPosition\n" );
487 mIMFCursorPosition = static_cast<int>( cursorPosition );
490 unsigned int InputMethodContextX::GetCursorPosition() const
492 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetCursorPosition\n" );
494 return static_cast<unsigned int>( mIMFCursorPosition );
497 void InputMethodContextX::SetSurroundingText( const std::string& text )
499 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetSurroundingText\n" );
501 mSurroundingText = text;
504 const std::string& InputMethodContextX::GetSurroundingText() const
506 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetSurroundingText\n" );
508 return mSurroundingText;
511 void InputMethodContextX::NotifyTextInputMultiLine( bool multiLine )
515 Dali::InputMethodContext::TextDirection InputMethodContextX::GetTextDirection()
517 Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );
521 char* locale( NULL );
522 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
526 direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
534 Rect<int> InputMethodContextX::GetInputMethodArea()
536 int xPos, yPos, width, height;
538 width = height = xPos = yPos = 0;
542 ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
546 DALI_LOG_WARNING("VKB Unable to get InputMethodContext Context so GetSize unavailable\n");
549 return Rect<int>(xPos,yPos,width,height);
552 void InputMethodContextX::ApplyOptions( const InputMethodOptions& options )
554 using namespace Dali::InputMethod::Category;
558 if (mIMFContext == NULL)
560 DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
564 if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
567 if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )
570 if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )
573 if ( mOptions.CompareAndSet(VARIATION, options, index) )
578 void InputMethodContextX::SetInputPanelData( const std::string& data )
580 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelData\n" );
584 int length = data.length();
585 ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
589 void InputMethodContextX::GetInputPanelData( std::string& data )
591 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelData\n" );
595 int length = 4096; // The max length is 4096 bytes
596 Dali::Vector< char > buffer;
597 buffer.Resize( length );
598 ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
599 data = std::string( buffer.Begin(), buffer.End() );
603 Dali::InputMethodContext::State InputMethodContextX::GetInputPanelState()
605 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelState\n" );
610 value = ecore_imf_context_input_panel_state_get( mIMFContext );
614 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
616 return Dali::InputMethodContext::SHOW;
620 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
622 return Dali::InputMethodContext::HIDE;
626 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
628 return Dali::InputMethodContext::WILL_SHOW;
634 return Dali::InputMethodContext::DEFAULT;
638 return Dali::InputMethodContext::DEFAULT;
641 void InputMethodContextX::SetReturnKeyState( bool visible )
643 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetReturnKeyState\n" );
647 ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
651 void InputMethodContextX::AutoEnableInputPanel( bool enabled )
653 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::AutoEnableInputPanel\n" );
657 ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
661 void InputMethodContextX::ShowInputPanel()
663 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::ShowInputPanel\n" );
667 ecore_imf_context_input_panel_show( mIMFContext );
671 void InputMethodContextX::HideInputPanel()
673 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::HideInputPanel\n" );
677 ecore_imf_context_input_panel_hide( mIMFContext );
681 Dali::InputMethodContext::KeyboardType InputMethodContextX::GetKeyboardType()
683 return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;
686 std::string InputMethodContextX::GetInputPanelLocale()
688 DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLocale\n" );
690 std::string locale = "";
695 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
699 std::string valueCopy( value );
702 // The locale string retrieved must be freed with free().
709 bool InputMethodContextX::FilterEventKey( const Dali::KeyEvent& keyEvent )
711 bool eventHandled( false );
713 // If a device key then skip ecore_imf_context_filter_event.
714 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))
716 //check whether it's key down or key up event
717 if ( keyEvent.state == KeyEvent::Down )
719 eventHandled = ProcessEventKeyDown( keyEvent );
721 else if ( keyEvent.state == KeyEvent::Up )
723 eventHandled = ProcessEventKeyUp( keyEvent );
730 bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent )
732 bool eventHandled( false );
735 // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
736 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
737 ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str();
738 ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str();
739 ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();
740 ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str();
741 ecoreKeyDownEvent.timestamp = keyEvent.time;
742 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
743 ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
744 #ifdef ECORE_IMF_1_13
745 ecoreKeyDownEvent.dev_name = "";
746 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
747 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
748 #endif // ECORE_IMF_1_13
750 // 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.
751 if ((keyEvent.GetDeviceName() == "ime") && ((!strncmp(keyEvent.keyPressedName.c_str(), "Left", 4)) ||
752 (!strncmp(keyEvent.keyPressedName.c_str(), "Right", 5)) ||
753 (!strncmp(keyEvent.keyPressedName.c_str(), "Up", 2)) ||
754 (!strncmp(keyEvent.keyPressedName.c_str(), "Down", 4))))
760 eventHandled = ecore_imf_context_filter_event(mIMFContext,
761 ECORE_IMF_EVENT_KEY_DOWN,
762 (Ecore_IMF_Event *) &ecoreKeyDownEvent);
765 // If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext
768 if (!strcmp(keyEvent.keyPressedName.c_str(), "Escape") ||
769 !strcmp(keyEvent.keyPressedName.c_str(), "Return") ||
770 !strcmp(keyEvent.keyPressedName.c_str(), "KP_Enter"))
772 ecore_imf_context_reset(mIMFContext);
779 bool InputMethodContextX::ProcessEventKeyUp( const KeyEvent& keyEvent )
781 bool eventHandled( false );
784 // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
785 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
786 ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str();
787 ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str();
788 ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();
789 ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str();
790 ecoreKeyUpEvent.timestamp = keyEvent.time;
791 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
792 ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
793 #ifdef ECORE_IMF_1_13
794 ecoreKeyUpEvent.dev_name = "";
795 #endif // ECORE_IMF_1_13
797 eventHandled = ecore_imf_context_filter_event(mIMFContext,
798 ECORE_IMF_EVENT_KEY_UP,
799 (Ecore_IMF_Event *) &ecoreKeyUpEvent);
804 Ecore_IMF_Keyboard_Modifiers InputMethodContextX::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier )
806 unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
808 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
810 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
813 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
815 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
818 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
820 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
823 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
825 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
828 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
830 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
833 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
836 Ecore_IMF_Keyboard_Locks InputMethodContextX::EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
838 unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
840 if( modifier & ECORE_EVENT_LOCK_NUM )
842 lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
845 if( modifier & ECORE_EVENT_LOCK_CAPS )
847 lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
850 if( modifier & ECORE_EVENT_LOCK_SCROLL )
852 lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
855 return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
864 #pragma GCC diagnostic pop