static void
set_focus_out(Ecore_IMF_Context *ctx)
{
+ char *surrounding = NULL;
+ int cursor_pos = 0;
+
WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
if (!imcontext || !imcontext->input) return;
+ if (ecore_imf_context_surrounding_get(ctx, &surrounding, &cursor_pos)) {
+ if (surrounding) {
+ wl_text_input_finalize_content(imcontext->text_input, surrounding, cursor_pos);
+ free(surrounding);
+ }
+ }
+
// deactivate
if (imcontext->text_input)
wl_text_input_deactivate(imcontext->text_input,
m_send_trans.write_to_socket(client_socket);
}
- void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type) {
+ void set_helper_mime_type(int client, uint32 context, const String& uuid, String& mime_type) {
LOGD ("client id:%d\n", client);
Socket client_socket(client);
m_send_trans.write_to_socket(client_socket);
}
+ void finalize_content_helper(int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos) {
+ LOGD("client id:%d\n", client);
+
+ Socket client_socket(client);
+ m_send_trans.clear();
+ m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
+ m_send_trans.put_data(context);
+ m_send_trans.put_data(uuid);
+ m_send_trans.put_command(ISM_TRANS_CMD_FINALIZE_CONTENT);
+ m_send_trans.put_data(text);
+ m_send_trans.put_data(cursor_pos);
+ m_send_trans.write_to_socket(client_socket);
+ }
+
bool process_key_event(int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial) {
LOGD ("client id:%d\n", client);
g_info_manager->set_ise_mime_type (get_panel_client_id (), String (mime_type));
return 0;
}
+
+int _isf_wsc_context_input_panel_finalize_content (int context, const char *text, int cursor_pos)
+{
+ g_info_manager->finalize_content (get_panel_client_id (), String (text), cursor_pos);
+ return 0;
+}
/*
vi:ts=4:expandtab:nowrap
*/
int _isf_wsc_context_process_input_device_event(int context, int type, const void* data, int len);
int _isf_wsc_context_input_panel_prediction_hint_set (int context, const char *prediction_hint);
int _isf_wsc_context_input_panel_mime_type_accept_set (int context, const char *mime_type);
+ int _isf_wsc_context_input_panel_finalize_content (int context, const char *text, int cursor_pos);
#ifdef __cplusplus
}
{
_isf_wsc_context_input_panel_mime_type_accept_set (_get_context_id(ctx), mime_type);
}
+
+void isf_wsc_context_input_panel_finalize_content (WSCContextISF *ctx, const char *text, int cursor_pos)
+{
+ _isf_wsc_context_input_panel_finalize_content (_get_context_id(ctx), text, cursor_pos);
+}
void isf_wsc_context_process_input_device_event (WSCContextISF *ctx, uint32_t type, const char *data, uint32_t len);
void isf_wsc_context_input_panel_prediction_hint_set (WSCContextISF *ctx, const char *prediction_hint);
void isf_wsc_context_input_panel_mime_type_accept_set (WSCContextISF *ctx, const char *mime_type);
+ void isf_wsc_context_input_panel_finalize_content (WSCContextISF *ctx, const char *text, int cursor_pos);
#ifdef __cplusplus
}
isf_wsc_context_input_panel_mime_type_accept_set (wsc_ctx, mime_type);
}
+static void
+_wsc_im_ctx_finalized_content (void *data, struct wl_input_method_context *im_ctx, const char *text, uint32_t cursor_pos)
+{
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+
+ SECURE_LOGD ("im_context = %p, text = %s, cursor_pos = %d\n", im_ctx, text, cursor_pos);
+ if (!wsc_ctx) return;
+
+ isf_wsc_context_input_panel_finalize_content (wsc_ctx, text, cursor_pos);
+}
+
static const struct wl_input_method_context_listener wsc_im_context_listener = {
_wsc_im_ctx_reset,
_wsc_im_ctx_content_type,
_wsc_im_ctx_filter_key_event,
_wsc_im_ctx_capital_mode,
_wsc_im_ctx_prediction_hint,
- _wsc_im_ctx_mime_type
+ _wsc_im_ctx_mime_type,
+ _wsc_im_ctx_finalized_content
};
#if ENABLE_GRAB_KEYBOARD
return false;
}
+ bool finalize_content_helper (const String& uuid, String text, uint32 cursor_pos) {
+ HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
+
+ if (it != m_helper_client_index.end ()) {
+ int client;
+ uint32 context;
+ uint32 ctx;
+ get_focused_context (client, context);
+ ctx = get_helper_ic (client, context);
+ LOGD ("Send ISM_TRANS_CMD_FINALIZE_CONTENT message");
+ m_panel_agent_manager.finalize_content_helper (it->second.id, ctx, uuid, text, cursor_pos);
+ return true;
+ }
+
+ return false;
+ }
+
//ISM_TRANS_CMD_SHOW_ISF_CONTROL
void show_isf_panel (int client_id) {
LOGD ("");
set_helper_mime_type (m_current_helper_uuid, mime_type);
}
+ //ISM_TRANS_CMD_FINALIZE_CONTENT
+ void finalize_content (int client_id, String text, uint32 cursor_pos) {
+ SCIM_DEBUG_MAIN (4) << "InfoManager::finalize_content ()\n";
+ LOGD ("");
+ if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
+ finalize_content_helper (m_current_helper_uuid, text, cursor_pos);
+ }
+
//ISM_TRANS_CMD_EXPAND_CANDIDATE
void expand_candidate () {
LOGD ("");
m_impl->set_ise_mime_type (client_id, mime_type);
}
+//ISM_TRANS_CMD_FINALIZE_CONTENT
+void InfoManager::finalize_content (int client_id, String text, uint32 cursor_pos)
+{
+ m_impl->finalize_content (client_id, text, cursor_pos);
+}
+
//ISM_TRANS_CMD_EXPAND_CANDIDATE
void InfoManager::expand_candidate ()
{
//ISM_TRANS_CMD_SET_MIME_TYPE
void set_ise_mime_type (int client_id, String mime_type);
+ //ISM_TRANS_CMD_FINALIZE_CONTENT
+ void finalize_content(int client_id, String text, uint32 cursor_pos);
+
//ISM_TRANS_CMD_EXPAND_CANDIDATE
void expand_candidate ();
String m_mime_type;
};
+/* ISM_TRANS_CMD_FINALIZE_CONTENT */
+class MessageItemFinalizeContent : public MessageItemHelper
+{
+public:
+ MessageItemFinalizeContent() : m_cursor_pos(0) {}
+ virtual ~MessageItemFinalizeContent() {}
+
+ String& get_text_ref() { return m_text; }
+ uint32& get_cursor_pos_ref() { return m_cursor_pos; }
+protected:
+ String m_text;
+ uint32 m_cursor_pos;
+};
+
template <typename T>
inline T*
alloc_message() /* We could use memory pool in the future for performance enhancement */
}
break;
}
+ case ISM_TRANS_CMD_FINALIZE_CONTENT:
+ {
+ MessageItemFinalizeContent *message = alloc_message<MessageItemFinalizeContent>();
+ if (message) {
+ message->get_command_ref() = cmd;
+ if (transaction.get_data(message->get_text_ref()) &&
+ transaction.get_data(message->get_cursor_pos_ref())) {
+ m_list_messages.push_back(message);
+ } else {
+ LOGW("wrong format of transaction\n");
+ dealloc_message<MessageItemFinalizeContent>(message);
+ }
+ }
+ break;
+ }
}
}
LOGW ("not implemented for %s", m_name.c_str ());
}
+void PanelAgentBase::finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos)
+{
+ LOGW("not implemented for %s", m_name.c_str());
+}
+
bool PanelAgentBase::process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial)
{
LOGW ("not implemented for %s", m_name.c_str ());
virtual void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
/**
+ * @brief finalize_content_helper.
+ *
+ * @param
+ *
+ * @return none.
+ */
+ virtual void finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos);
+
+ /**
* @brief process_key_event.
*
* @param
_p->set_helper_mime_type (id, context_id, uuid, mime_type);
}
+void PanelAgentManager::finalize_content_helper (int id, uint32 context_id, const String& uuid, String& text, uint32& cursor_pos)
+{
+ PanelAgentPointer _p = m_impl->get_panel_agent_by_id(id);
+
+ if (!_p.null())
+ _p->finalize_content_helper (id, context_id, uuid, text, cursor_pos);
+}
+
bool PanelAgentManager::process_key_event (int id, uint32 context_id, const String& uuid, KeyEvent& key, uint32 serial)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
void set_helper_keyboard_mode (int client, uint32 context, const String& uuid, uint32& mode);
void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
+ void finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos);
bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial);
bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
uint32 layout;
bool ise_show_flag;
bool hw_keyboard_mode;
+ bool ise_focus_flag;
+ char* finalized_text;
+ uint32 finalized_cursor_pos;
HelperAgentSignalVoid signal_exit;
HelperAgentSignalVoid signal_attach_input_context;
HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
need_update_surrounding_text (0), need_update_selection_text (0),
- layout (0), ise_show_flag (false), hw_keyboard_mode (false) {
+ layout (0), ise_show_flag (false), hw_keyboard_mode (false), ise_focus_flag (false),
+ finalized_text(NULL), finalized_cursor_pos(0) {
}
~HelperAgentImpl () {
if (surrounding_text != NULL)
free (surrounding_text);
+ if (finalized_text != NULL)
+ free(finalized_text);
+
if (selection_text != NULL)
free (selection_text);
case SCIM_TRANS_CMD_FOCUS_OUT:
{
MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
+ m_impl->ise_focus_flag = false;
m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
m_impl->focused_ic = (uint32) -1;
if (!m_impl->si.null ()) m_impl->si->focus_out();
case SCIM_TRANS_CMD_FOCUS_IN:
{
MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
+ m_impl->ise_focus_flag = true;
m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
m_impl->focused_ic = subclass->get_ic_ref();
+ if (m_impl->finalized_text != NULL)
+ free(m_impl->finalized_text);
+ m_impl->finalized_text = NULL;
+ m_impl->finalized_cursor_pos = 0;
if (!m_impl->si.null ()) m_impl->si->focus_in();
break;
}
}
break;
}
+ case ISM_TRANS_CMD_FINALIZE_CONTENT:
+ {
+ MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
+ if (m_impl) {
+ if (m_impl->finalized_text != NULL)
+ free(m_impl->finalized_text);
+ m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
+ m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
+ }
+ break;
+ }
default:
break;
}
if (!m_impl->socket_active.is_connected ())
return;
- m_impl->send.clear ();
- m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
- m_impl->send.put_data (m_impl->magic_active);
- m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
- m_impl->send.put_data ("");
- m_impl->send.put_data (maxlen_before);
- m_impl->send.put_data (maxlen_after);
- m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
- if (m_impl->surrounding_text) {
- free (m_impl->surrounding_text);
- m_impl->surrounding_text = NULL;
- }
+ if (!m_impl->ise_focus_flag) {
+ if (m_impl->finalized_text) {
+ String buffer = m_impl->finalized_text;
+ cursor = m_impl->finalized_cursor_pos;
+ int pos = cursor - maxlen_before;
+ if (pos < 0) pos = 0;
+ int len = maxlen_after + (cursor - pos);
+ if (len < 0) len = INT_MAX;
+ text = buffer.substr (pos, len);
+ } else {
+ text.clear ();
+ cursor = 0;
+ }
+ } else {
+ m_impl->send.clear();
+ m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
+ m_impl->send.put_data(m_impl->magic_active);
+ m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
+ m_impl->send.put_data("");
+ m_impl->send.put_data(maxlen_before);
+ m_impl->send.put_data(maxlen_after);
+ m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
+ if (m_impl->surrounding_text) {
+ free(m_impl->surrounding_text);
+ m_impl->surrounding_text = NULL;
+ }
- const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
- /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
- if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
- MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
- handle_message(message);
- message_queue.remove_message(message);
+ const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
+ /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
+ if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
+ MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
+ handle_message(message);
+ message_queue.remove_message(message);
- if (m_impl->surrounding_text) {
- text = m_impl->surrounding_text;
- cursor = m_impl->cursor_pos;
+ if (m_impl->surrounding_text) {
+ text = m_impl->surrounding_text;
+ cursor = m_impl->cursor_pos;
+ }
}
- }
- if (m_impl->surrounding_text) {
- free (m_impl->surrounding_text);
- m_impl->surrounding_text = NULL;
+ if (m_impl->surrounding_text) {
+ free(m_impl->surrounding_text);
+ m_impl->surrounding_text = NULL;
+ }
}
}
const int ISM_TRANS_CMD_SET_KEYBOARD_MODE = 1128;
const int ISM_TRANS_CMD_SET_PREDICTION_HINT = 1129;
const int ISM_TRANS_CMD_SET_MIME_TYPE = 1130;
+const int ISM_TRANS_CMD_FINALIZE_CONTENT = 1131;
/* ISE/Panel to IMControl */
const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT = 1151;