}
}
+static void
+_wsc_im_ctx_selection_text(void *data, struct wl_input_method_context *im_ctx, const char *text)
+{
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+
+ LOGD ("im_context = %p selection text = %s\n", im_ctx, text);
+ if (!wsc_ctx) return;
+
+ g_info_manager->socket_update_selection (text);
+}
+
static const struct wl_input_method_context_listener wsc_im_context_listener = {
_wsc_im_ctx_surrounding_text,
_wsc_im_ctx_reset,
_wsc_im_ctx_return_key_type,
_wsc_im_ctx_return_key_disabled,
_wsc_im_ctx_input_panel_data,
- _wsc_im_ctx_bidi_direction
+ _wsc_im_ctx_bidi_direction,
+ _wsc_im_ctx_selection_text
};
static void
BackEndPointer m_backend;
char* surrounding_text;
+ char* selection_text;
uint32 cursor_pos;
bool need_update_surrounding_text;
+ bool need_update_selection_text;
HelperAgentSignalVoid signal_exit;
HelperAgentSignalVoid signal_attach_input_context;
HelperAgentSignalUintVoid signal_check_option_window;
public:
- HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz), surrounding_text (NULL), cursor_pos (0), need_update_surrounding_text(false) {
+ HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
+ surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
+ need_update_surrounding_text (false), need_update_selection_text (false) {
}
{
LOGD ("");
String _text;
- //FIXME
- //thiz->get_selection (_text);
+ thiz->get_selection (_text);
text = utf8_mbstowcs (_text);
return true;
}
{
if (m_impl->surrounding_text != NULL)
free (m_impl->surrounding_text);
+ if (m_impl->selection_text != NULL)
+ free (m_impl->selection_text);
delete m_impl;
}
free (m_impl->surrounding_text);
m_impl->surrounding_text = strdup (text.c_str ());
m_impl->cursor_pos = cursor;
- LOGD ("%s, %d", m_impl->surrounding_text, m_impl->cursor_pos);
+ LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, m_impl->cursor_pos);
if (m_impl->need_update_surrounding_text) {
m_impl->need_update_surrounding_text = false;
m_impl->signal_update_surrounding_text (this, ic, text, (int) cursor);
case ISM_TRANS_CMD_UPDATE_SELECTION:
{
String text;
- if (m_impl->recv.get_data (text))
- m_impl->signal_update_selection (this, ic, text);
- else
+ if (m_impl->recv.get_data (text)) {
+ if (m_impl->selection_text != NULL)
+ free (m_impl->selection_text);
+
+ m_impl->selection_text = strdup (text.c_str ());
+ LOGD ("selection text: %s", m_impl->selection_text);
+
+ if (m_impl->need_update_selection_text) {
+ m_impl->need_update_selection_text = false;
+ m_impl->signal_update_selection (this, ic, text);
+ }
+ } else
LOGW ("wrong format of transaction\n");
break;
}
m_impl->send.put_data (uuid);
m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
}
+
+ m_impl->need_update_selection_text = true;
+}
+
+/**
+ * @brief Request to get selection text synchronously.
+ *
+ * @param text The selection text.
+ */
+void
+HelperAgent::get_selection (String &text) const
+{
+ LOGD ("");
+ if (m_impl->selection_text)
+ text = m_impl->selection_text;
}
/**