summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInHong Han <inhong1.han@samsung.com>2016-08-31 09:19:01 +0900
committerJihoon Kim <jihoon48.kim@samsung.com>2016-09-19 18:55:27 -0700
commitb10adf89f68d2ee931a32012ed6fe778945eace3 (patch)
tree5672c9c788cf5b2c35e0e9029730182211d6fe26
parentb79c153ab5513437f34ffdd80497efa5f954bf39 (diff)
downloadisf-b10adf89f68d2ee931a32012ed6fe778945eace3.tar.gz
isf-b10adf89f68d2ee931a32012ed6fe778945eace3.tar.bz2
isf-b10adf89f68d2ee931a32012ed6fe778945eace3.zip
Replace remote_control_default_text_cb() with remote_control_text_updated_cb()
Change-Id: I0f313b0503087118188e17a3e366ef676ce5b14c
-rw-r--r--ism/extras/efl_panel/remote_input.cpp7
-rwxr-xr-xism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp26
-rw-r--r--ism/modules/panelagent/wayland/isf_wsc_context.h11
-rwxr-xr-x[-rw-r--r--]ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp308
-rw-r--r--ism/src/isf_info_manager.cpp40
-rw-r--r--ism/src/isf_info_manager.h2
-rw-r--r--ism/src/isf_panel_agent_base.cpp13
-rw-r--r--ism/src/isf_panel_agent_base.h25
-rw-r--r--ism/src/isf_panel_agent_manager.cpp23
-rw-r--r--ism/src/isf_panel_agent_manager.h9
-rw-r--r--ism/src/isf_remote_client.cpp18
-rw-r--r--ism/src/isf_remote_client.h4
-rw-r--r--ism/src/isf_remote_control.cpp50
-rw-r--r--ism/src/isf_remote_control.h26
-rw-r--r--ism/src/scim_trans_commands.h2
15 files changed, 434 insertions, 130 deletions
diff --git a/ism/extras/efl_panel/remote_input.cpp b/ism/extras/efl_panel/remote_input.cpp
index a4efb30e..ae4d0327 100644
--- a/ism/extras/efl_panel/remote_input.cpp
+++ b/ism/extras/efl_panel/remote_input.cpp
@@ -517,12 +517,13 @@ void Remote_Input::handle_websocket_message(ISE_MESSAGE &message)
}
if (message.command.compare(ISE_MESSAGE_COMMAND_STRINGS[ISE_MESSAGE_COMMAND_UPDATE_PREEDIT_STRING]) == 0) {
- if (message.values.size() == 1) {
+ if (message.values.size() == 2) {
scim::AttributeList attrs;
attrs.push_back(scim::Attribute(0, scim::utf8_mbstowcs((char*)message.values.at(0).c_str()).length(), scim::SCIM_ATTR_DECORATE, scim::SCIM_ATTR_DECORATE_UNDERLINE));
- LOGD ("preedit:|%s|", message.values.at(0).c_str());
- _info_manager->remoteinput_update_preedit_string(scim::utf8_mbstowcs((char*)message.values.at(0).c_str()), attrs, -1);
+ int caret = atoi(message.values.at(1).c_str());
+ LOGD ("preedit:|%s|, caret = %d", message.values.at(0).c_str(), caret);
+ _info_manager->remoteinput_update_preedit_string(scim::utf8_mbstowcs((char*)message.values.at(0).c_str()), attrs, (uint32) caret);
}
}
diff --git a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
index 5e614c9c..eac93a2e 100755
--- a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
+++ b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
@@ -1072,7 +1072,7 @@ private:
}
}
- void socket_remoteinput_default_text (int client, String& text, uint32 cursor) {
+ void socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor) {
SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n";
LOGD ("client id:%d\n", client);
@@ -1084,7 +1084,7 @@ private:
m_send_trans.clear();
m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
- m_send_trans.put_command(ISM_REMOTE_TRANS_CMD_RECV_DEFAULT_TEXT);
+ m_send_trans.put_command(ISM_REMOTE_TRANS_CMD_RECV_SURROUNDING_TEXT);
m_send_trans.put_data(text);
m_send_trans.put_data(cursor);
m_send_trans.write_to_socket(client_socket);
@@ -1505,7 +1505,7 @@ private:
m_send_trans.write_to_socket(client_socket);
}
- void update_preedit_string (int client, uint32 target_context, const WideString &str, const AttributeList &attrs) {
+ void remote_update_preedit_string (int client, uint32 target_context, const WideString str, const AttributeList &attrs, uint32 caret) {
LOGD("client id:%d\n", client);
Socket client_socket(client);
@@ -1516,12 +1516,12 @@ private:
m_send_trans.put_command(SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
m_send_trans.put_data(str);
m_send_trans.put_data(attrs);
- m_send_trans.put_data(-1);
+ m_send_trans.put_data(caret);
m_send_trans.write_to_socket(client_socket);
unlock();
}
- void send_key_event (int client, uint32 target_context, const KeyEvent &key) {
+ void remote_send_key_event (int client, uint32 target_context, const KeyEvent &key) {
LOGD("client id:%d\n", client);
Socket client_socket(client);
@@ -1535,7 +1535,7 @@ private:
unlock();
}
- void forward_key_event (int client, uint32 target_context, const KeyEvent &key) {
+ void remote_forward_key_event (int client, uint32 target_context, const KeyEvent &key) {
LOGD("client id:%d\n", client);
Socket client_socket(client);
@@ -1548,6 +1548,20 @@ private:
m_send_trans.write_to_socket (client_socket);
unlock();
}
+
+ void remote_commit_string (int client, uint32 target_context, const WideString& wstr) {
+ LOGD ("client id:%d\n", client);
+
+ Socket socket_client(client);
+ lock();
+ m_send_trans.clear();
+ m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
+ m_send_trans.put_data(target_context);
+ m_send_trans.put_command(SCIM_TRANS_CMD_COMMIT_STRING);
+ m_send_trans.put_data(wstr);
+ m_send_trans.write_to_socket(socket_client);
+ unlock();
+ }
private:
static void send_fail_reply (int client_id)
diff --git a/ism/modules/panelagent/wayland/isf_wsc_context.h b/ism/modules/panelagent/wayland/isf_wsc_context.h
index 4c7307a6..95282559 100644
--- a/ism/modules/panelagent/wayland/isf_wsc_context.h
+++ b/ism/modules/panelagent/wayland/isf_wsc_context.h
@@ -39,6 +39,12 @@
typedef std::map <uint32_t, uint32_t> KeycodeRepository;
#endif
+typedef enum {
+ INPUT_RESOURCE_NONE,
+ INPUT_RESOURCE_LOCAL,
+ INPUT_RESOURCE_REMOTE
+} Input_Resource;
+
struct weescim;
const double DOUBLE_SPACE_INTERVAL = 1.0;
@@ -77,8 +83,10 @@ struct _WSCContextISF {
Ecore_Fd_Handler* surrounding_text_fd_read_handler;
Ecore_Fd_Handler* selection_text_fd_read_handler;
+ Ecore_Fd_Handler* remote_surrounding_text_fd_read_handler;
char *surrounding_text;
+ char *remote_surrounding_text;
char *selection_text;
char *preedit_str;
char *language;
@@ -134,7 +142,7 @@ void isf_wsc_context_focus_out (WSCContextISF *wsc_ctx);
void isf_wsc_context_preedit_string_get (WSCContextISF *wsc_ctx, char** str, int *cursor_pos);
void isf_wsc_context_autocapital_type_set (WSCContextISF* wsc_ctx, Ecore_IMF_Autocapital_Type autocapital_type);
void isf_wsc_context_bidi_direction_set (WSCContextISF* wsc_ctx, Ecore_IMF_BiDi_Direction direction);
-void isf_wsc_context_send_default_text (WSCContextISF* wsc_ctx, const char *text, int cursor);
+void isf_wsc_context_send_surrounding_text (WSCContextISF* wsc_ctx, const char *text, int cursor);
void isf_wsc_context_send_entry_metadata (WSCContextISF* wsc_ctx, Ecore_IMF_Input_Hints hint,
Ecore_IMF_Input_Panel_Layout layout, int variation,
Ecore_IMF_Autocapital_Type type);
@@ -153,6 +161,7 @@ void isf_wsc_context_filter_key_event (WSCContextISF* wsc_ctx,
#endif
bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *cursor_pos);
+void wsc_context_remote_surrounding_get (WSCContextISF *wsc_ctx);
Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get(WSCContextISF *wsc_ctx);
int wsc_context_input_panel_layout_variation_get (WSCContextISF *wsc_ctx);
bool wsc_context_input_panel_caps_lock_mode_get(WSCContextISF *wsc_ctx);
diff --git a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
index e23f4fd5..ef2923fc 100644..100755
--- a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
+++ b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
@@ -42,6 +42,7 @@
#include <malloc.h>
#include <dlog.h>
#include <glib.h>
+#include <limits.h>
#include <Eina.h>
#include <Ecore.h>
@@ -98,6 +99,10 @@ struct _WSCContextISFImpl {
bool preedit_started;
bool preedit_updating;
bool need_commit_preedit;
+ bool init_remote_entry_metadata;
+ bool init_remote_surrounding_text;
+ bool block_input_resource;
+ Input_Resource input_resource;
int next_shift_status;
int shift_mode_enabled;
@@ -124,6 +129,10 @@ struct _WSCContextISFImpl {
preedit_started(false),
preedit_updating(false),
need_commit_preedit(false),
+ init_remote_entry_metadata(true),
+ init_remote_surrounding_text(true),
+ block_input_resource(false),
+ input_resource(INPUT_RESOURCE_NONE),
next_shift_status(0),
shift_mode_enabled(0),
next(NULL)
@@ -182,13 +191,22 @@ static void panel_slot_update_preedit_caret (int
static void panel_slot_process_key_event (int context,
const KeyEvent &key);
static void panel_slot_commit_string (int context,
- const WideString &wstr);
+ const WideString &wstr,
+ bool remote_mode);
static void panel_slot_forward_key_event (int context,
- const KeyEvent &key);
+ const KeyEvent &key,
+ bool remote_mode);
+static void panel_slot_update_preedit_string (int context,
+ const WideString str,
+ const AttributeList &attrs,
+ int caret,
+ bool remote_mode);
static void _show_preedit_string (int context);
static void panel_req_update_bidi_direction (WSCContextISF *ic, int direction);
+static void remote_surrounding_get (WSCContextISF *wsc_ctx);
+
/* Panel iochannel handler*/
static void panel_initialize (void);
static void panel_finalize (void);
@@ -236,6 +254,8 @@ static bool _x_key_event_is_valid
static Input_Language input_lang = INPUT_LANG_OTHER;
+static Ecore_Timer *_resource_check_timer = NULL;
+
//FIXME: remove this definitions
#define SHIFT_MODE_OFF 0xffe1
#define SHIFT_MODE_ON 0xffe2
@@ -299,6 +319,8 @@ _wsc_im_ctx_content_type(void *data, struct wl_input_method_context *im_ctx, uin
isf_wsc_context_send_entry_metadata (wsc_ctx, wsc_context_input_hint_get (wsc_ctx), wsc_context_input_panel_layout_get (wsc_ctx),
wsc_context_input_panel_layout_variation_get (wsc_ctx), wsc_context_autocapital_type_get(wsc_ctx));
+
+ remote_surrounding_get (wsc_ctx);
}
static void
@@ -412,6 +434,8 @@ _wsc_im_ctx_cursor_position(void *data, struct wl_input_method_context *im_ctx,
wsc_ctx->surrounding_cursor = cursor_pos;
caps_mode_check (wsc_ctx, EINA_FALSE, EINA_TRUE);
g_info_manager->socket_update_cursor_position (cursor_pos);
+
+ remote_surrounding_get (wsc_ctx);
}
static void
@@ -650,6 +674,7 @@ _wsc_im_activate(void *data, struct wl_input_method *input_method, struct wl_inp
wsc->wsc_ctx = wsc_ctx;
wsc_ctx->ctx = wsc;
wsc_ctx->surrounding_text = NULL;
+ wsc_ctx->remote_surrounding_text = NULL;
wsc_ctx->surrounding_cursor = 0;
get_language(&wsc_ctx->language);
@@ -732,6 +757,11 @@ _wsc_im_deactivate(void *data, struct wl_input_method *input_method, struct wl_i
wsc_ctx->surrounding_text = NULL;
}
+ if (wsc_ctx->remote_surrounding_text) {
+ free (wsc_ctx->remote_surrounding_text);
+ wsc_ctx->remote_surrounding_text = NULL;
+ }
+
if (wsc_ctx->language) {
free (wsc_ctx->language);
wsc_ctx->language = NULL;
@@ -1261,6 +1291,46 @@ insert_text (const char *text, uint32_t offset, const char *insert)
return new_text;
}
+static Eina_Bool
+change_block_status_timer_cb (void *data)
+{
+ WSCContextISF* context_scim = static_cast<WSCContextISF*>(data);
+ if (context_scim && context_scim->impl)
+ context_scim->impl->block_input_resource = false;
+
+ _resource_check_timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+check_input_resource (WSCContextISF* wsc_ctx, Input_Resource input_res)
+{
+ WSCContextISF* context_scim = wsc_ctx;
+ LOGD ("Input resource : %d\n", input_res);
+ SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
+
+ if (context_scim && context_scim->impl) {
+ if (context_scim->impl->input_resource == input_res)
+ return;
+
+ if (context_scim->impl->input_resource == INPUT_RESOURCE_REMOTE && input_res == INPUT_RESOURCE_LOCAL) {
+ WideString wstr = context_scim->impl->preedit_string;
+
+ if (context_scim->impl->need_commit_preedit) {
+ _hide_preedit_string (context_scim->id, false);
+ wsc_context_commit_string (context_scim, utf8_wcstombs (wstr).c_str());
+ }
+
+ if (_resource_check_timer)
+ ecore_timer_del (_resource_check_timer);
+ _resource_check_timer = ecore_timer_add (2.0, change_block_status_timer_cb, context_scim);
+ context_scim->impl->block_input_resource = true;
+ }
+ context_scim->impl->input_resource = input_res;
+ }
+}
+
/* Public functions */
void
isf_wsc_context_init (void)
@@ -1328,7 +1398,9 @@ isf_wsc_context_add (WSCContextISF *wsc_ctx)
if (!context_scim) return;
context_scim->surrounding_text_fd_read_handler = NULL;
context_scim->selection_text_fd_read_handler = NULL;
+ context_scim->remote_surrounding_text_fd_read_handler = NULL;
context_scim->surrounding_text = NULL;
+ context_scim->remote_surrounding_text = NULL;
context_scim->selection_text = NULL;
context_scim->impl = new_ic_impl (context_scim);
@@ -1392,11 +1464,23 @@ isf_wsc_context_del (WSCContextISF *wsc_ctx)
context_scim->surrounding_text_fd_read_handler = NULL;
}
+ if (context_scim->remote_surrounding_text_fd_read_handler) {
+ int fd = ecore_main_fd_handler_fd_get(context_scim->remote_surrounding_text_fd_read_handler);
+ close(fd);
+ ecore_main_fd_handler_del(context_scim->remote_surrounding_text_fd_read_handler);
+ context_scim->remote_surrounding_text_fd_read_handler = NULL;
+ }
+
if (context_scim->surrounding_text) {
free (context_scim->surrounding_text);
context_scim->surrounding_text = NULL;
}
+ if (context_scim->remote_surrounding_text) {
+ free (context_scim->remote_surrounding_text);
+ context_scim->remote_surrounding_text = NULL;
+ }
+
if (context_scim->id != _ic_list->id) {
WSCContextISF * pre = _ic_list;
WSCContextISF * cur = _ic_list->next;
@@ -1505,6 +1589,10 @@ isf_wsc_context_focus_in (WSCContextISF *wsc_ctx)
g_info_manager->remoteinput_callback_focus_in ();
+ context_scim->impl->init_remote_entry_metadata = false;
+ context_scim->impl->init_remote_surrounding_text = false;
+ context_scim->impl->input_resource = INPUT_RESOURCE_NONE;
+
/* At the moment we received focus_in, our surrounding text has not been updated yet -
which means it will always turn Shift key on, resulting the whole keyboard blinking.
This is only a temporary solution - the caps_mode_check() needs be executed on
@@ -1549,6 +1637,9 @@ isf_wsc_context_focus_out (WSCContextISF *wsc_ctx)
_focused_ic = 0;
g_info_manager->remoteinput_callback_focus_out ();
+
+ context_scim->impl->init_remote_entry_metadata = true;
+ context_scim->impl->init_remote_surrounding_text = true;
}
_x_key_event_is_valid = false;
}
@@ -1623,7 +1714,7 @@ isf_wsc_context_bidi_direction_set (WSCContextISF* wsc_ctx, Ecore_IMF_BiDi_Direc
}
void
-isf_wsc_context_send_default_text (WSCContextISF* wsc_ctx, const char *text, int cursor)
+isf_wsc_context_send_surrounding_text (WSCContextISF* wsc_ctx, const char *text, int cursor)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
@@ -1636,12 +1727,15 @@ isf_wsc_context_send_default_text (WSCContextISF* wsc_ctx, const char *text, int
if (!conv_text)
return;
- if (strcmp (conv_text, text) != 0 || context_scim->impl->cursor_pos != cursor) {
+ if ((!context_scim->impl->init_remote_surrounding_text || strcmp (conv_text, text) != 0 || context_scim->impl->cursor_pos != cursor)) {
+ LOGD("remote surrounding text : %s\n", text);
context_scim->impl->surrounding_text = utf8_mbstowcs (String (text));
context_scim->impl->cursor_pos = cursor;
String _text(text);
- g_info_manager->remoteinput_callback_default_text (_text, context_scim->impl->cursor_pos);
+ g_info_manager->remoteinput_callback_surrounding_text (_text, context_scim->impl->cursor_pos);
+
+ context_scim->impl->init_remote_surrounding_text = true;
}
free (conv_text);
}
@@ -1655,16 +1749,19 @@ isf_wsc_context_send_entry_metadata (WSCContextISF* wsc_ctx, Ecore_IMF_Input_Hin
WSCContextISF *context_scim = wsc_ctx;
- if (context_scim && context_scim->impl &&
- (context_scim->impl->input_hint != hint || context_scim->impl->panel_layout != layout ||
+ if (context_scim && context_scim->impl) {
+ if (!context_scim->impl->init_remote_entry_metadata || (context_scim->impl->input_hint != hint || context_scim->impl->panel_layout != layout ||
context_scim->impl->variation != variation || context_scim->impl->autocapital_type != type)) {
- context_scim->impl->input_hint = hint;
- context_scim->impl->panel_layout = layout;
- context_scim->impl->variation = variation;
- context_scim->impl->autocapital_type = type;
+ context_scim->impl->input_hint = hint;
+ context_scim->impl->panel_layout = layout;
+ context_scim->impl->variation = variation;
+ context_scim->impl->autocapital_type = type;
- g_info_manager->remoteinput_callback_entry_metadata (context_scim->impl->input_hint, context_scim->impl->panel_layout,
- context_scim->impl->variation, context_scim->impl->autocapital_type);
+ g_info_manager->remoteinput_callback_entry_metadata (context_scim->impl->input_hint, context_scim->impl->panel_layout,
+ context_scim->impl->variation, context_scim->impl->autocapital_type);
+
+ context_scim->impl->init_remote_entry_metadata = true;
+ }
}
}
@@ -1994,6 +2091,93 @@ bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *curs
return true;
}
+static Eina_Bool
+remote_surrounding_text_fd_read_func(void* data, Ecore_Fd_Handler* fd_handler) {
+ if (fd_handler == NULL || data == NULL)
+ return ECORE_CALLBACK_RENEW;
+
+ WSCContextISF* wsc_ctx = (WSCContextISF*)data;
+
+ int fd = ecore_main_fd_handler_fd_get(fd_handler);
+ char buff[512];
+ int len = read (fd, buff, sizeof(buff) - 1);
+
+ if (len == 0) {
+ LOGD ("update");
+ isf_wsc_context_send_surrounding_text (wsc_ctx, wsc_ctx->remote_surrounding_text ? wsc_ctx->remote_surrounding_text : "", wsc_ctx->surrounding_cursor);
+ } else if (len < 0) {
+ LOGW ("failed");
+ } else {
+ buff[len] = '\0';
+ if (wsc_ctx->remote_surrounding_text == NULL) {
+ wsc_ctx->remote_surrounding_text = (char*)malloc (len + 1);
+ if (wsc_ctx->remote_surrounding_text) {
+ memcpy (wsc_ctx->remote_surrounding_text, buff, len);
+ wsc_ctx->remote_surrounding_text[len] = '\0';
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ LOGE ("malloc failed");
+ }
+ } else {
+ int old_len = strlen(wsc_ctx->remote_surrounding_text);
+ void * _new = realloc (wsc_ctx->remote_surrounding_text, len + old_len + 1);
+ if (_new) {
+ wsc_ctx->remote_surrounding_text = (char*)_new;
+ memcpy (wsc_ctx->remote_surrounding_text + old_len, buff, len);
+ wsc_ctx->remote_surrounding_text[old_len + len] = '\0';
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ LOGE ("realloc failed");
+ }
+ }
+ }
+
+ if (wsc_ctx->remote_surrounding_text_fd_read_handler) {
+ close(fd);
+ ecore_main_fd_handler_del(wsc_ctx->remote_surrounding_text_fd_read_handler);
+ wsc_ctx->remote_surrounding_text_fd_read_handler = NULL;
+ }
+
+ if (wsc_ctx->remote_surrounding_text) {
+ free (wsc_ctx->remote_surrounding_text);
+ wsc_ctx->remote_surrounding_text = NULL;
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+remote_surrounding_get (WSCContextISF *wsc_ctx)
+{
+ int filedes[2];
+ if (pipe2(filedes,O_CLOEXEC | O_NONBLOCK) == -1) {
+ LOGW ("create pipe failed");
+ } else {
+ LOGD("%d,%d",filedes[0],filedes[1]);
+ if (wsc_ctx && wsc_ctx->im_ctx) {
+ wl_input_method_context_get_surrounding_text(wsc_ctx->im_ctx, UINT_MAX, UINT_MAX, filedes[1]);
+ ecore_wl_flush();
+ }
+ close (filedes[1]);
+
+ if (wsc_ctx && wsc_ctx->im_ctx) {
+ if (wsc_ctx->remote_surrounding_text_fd_read_handler) {
+ int fd = ecore_main_fd_handler_fd_get(wsc_ctx->remote_surrounding_text_fd_read_handler);
+ close(fd);
+ ecore_main_fd_handler_del(wsc_ctx->remote_surrounding_text_fd_read_handler);
+ wsc_ctx->remote_surrounding_text_fd_read_handler = NULL;
+ }
+
+ if (wsc_ctx->remote_surrounding_text) {
+ free (wsc_ctx->remote_surrounding_text);
+ wsc_ctx->remote_surrounding_text = NULL;
+ }
+
+ wsc_ctx->remote_surrounding_text_fd_read_handler = ecore_main_fd_handler_add(filedes[0], ECORE_FD_READ, remote_surrounding_text_fd_read_func, wsc_ctx, NULL, NULL);
+ }
+ }
+}
+
Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get (WSCContextISF *wsc_ctx)
{
Ecore_IMF_Input_Panel_Layout layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
@@ -2438,7 +2622,7 @@ panel_slot_process_key_event (int context, const KeyEvent &key)
}
static void
-panel_slot_commit_string (int context, const WideString &wstr)
+panel_slot_commit_string (int context, const WideString &wstr, bool remote_mode)
{
LOGD ("");
WSCContextISF* ic = find_ic (context);
@@ -2448,6 +2632,14 @@ panel_slot_commit_string (int context, const WideString &wstr)
if (_focused_ic != ic)
return;
+ if (remote_mode) {
+ if (ic->impl->block_input_resource) {
+ LOGW ("block remote input\n");
+ return;
+ }
+ check_input_resource(ic, INPUT_RESOURCE_REMOTE);
+ }
+
if (utf8_wcstombs (wstr) == String (" ") || utf8_wcstombs (wstr) == String (" "))
autoperiod_insert (ic);
@@ -2458,7 +2650,7 @@ panel_slot_commit_string (int context, const WideString &wstr)
}
static void
-panel_slot_forward_key_event (int context, const KeyEvent &key)
+panel_slot_forward_key_event (int context, const KeyEvent &key, bool remote_mode)
{
LOGD ("");
WSCContextISF* ic = find_ic (context);
@@ -2470,6 +2662,14 @@ panel_slot_forward_key_event (int context, const KeyEvent &key)
if ((_focused_ic != NULL) && (_focused_ic != ic))
return;
+ if (remote_mode) {
+ if (ic->impl->block_input_resource) {
+ LOGW ("block remote input\n");
+ return;
+ }
+ check_input_resource(ic, INPUT_RESOURCE_REMOTE);
+ }
+
if (strlen (key.get_key_string ().c_str ()) >= 116)
return;
@@ -2477,6 +2677,56 @@ panel_slot_forward_key_event (int context, const KeyEvent &key)
}
static void
+panel_slot_update_preedit_string (int context, const WideString str, const AttributeList &attrs, int caret, bool remote_mode)
+{
+ LOGD ("");
+ WSCContextISF* ic = find_ic (context);
+ SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << " context=" << context << " caret=" << caret << " ic=" << ic << "\n";
+
+ if (ic && ic->impl && _focused_ic == ic) {
+ if (remote_mode) {
+ if (ic->impl->block_input_resource) {
+ LOGW ("block remote input\n");
+ return;
+ }
+ check_input_resource(ic, INPUT_RESOURCE_REMOTE);
+ }
+
+ if (!ic->impl->is_on)
+ ic->impl->is_on = true;
+
+ if (ic->impl->preedit_string != str || str.length ()) {
+ ic->impl->preedit_string = str;
+ ic->impl->preedit_attrlist = attrs;
+
+ if (ic->impl->use_preedit) {
+ if (!ic->impl->preedit_started) {
+ if (!check_valid_ic (ic))
+ return;
+
+ ic->impl->preedit_started = true;
+ ic->impl->need_commit_preedit = true;
+ }
+ if (caret >= 0 && caret <= (int)str.length ())
+ ic->impl->preedit_caret = caret;
+ else
+ ic->impl->preedit_caret = str.length ();
+
+ ic->impl->preedit_updating = true;
+
+ if (check_valid_ic (ic))
+ ic->impl->preedit_updating = false;
+
+ wsc_context_send_preedit_string (ic);
+ } else {
+ String _str = utf8_wcstombs (str);
+ g_info_manager->socket_update_preedit_string (_str, attrs, (uint32)caret);
+ }
+ }
+ }
+}
+
+static void
_show_preedit_string (int context)
{
LOGD ("");
@@ -2484,6 +2734,8 @@ _show_preedit_string (int context)
SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << " context=" << context << "\n";
if (ic && ic->impl && _focused_ic == ic) {
+ check_input_resource(ic, INPUT_RESOURCE_LOCAL);
+
if (!ic->impl->is_on)
ic->impl->is_on = true;
@@ -2769,19 +3021,37 @@ public:
if (cmd == SCIM_TRANS_CMD_PROCESS_KEY_EVENT)
panel_slot_process_key_event (context_id, key);
else
- panel_slot_forward_key_event (context_id, key);
+ panel_slot_forward_key_event (context_id, key, false);
}
void
commit_string (int id, uint32 context_id, const WideString& wstr) {
LOGD ("client id:%d", id);
- panel_slot_commit_string (context_id, wstr);
+ panel_slot_commit_string (context_id, wstr, false);
}
void
forward_key_event (int id, uint32 context_id, const KeyEvent &key) {
LOGD ("client id:%d", id);
- panel_slot_forward_key_event (context_id, key);
+ panel_slot_forward_key_event (context_id, key, true);
+ }
+
+ void
+ remote_commit_string (int id, uint32 context_id, const WideString& wstr) {
+ LOGD ("client id:%d", id);
+ panel_slot_commit_string (context_id, wstr, true);
+ }
+
+ void
+ remote_update_preedit_string (int id, uint32 context_id, const WideString str, const AttributeList &attrs, uint32 caret) {
+ LOGD ("client id:%d", id);
+ panel_slot_update_preedit_string (context_id, str, attrs, caret, true);
+ }
+
+ void
+ remote_forward_key_event (int id, uint32 context_id, const KeyEvent &key) {
+ LOGD ("client id:%d", id);
+ panel_slot_forward_key_event (context_id, key, true);
}
#if 0
@@ -2881,8 +3151,6 @@ public:
if (len == 0) {
LOGD ("update");
g_info_manager->socket_update_surrounding_text (wsc_ctx->surrounding_text ? wsc_ctx->surrounding_text : "", wsc_ctx->surrounding_cursor);
- isf_wsc_context_send_default_text (wsc_ctx, wsc_ctx->surrounding_text ? wsc_ctx->surrounding_text : "", wsc_ctx->surrounding_cursor);
-
} else if (len < 0) {
LOGW ("failed");
} else {
diff --git a/ism/src/isf_info_manager.cpp b/ism/src/isf_info_manager.cpp
index 50c21e64..0a13057d 100644
--- a/ism/src/isf_info_manager.cpp
+++ b/ism/src/isf_info_manager.cpp
@@ -261,7 +261,6 @@ class InfoManager::InfoManagerImpl
int m_current_recv_remoteinput_id;
IntIntRepository m_send_remoteinput_map;
IntIntRepository m_recv_remoteinput_map;
- bool m_remoteinput_status;
int m_last_socket_client;
uint32 m_last_client_context;
@@ -396,7 +395,7 @@ public:
m_active_client_id (-1),
m_should_shared_ise (false),
m_ise_exiting (false), m_is_imengine_aux (false), m_is_imengine_candidate (false),
- m_current_send_remoteinput_id (0), m_current_recv_remoteinput_id (0), m_remoteinput_status (true),
+ m_current_send_remoteinput_id (0), m_current_recv_remoteinput_id (0),
m_last_socket_client (-1), m_last_client_context (0),
m_ise_context_buffer (NULL), m_ise_context_length (0) {
m_current_ise_name = String (_ ("English Keyboard"));
@@ -1272,13 +1271,13 @@ public:
bool send_remote_input_message (int client_id, char* buf, size_t len) {
SCIM_DEBUG_MAIN(4) << "InfoManager::send_remote_input_message ()\n";
- if(buf == NULL) {
- return false;
+ if (buf && len > 0) {
+ String msg (buf);
+ m_signal_remoteinput_send_input_message (msg, true);
+ return true;
}
- String msg (buf);
- m_signal_remoteinput_send_input_message (msg, 1);
- return true;
+ return false;
}
void send_remote_surrounding_text (const char* text, uint32 cursor) {
@@ -1377,7 +1376,6 @@ public:
//SCIM_TRANS_CMD_PROCESS_KEY_EVENT
bool process_key_event (KeyEvent& key, uint32 serial) {
LOGD ("");
- if (m_remoteinput_status) m_remoteinput_status = false;
HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
@@ -1951,7 +1949,7 @@ public:
get_focused_context (client, context);
if (client >= 0) {
- m_panel_agent_manager.update_preedit_string (client, context, str, str, attrs, caret);
+ m_panel_agent_manager.remote_update_preedit_string (client, context, str, attrs, caret);
}
unlock ();
@@ -1969,7 +1967,7 @@ public:
get_focused_context (client, context);
if (client >= 0) {
- m_panel_agent_manager.commit_string (client, context, str);
+ m_panel_agent_manager.remote_commit_string (client, context, str);
}
unlock ();
@@ -1985,7 +1983,7 @@ public:
get_focused_context (client, context);
if (client >= 0) {
- m_panel_agent_manager.send_key_event (client, context, key);
+ m_panel_agent_manager.remote_send_key_event (client, context, key);
}
return client >= 0;
@@ -1999,7 +1997,7 @@ public:
get_focused_context (client, context);
if (client >= 0) {
- m_panel_agent_manager.forward_key_event (client, context, key);
+ m_panel_agent_manager.remote_forward_key_event (client, context, key);
}
return client >= 0;
@@ -2772,8 +2770,6 @@ client context helpers: %d, helpers uuid count: %d",
SCIM_DEBUG_MAIN (4) << __FUNCTION__ << "...\n";
LOGD ("");
- if (m_remoteinput_status) m_remoteinput_status = false;
-
lock();
m_panel_agent_manager.socket_remoteinput_focus_in (m_current_recv_remoteinput_id);
unlock ();
@@ -2797,17 +2793,13 @@ client context helpers: %d, helpers uuid count: %d",
unlock ();
}
- void remoteinput_callback_default_text (String text, uint32 cursor) {
+ void remoteinput_callback_surrounding_text (String text, uint32 cursor) {
SCIM_DEBUG_MAIN (4) << __FUNCTION__ << "...\n";
LOGD ("");
- if (!m_remoteinput_status) {
- lock();
- m_panel_agent_manager.socket_remoteinput_default_text (m_current_recv_remoteinput_id, text, cursor);
- unlock ();
-
- m_remoteinput_status = true;
- }
+ lock();
+ m_panel_agent_manager.socket_remoteinput_surrounding_text (m_current_recv_remoteinput_id, text, cursor);
+ unlock ();
}
//ISM_TRANS_CMD_UPDATE_SELECTION
@@ -4630,9 +4622,9 @@ void InfoManager::remoteinput_callback_entry_metadata (uint32 hint, uint32 layou
m_impl->remoteinput_callback_entry_metadata (hint, layout, variation, autocapital_type);
}
-void InfoManager::remoteinput_callback_default_text (String text, uint32 cursor)
+void InfoManager::remoteinput_callback_surrounding_text (String text, uint32 cursor)
{
- m_impl->remoteinput_callback_default_text (text, cursor);
+ m_impl->remoteinput_callback_surrounding_text (text, cursor);
}
//ISM_TRANS_CMD_UPDATE_SELECTION
diff --git a/ism/src/isf_info_manager.h b/ism/src/isf_info_manager.h
index 110d2b9f..7fa90fe7 100644
--- a/ism/src/isf_info_manager.h
+++ b/ism/src/isf_info_manager.h
@@ -578,7 +578,7 @@ public:
void remoteinput_callback_entry_metadata (uint32 hint, uint32 layout, int variation, uint32 autocapital_type);
- void remoteinput_callback_default_text (String text, uint32 cursor);
+ void remoteinput_callback_surrounding_text (String text, uint32 cursor);
/////////////////////////////////Message function begin/////////////////////////////////////////
diff --git a/ism/src/isf_panel_agent_base.cpp b/ism/src/isf_panel_agent_base.cpp
index ebd49771..062982cc 100644
--- a/ism/src/isf_panel_agent_base.cpp
+++ b/ism/src/isf_panel_agent_base.cpp
@@ -368,7 +368,7 @@ void PanelAgentBase::socket_remoteinput_entry_metadata (int client, uint32 hint,
LOGW ("not implemented for %s", m_name.c_str ());
}
-void PanelAgentBase::socket_remoteinput_default_text (int client, String& text, uint32 cursor)
+void PanelAgentBase::socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor)
{
LOGW ("not implemented for %s", m_name.c_str ());
}
@@ -530,17 +530,22 @@ void PanelAgentBase::set_autocapital_type(int client, uint32 context, String uui
LOGW("not implemented for %s", m_name.c_str());
}
-void PanelAgentBase::update_preedit_string (int client, uint32 context,const WideString &str, const AttributeList &attrs)
+void PanelAgentBase::remote_update_preedit_string (int client, uint32 context, const WideString str, const AttributeList &attrs, uint32 caret)
{
LOGW ("not implemented for %s", m_name.c_str ());
}
-void PanelAgentBase::send_key_event (int client, uint32 context,const KeyEvent &key)
+void PanelAgentBase::remote_send_key_event (int client, uint32 context, const KeyEvent &key)
{
LOGW ("not implemented for %s", m_name.c_str ());
}
-void PanelAgentBase::forward_key_event (int client, uint32 context,const KeyEvent &key)
+void PanelAgentBase::remote_forward_key_event (int client, uint32 context, const KeyEvent &key)
+{
+ LOGW ("not implemented for %s", m_name.c_str ());
+}
+
+void PanelAgentBase::remote_commit_string (int client, uint32 context,const WideString& wstr)
{
LOGW ("not implemented for %s", m_name.c_str ());
}
diff --git a/ism/src/isf_panel_agent_base.h b/ism/src/isf_panel_agent_base.h
index c8419b27..3c74d63d 100644
--- a/ism/src/isf_panel_agent_base.h
+++ b/ism/src/isf_panel_agent_base.h
@@ -575,13 +575,13 @@ public:
virtual void socket_remoteinput_entry_metadata (int client, uint32 hint, uint32 layout, int variation, uint32 autocapital_type);
/**
- * @brief socket_remoteinput_default_text.
+ * @brief socket_remoteinput_surrounding_text.
*
* @param
*
* @return none.
*/
- virtual void socket_remoteinput_default_text (int client, String& text, uint32 cursor);
+ virtual void socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor);
/**
* @brief socket_update_selection.
@@ -845,31 +845,40 @@ public:
virtual void set_autocapital_type(int client, uint32 context, String uuid, int mode);
/**
- * @brief update_preedit_string.
+ * @brief remote_update_preedit_string.
*
* @param
*
* @return none.
*/
- virtual void update_preedit_string (int client, uint32 context,const WideString &str, const AttributeList &attrs);
+ virtual void remote_update_preedit_string (int client, uint32 context, const WideString str, const AttributeList &attrs, uint32 caret);
/**
- * @brief send_key_event.
+ * @brief remote_send_key_event.
*
* @param
*
* @return none.
*/
- virtual void send_key_event (int client, uint32 context,const KeyEvent &key);
+ virtual void remote_send_key_event (int client, uint32 context, const KeyEvent &key);
/**
- * @brief forward_key_event.
+ * @brief remote_forward_key_event.
*
* @param
*
* @return none.
*/
- virtual void forward_key_event (int client, uint32 context,const KeyEvent &key);
+ virtual void remote_forward_key_event (int client, uint32 context, const KeyEvent &key);
+
+ /**
+ * @brief remote_commit_string.
+ *
+ * @param
+ *
+ * @return none.
+ */
+ virtual void remote_commit_string (int client, uint32 context,const WideString& wstr);
};
/** @} */
diff --git a/ism/src/isf_panel_agent_manager.cpp b/ism/src/isf_panel_agent_manager.cpp
index dba1daca..3d83fae9 100644
--- a/ism/src/isf_panel_agent_manager.cpp
+++ b/ism/src/isf_panel_agent_manager.cpp
@@ -596,12 +596,12 @@ void PanelAgentManager::socket_remoteinput_entry_metadata (int id, uint32 hint,
_p->socket_remoteinput_entry_metadata (id, hint, layout, variation, autocapital_type);
}
-void PanelAgentManager::socket_remoteinput_default_text (int id, String& text, uint32 cursor)
+void PanelAgentManager::socket_remoteinput_surrounding_text (int id, String& text, uint32 cursor)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
if (!_p.null ())
- _p->socket_remoteinput_default_text (id, text, cursor);
+ _p->socket_remoteinput_surrounding_text (id, text, cursor);
}
void PanelAgentManager::socket_update_selection (int id, uint32 context_id, String& uuid, String text)
@@ -830,30 +830,37 @@ void PanelAgentManager::set_autocapital_type(int id, uint32 context_id, String u
_p->set_autocapital_type (id, context_id, uuid, mode);
}
-void PanelAgentManager::update_preedit_string (int id, uint32 context_id, const WideString &str, const AttributeList &attrs)
+void PanelAgentManager::remote_update_preedit_string (int id, uint32 context_id, const WideString str, const AttributeList &attrs, uint32 caret)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
if (!_p.null ())
- _p->update_preedit_string (id, context_id, str, attrs);
+ _p->remote_update_preedit_string (id, context_id, str, attrs, caret);
}
-void PanelAgentManager::send_key_event (int id, uint32 context_id, const KeyEvent &key)
+void PanelAgentManager::remote_send_key_event (int id, uint32 context_id, const KeyEvent &key)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
if (!_p.null ())
- _p->send_key_event (id, context_id, key);
+ _p->remote_send_key_event (id, context_id, key);
}
-void PanelAgentManager::forward_key_event (int id, uint32 context_id, const KeyEvent &key)
+void PanelAgentManager::remote_forward_key_event (int id, uint32 context_id, const KeyEvent &key)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
if (!_p.null ())
- _p->forward_key_event (id, context_id, key);
+ _p->remote_forward_key_event (id, context_id, key);
}
+void PanelAgentManager::remote_commit_string (int id, uint32 context_id, const WideString& wstr)
+{
+ PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
+
+ if (!_p.null ())
+ _p->remote_commit_string (id, context_id, wstr);
+}
} /* namespace scim */
diff --git a/ism/src/isf_panel_agent_manager.h b/ism/src/isf_panel_agent_manager.h
index 57ee5045..a4851696 100644
--- a/ism/src/isf_panel_agent_manager.h
+++ b/ism/src/isf_panel_agent_manager.h
@@ -318,7 +318,7 @@ public:
void socket_remoteinput_focus_in (int client);
void socket_remoteinput_focus_out (int client);
void socket_remoteinput_entry_metadata (int client, uint32 hint, uint32 layout, int variation, uint32 autocapital_type);
- void socket_remoteinput_default_text (int client, String& text, uint32 cursor);
+ void socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor);
void socket_update_selection (int client, uint32 context, String& uuid, String text);
void socket_get_keyboard_ise_list (int client, uint32 context, const String& uuid, std::vector<String>& list);
void socket_get_candidate_ui (int client, uint32 context, const String& uuid, int style, int mode);
@@ -348,9 +348,10 @@ public:
bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
void process_key_event_done(int client, uint32 context, KeyEvent &key, uint32 ret, uint32 serial);
void set_autocapital_type(int id, uint32 context_id, String uuid, int mode);
- void update_preedit_string (int target_client, uint32 target_context, const WideString &str, const AttributeList &attrs);
- void send_key_event (int target_client, uint32 target_context, const KeyEvent &key);
- void forward_key_event (int target_client, uint32 target_context, const KeyEvent &key);
+ void remote_update_preedit_string (int target_client, uint32 target_context, const WideString str, const AttributeList &attrs, uint32 caret);
+ void remote_send_key_event (int target_client, uint32 target_context, const KeyEvent &key);
+ void remote_forward_key_event (int target_client, uint32 target_context, const KeyEvent &key);
+ void remote_commit_string (int target_client, uint32 target_context,const WideString& wstr);
};
/** @} */
diff --git a/ism/src/isf_remote_client.cpp b/ism/src/isf_remote_client.cpp
index c409dc41..8d790609 100644
--- a/ism/src/isf_remote_client.cpp
+++ b/ism/src/isf_remote_client.cpp
@@ -138,7 +138,7 @@ class RemoteInputClient::RemoteInputClientImpl
RemoteInputClientSignalVoid m_signal_show_ise;
RemoteInputClientSignalVoid m_signal_hide_ise;
- String m_default_text;
+ String m_surrounding_text;
uint32 m_hint, m_cursor, m_layout, m_variation, m_autocapital_type;
public:
@@ -146,7 +146,7 @@ public:
: m_socket_timeout (scim_get_default_socket_timeout ()),
m_socket_r2p_magic_key (0),
m_socket_p2r_magic_key (0),
- m_default_text (""),
+ m_surrounding_text (""),
m_hint (0),
m_cursor (0),
m_layout (0),
@@ -332,11 +332,11 @@ public:
LOGW ("wrong format of transaction\n");
break;
}
- case ISM_REMOTE_TRANS_CMD_RECV_DEFAULT_TEXT:
+ case ISM_REMOTE_TRANS_CMD_RECV_SURROUNDING_TEXT:
{
- type = REMOTE_CONTROL_CALLBACK_DEFAULT_TEXT;
+ type = REMOTE_CONTROL_CALLBACK_TEXT_UPDATED;
- if (m_trans_recv.get_data (m_default_text) && m_trans_recv.get_data (m_cursor)) {
+ if (m_trans_recv.get_data (m_surrounding_text) && m_trans_recv.get_data (m_cursor)) {
}
else
LOGW ("wrong format of transaction\n");
@@ -356,8 +356,8 @@ public:
*autocapital_type = m_autocapital_type;
}
- void get_default_text (String &default_text, int *cursor) {
- default_text = m_default_text;
+ void get_surrounding_text (String &surrounding_text, int *cursor) {
+ surrounding_text = m_surrounding_text;
*cursor = m_cursor;
}
};
@@ -439,9 +439,9 @@ RemoteInputClient::get_entry_metadata (int *hint, int *layout, int *variation, i
}
void
-RemoteInputClient::get_default_text (String &default_text, int *cursor)
+RemoteInputClient::get_surrounding_text (String &surrounding_text, int *cursor)
{
- m_impl->get_default_text (default_text, cursor);
+ m_impl->get_surrounding_text (surrounding_text, cursor);
}
};
diff --git a/ism/src/isf_remote_client.h b/ism/src/isf_remote_client.h
index de36daf6..40067bb6 100644
--- a/ism/src/isf_remote_client.h
+++ b/ism/src/isf_remote_client.h
@@ -33,7 +33,7 @@ typedef enum {
REMOTE_CONTROL_CALLBACK_FOCUS_IN,
REMOTE_CONTROL_CALLBACK_FOCUS_OUT,
REMOTE_CONTROL_CALLBACK_ENTRY_METADATA,
- REMOTE_CONTROL_CALLBACK_DEFAULT_TEXT,
+ REMOTE_CONTROL_CALLBACK_TEXT_UPDATED,
} remote_control_callback_type;
class EXAPI RemoteInputClient
@@ -56,7 +56,7 @@ public:
bool delete_surrounding_text(int offset, int len);
remote_control_callback_type recv_callback_message (void);
void get_entry_metadata (int *hint, int *layout, int *variation, int *autocapital_type);
- void get_default_text (String &default_text, int *cursor);
+ void get_surrounding_text (String &default_text, int *cursor);
};
}
diff --git a/ism/src/isf_remote_control.cpp b/ism/src/isf_remote_control.cpp
index 0a7aae27..89b00ade 100644
--- a/ism/src/isf_remote_control.cpp
+++ b/ism/src/isf_remote_control.cpp
@@ -15,7 +15,7 @@
using namespace scim;
-static bool focus_flag, event_check_flag;
+static bool focus_flag;
struct _remote_control_client {
RemoteInputClient remote_client;
@@ -27,8 +27,8 @@ struct _remote_control_client {
void* focus_out_cb_user_data;
remote_control_entry_metadata_cb metadata_cb;
void* metadata_cb_user_data;
- remote_control_default_text_cb default_text_cb;
- void* default_text_cb_user_data;
+ remote_control_text_updated_cb text_updated_cb;
+ void* text_updated_cb_user_data;
};
static Eina_Bool
@@ -41,7 +41,6 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
case REMOTE_CONTROL_CALLBACK_FOCUS_IN:
{
focus_flag = true;
- event_check_flag = false;
client->focus_in_cb (client->focus_in_cb_user_data);
break;
}
@@ -68,14 +67,14 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
}
break;
}
- case REMOTE_CONTROL_CALLBACK_DEFAULT_TEXT:
+ case REMOTE_CONTROL_CALLBACK_TEXT_UPDATED:
{
- if (focus_flag && !event_check_flag) {
- String default_text;
+ if (focus_flag) {
+ String surrounding_text;
int cursor;
- client->remote_client.get_default_text (default_text, &cursor);
- client->default_text_cb (client->default_text_cb_user_data, strdup (default_text.c_str ()), cursor);
+ client->remote_client.get_surrounding_text (surrounding_text, &cursor);
+ client->text_updated_cb (client->text_updated_cb_user_data, strdup (surrounding_text.c_str ()), cursor);
}
}
case REMOTE_CONTROL_CALLBACK_ERROR:
@@ -91,7 +90,6 @@ EXAPI remote_control_client * remote_control_connect(void)
{
remote_control_client *client = new remote_control_client;
focus_flag = false;
- event_check_flag = false;
if (client) {
RemoteInputClient *remote_client = new RemoteInputClient;
@@ -253,7 +251,7 @@ EXAPI int remote_control_entry_metadata_callback_unset(remote_control_client *cl
return REMOTE_CONTROL_ERROR_NONE;
}
-EXAPI int remote_control_default_text_callback_set(remote_control_client *client, remote_control_default_text_cb func, void *user_data)
+EXAPI int remote_control_text_updated_callback_set(remote_control_client *client, remote_control_text_updated_cb func, void *user_data)
{
if (client == NULL)
return REMOTE_CONTROL_INVALID_PARAMETER;
@@ -264,13 +262,13 @@ EXAPI int remote_control_default_text_callback_set(remote_control_client *client
if (!client->remote_client.check_privilege())
return REMOTE_CONTROL_PERMISSION_DENIED;
- client->default_text_cb = func;
- client->default_text_cb_user_data = user_data;
+ client->text_updated_cb = func;
+ client->text_updated_cb_user_data = user_data;
return REMOTE_CONTROL_ERROR_NONE;
}
-EXAPI int remote_control_default_text_callback_unset(remote_control_client *client)
+EXAPI int remote_control_text_updated_callback_unset(remote_control_client *client)
{
if (client == NULL)
return REMOTE_CONTROL_INVALID_PARAMETER;
@@ -281,8 +279,8 @@ EXAPI int remote_control_default_text_callback_unset(remote_control_client *clie
if (!client->remote_client.check_privilege())
return REMOTE_CONTROL_PERMISSION_DENIED;
- client->default_text_cb = NULL;
- client->default_text_cb_user_data = NULL;
+ client->text_updated_cb = NULL;
+ client->text_updated_cb_user_data = NULL;
return REMOTE_CONTROL_ERROR_NONE;
}
@@ -305,10 +303,9 @@ EXAPI int remote_control_send_key_event(remote_control_client *client, remote_co
if (!client->remote_client.prepare())
return REMOTE_CONTROL_REPLY_TIMEOUT;
- if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
- event_check_flag = true;
+ if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
return REMOTE_CONTROL_ERROR_NONE;
- }
+
return REMOTE_CONTROL_INVALID_OPERATION;
}
@@ -328,10 +325,9 @@ EXAPI int remote_control_send_commit_string(remote_control_client *client, const
if (!client->remote_client.prepare())
return REMOTE_CONTROL_REPLY_TIMEOUT;
- if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
- event_check_flag = true;
+ if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
return REMOTE_CONTROL_ERROR_NONE;
- }
+
return REMOTE_CONTROL_INVALID_OPERATION;
}
@@ -346,15 +342,16 @@ EXAPI int remote_control_update_preedit_string(remote_control_client *client, co
if (!client->remote_client.check_privilege())
return REMOTE_CONTROL_PERMISSION_DENIED;
- String command = String ("|plain|update_preedit_string|") + String (text) + String ("|");
+ char cursor_position[10] = {};
+ snprintf(cursor_position, sizeof(cursor_position), "%d", cursor_pos);
+ String command = String ("|plain|update_preedit_string|") + String (text) + String ("|") + String (cursor_position) + String ("|");
if (!client->remote_client.prepare())
return REMOTE_CONTROL_REPLY_TIMEOUT;
- if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
- event_check_flag = true;
+ if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
return REMOTE_CONTROL_ERROR_NONE;
- }
+
return REMOTE_CONTROL_INVALID_OPERATION;
}
@@ -371,6 +368,7 @@ EXAPI int remote_control_delete_surrounding_text(remote_control_client *client,
if (!client->remote_client.prepare())
return REMOTE_CONTROL_REPLY_TIMEOUT;
+
if (focus_flag && client->remote_client.delete_surrounding_text(offset, len))
return REMOTE_CONTROL_ERROR_NONE;
diff --git a/ism/src/isf_remote_control.h b/ism/src/isf_remote_control.h
index dedbaa40..64b77db5 100644
--- a/ism/src/isf_remote_control.h
+++ b/ism/src/isf_remote_control.h
@@ -311,7 +311,7 @@ EXAPI int remote_control_entry_metadata_callback_unset(remote_control_client *cl
*
* @privilege %http://tizen.org/privilege/imemanager
*
- * @remarks remote_control_default_text_cb() called after remote_control_entry_metadata_cb()
+ * @remarks remote_control_text_updated_cb() called after remote_control_entry_metadata_cb()
*
* @param[in] user_data User data to be passed from the callback registration function
* @param[in] default_text The UTF-8 string requested
@@ -319,13 +319,13 @@ EXAPI int remote_control_entry_metadata_callback_unset(remote_control_client *cl
*
* @pre The callback can be registered using remote_control_default_text_callback_set() function.
*
- * @see remote_control_default_text_callback_set()
- * @see remote_control_default_text_callback_unset()
+ * @see remote_control_text_updated_callback_set()
+ * @see remote_control_text_updated_callback_unset()
*/
-typedef void (*remote_control_default_text_cb)(void *user_data, char *default_text, int cursor_pos);
+typedef void (*remote_control_text_updated_cb)(void *user_data, char *default_text, int cursor_pos);
/**
- * @brief Register a remote_control_default_text_cb() callback function.
+ * @brief Register a remote_control_text_updated_cb() callback function.
*
* @since_tizen @if TV 3.0 @endif
*
@@ -334,7 +334,7 @@ typedef void (*remote_control_default_text_cb)(void *user_data, char *default_te
* @privilege %http://tizen.org/privilege/imemanager
*
* @param[in] client The remote control client
- * @param[in] func remote_control_default_text_cb() callback function
+ * @param[in] func remote_control_text_updated_cb() callback function
* @param[in] user_data User data to be passed to the callback function
*
* @return 0 on success, otherwise a negative error value
@@ -343,13 +343,13 @@ typedef void (*remote_control_default_text_cb)(void *user_data, char *default_te
* @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
* @retval #REMOTE_CONTROL_REPLY_TIMEOUT Socket connection failed
*
- * @see remote_control_default_text_cb()
- * @see remote_control_default_text_callback_unset()
+ * @see remote_control_text_updated_cb()
+ * @see remote_control_text_updated_callback_unset()
*/
-EXAPI int remote_control_default_text_callback_set(remote_control_client *client, remote_control_default_text_cb func, void *user_data);
+EXAPI int remote_control_text_updated_callback_set(remote_control_client *client, remote_control_text_updated_cb func, void *user_data);
/**
- * @brief Remove a remote_control_default_text_cb() callback function.
+ * @brief Remove a remote_control_text_updated_cb() callback function.
*
* @since_tizen @if TV 3.0 @endif
*
@@ -365,10 +365,10 @@ EXAPI int remote_control_default_text_callback_set(remote_control_client *client
* @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
* @retval #REMOTE_CONTROL_REPLY_TIMEOUT Socket connection failed
*
- * @see remote_control_default_text_cb()
- * @see remote_control_default_text_callback_set()
+ * @see remote_control_text_updated_cb()
+ * @see remote_control_text_updated_callback_set()
*/
-EXAPI int remote_control_default_text_callback_unset(remote_control_client *client);
+EXAPI int remote_control_text_updated_callback_unset(remote_control_client *client);
/**
* @brief Sends the key event to the associated text field.
diff --git a/ism/src/scim_trans_commands.h b/ism/src/scim_trans_commands.h
index 9193f5dd..23f7269c 100644
--- a/ism/src/scim_trans_commands.h
+++ b/ism/src/scim_trans_commands.h
@@ -641,7 +641,7 @@ const int ISM_REMOTE_TRANS_CMD_SEND_INPUT_MESSAGE = 1025;
const int ISM_REMOTE_TRANS_CMD_RECV_FOCUS_IN = 1026;
const int ISM_REMOTE_TRANS_CMD_RECV_FOCUS_OUT = 1027;
const int ISM_REMOTE_TRANS_CMD_RECV_ENTRY_METADATA = 1028;
-const int ISM_REMOTE_TRANS_CMD_RECV_DEFAULT_TEXT = 1029;
+const int ISM_REMOTE_TRANS_CMD_RECV_SURROUNDING_TEXT = 1029;
const int ISM_REMOTE_TRANS_CMD_CHECK_PRIVILEGE = 1030;
const int ISM_REMOTE_TRANS_CMD_DELETE_SURROUNDING_TEXT = 1031;