/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
size_t length = 0;
- if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
+ if( ( leadByte & 0x80 ) == 0 ) //ASCII character (lead bit zero)
{
length = 1;
}
- else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ else if( ( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
{
length = 2;
}
- else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ else if( ( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
{
length = 3;
}
- else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ else if( ( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
{
length = 4;
}
+ else if( ( leadByte & 0xfc ) == 0xf8 ) //1111 10xx
+ {
+ length = 5;
+ }
+ else if( ( leadByte & 0xfe ) == 0xfc ) //1111 110x
+ {
+ length = 6;
+ }
return length;
}
{
ecore_imf_init();
- actor.OnStageSignal().Connect( this, &InputMethodContextX::OnStaged );
+ actor.OnSceneSignal().Connect( this, &InputMethodContextX::OnStaged );
}
InputMethodContextX::~InputMethodContextX()
size_t byteIndex = 0;
// iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
- const char leadByte = preEditString[byteIndex];
+ char leadByte = preEditString[byteIndex];
+
while( leadByte != '\0' )
{
+ leadByte = preEditString[byteIndex]; // Update the character to get the number of its byte
+
// attr->end_index is provided as a byte position not character and we need to know the character position.
const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
if( byteIndex <= attr->start_index )
{
data.startIndex = visualCharacterIndex;
}
- if ( byteIndex >= attr->end_index )
+ if( byteIndex >= attr->end_index )
{
data.endIndex = visualCharacterIndex;
break;
Dali::InputMethodContext::TextDirection InputMethodContextX::GetTextDirection()
{
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );
+ Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );
if ( mIMFContext )
{
bool eventHandled( false );
// If a device key then skip ecore_imf_context_filter_event.
- if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))
+ if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))
{
//check whether it's key down or key up event
- if ( keyEvent.state == KeyEvent::Down )
+ if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )
{
eventHandled = ProcessEventKeyDown( keyEvent );
}
- else if ( keyEvent.state == KeyEvent::Up )
+ else if ( keyEvent.GetState() == Dali::KeyEvent::UP )
{
eventHandled = ProcessEventKeyUp( keyEvent );
}
// ecore_imf_context_input_panel_position_set() is supported from ecore-imf 1.21.0 version.
}
-void InputMethodContextX::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const
+void InputMethodContextX::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
attrs = mPreeditAttrs;
}
-bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent )
+bool InputMethodContextX::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )
{
bool eventHandled( false );
if ( mIMFContext )
{
- Integration::KeyEvent integKeyEvent( keyEvent );
+ Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
std::string key = integKeyEvent.logicalKey;
- std::string compose = keyEvent.GetCompose();
+ std::string compose = integKeyEvent.compose;
// We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
- ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str();
+ ecoreKeyDownEvent.keyname = integKeyEvent.keyName.c_str();
ecoreKeyDownEvent.key = key.c_str();
- ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();
+ ecoreKeyDownEvent.string = integKeyEvent.keyString.c_str();
ecoreKeyDownEvent.compose = compose.c_str();
- ecoreKeyDownEvent.timestamp = keyEvent.time;
- ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
- ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
+ ecoreKeyDownEvent.timestamp = integKeyEvent.time;
+ ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
+ ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR)
#if (ECORE_VERSION_MINOR >= 14)
ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
#endif // Since ecore_imf 1.14 version
#if (ECORE_VERSION_MINOR >= 22)
- ecoreKeyDownEvent.keycode = keyEvent.keyCode;
+ ecoreKeyDownEvent.keycode = integKeyEvent.keyCode;
#endif // Since ecore_imf 1.22 version
#endif // Since ecore_imf Version 1
// 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.
- if ((keyEvent.GetDeviceName() == "ime") && ((!strncmp(keyEvent.keyPressedName.c_str(), "Left", 4)) ||
- (!strncmp(keyEvent.keyPressedName.c_str(), "Right", 5)) ||
- (!strncmp(keyEvent.keyPressedName.c_str(), "Up", 2)) ||
- (!strncmp(keyEvent.keyPressedName.c_str(), "Down", 4))))
+ if ((integKeyEvent.deviceName == "ime") && ((!strncmp(integKeyEvent.keyName.c_str(), "Left", 4)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Right", 5)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Up", 2)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Down", 4))))
{
eventHandled = 0;
}
// If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext
if (!eventHandled)
{
- if (!strcmp(keyEvent.keyPressedName.c_str(), "Escape") ||
- !strcmp(keyEvent.keyPressedName.c_str(), "Return") ||
- !strcmp(keyEvent.keyPressedName.c_str(), "KP_Enter"))
+ if (!strcmp(integKeyEvent.keyName.c_str(), "Escape") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "Return") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "KP_Enter"))
{
ecore_imf_context_reset(mIMFContext);
}
return eventHandled;
}
-bool InputMethodContextX::ProcessEventKeyUp( const KeyEvent& keyEvent )
+bool InputMethodContextX::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )
{
bool eventHandled( false );
if( mIMFContext )
{
- Integration::KeyEvent integKeyEvent( keyEvent );
+ Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
+
std::string key = integKeyEvent.logicalKey;
- std::string compose = keyEvent.GetCompose();
+ std::string compose = integKeyEvent.compose;
// We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
- ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str();
+ ecoreKeyUpEvent.keyname = integKeyEvent.keyName.c_str();
ecoreKeyUpEvent.key = key.c_str();
- ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();
+ ecoreKeyUpEvent.string = integKeyEvent.keyString.c_str();
ecoreKeyUpEvent.compose = compose.c_str();
- ecoreKeyUpEvent.timestamp = keyEvent.time;
- ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
- ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
+ ecoreKeyUpEvent.timestamp = integKeyEvent.time;
+ ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
+ ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR)
#if (ECORE_VERSION_MINOR >= 14)
ecoreKeyUpEvent.dev_name = "";
#endif // Since ecore_imf 1.14 version
#if (ECORE_VERSION_MINOR >= 22)
- ecoreKeyUpEvent.keycode = keyEvent.keyCode;
+ ecoreKeyUpEvent.keycode = integKeyEvent.keyCode;
#endif // Since ecore_imf 1.22 version
#endif // Since ecore_imf Version 1