/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
#include <dali/internal/input/ubuntu-x11/input-method-context-impl-x.h>
// EXTERNAL INCLUDES
-#include <Ecore_IMF.h>
-#include <Ecore_Input.h>
+#include <dali/internal/input/linux/dali-ecore-imf.h>
+#include <dali/internal/input/ubuntu-x11/dali-ecore-input.h>
#include <dali/public-api/events/key-event.h>
#include <dali/public-api/adaptor-framework/key.h>
#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor.h>
-#include <dali/internal/window-system/ubuntu-x11/window-render-surface-x.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/system/common/locale-utils.h>
#include <dali/internal/system/common/singleton-service-impl.h>
#include <dali/internal/input/common/virtual-keyboard-impl.h>
#include <dali/internal/input/common/key-impl.h>
-// Ecore is littered with C style cast
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>
namespace Dali
const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
if ( byteIndex == attr->end_index )
{
- cursorPosition = visualCharacterIndex;
+ cursorPosition = static_cast<int>( visualCharacterIndex );
break;
// end loop as found cursor position that matches byte position
}
return eventHandled;
}
+void InputMethodContextX::AllowTextPrediction( bool prediction )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::AllowTextPrediction\n" );
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_prediction_allow_set( mIMFContext, prediction );
+ }
+}
+
+bool InputMethodContextX::IsTextPredictionAllowed() const
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::IsTextPredictionAllowed\n" );
+ bool prediction = false;
+ if( mIMFContext )
+ {
+ prediction = ecore_imf_context_prediction_allow_get( mIMFContext );
+ }
+ return prediction;
+}
+
+void InputMethodContextX::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelLanguage\n" );
+ if( mIMFContext )
+ {
+ switch (language)
+ {
+ case Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC:
+ {
+ ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC );
+ break;
+ }
+ case Dali::InputMethodContext::InputPanelLanguage::ALPHABET:
+ {
+ ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET );
+ break;
+ }
+ }
+ }
+}
+
+Dali::InputMethodContext::InputPanelLanguage InputMethodContextX::GetInputPanelLanguage() const
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLanguage\n" );
+ if( mIMFContext )
+ {
+ int value;
+ value = ecore_imf_context_input_panel_language_get( mIMFContext );
+
+ switch (value)
+ {
+ case ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC:
+ {
+ return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
+ break;
+ }
+ case ECORE_IMF_INPUT_PANEL_LANG_ALPHABET:
+ {
+ return Dali::InputMethodContext::InputPanelLanguage::ALPHABET;
+ break;
+ }
+ }
+ }
+ return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
+}
+
bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent )
{
bool eventHandled( false );
if ( mIMFContext )
{
+ Integration::KeyEvent integKeyEvent( keyEvent );
+ std::string key = integKeyEvent.logicalKey;
+
+ std::string compose = keyEvent.GetCompose();
+
// 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.key = keyEvent.keyPressedName.c_str();
+ ecoreKeyDownEvent.key = key.c_str();
ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();
- ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str();
+ ecoreKeyDownEvent.compose = compose.c_str();
ecoreKeyDownEvent.timestamp = keyEvent.time;
ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
{
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_DOWN,
- (Ecore_IMF_Event *) &ecoreKeyDownEvent);
+ reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyDownEvent ));
}
// If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext
bool eventHandled( false );
if( mIMFContext )
{
+ Integration::KeyEvent integKeyEvent( keyEvent );
+ std::string key = integKeyEvent.logicalKey;
+
+ std::string compose = keyEvent.GetCompose();
+
// 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.key = keyEvent.keyPressedName.c_str();
+ ecoreKeyUpEvent.key = key.c_str();
ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();
- ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str();
+ ecoreKeyUpEvent.compose = compose.c_str();
ecoreKeyUpEvent.timestamp = keyEvent.time;
ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_UP,
- (Ecore_IMF_Event *) &ecoreKeyUpEvent);
+ reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyUpEvent ));
}
return eventHandled;
}
} // Internal
} // Dali
-
-#pragma GCC diagnostic pop