char *req_surrounding = eina_unicode_unicode_to_utf8_range (wide_surrounding + maxlen_before, maxlen_after - maxlen_before, NULL);
- if (req_surrounding) {
+ ssize_t ret = write(fd, &cursor_pos, sizeof(cursor_pos));
+ if (ret <= 0) {
+ LOGW ("write pipe failed, errno: %d", errno);
+ } else if (req_surrounding) {
char *_surrounding = req_surrounding;
size_t len = strlen(req_surrounding);
while (len) {
if (!wsc_ctx || !wsc_ctx->impl) return;
wsc_ctx->impl->cursor_pos = cursor_pos;
wsc_ctx->surrounding_cursor = cursor_pos;
+ LOGD ("wsc_ctx->surrounding_cursor = %d\n", wsc_ctx->surrounding_cursor);
g_info_manager->socket_update_cursor_position (cursor_pos);
#if ENABLE_REMOTE_INPUT
wsc_ctx->surrounding_text = NULL;
wsc_ctx->remote_surrounding_text = NULL;
wsc_ctx->surrounding_cursor = 0;
+ LOGD ("wsc_ctx->surrounding_cursor = %d\n", wsc_ctx->surrounding_cursor);
get_language (&wsc_ctx->language);
free (wsc_ctx->surrounding_text);
wsc_ctx->surrounding_text = surrounding_text;
wsc_ctx->surrounding_cursor += strlen (wsc_ctx->preedit_str);
+ LOGD ("wsc_ctx->surrounding_cursor = %d\n", wsc_ctx->surrounding_cursor);
} else {
wsc_ctx->surrounding_text = strdup (wsc_ctx->preedit_str);
wsc_ctx->surrounding_cursor = strlen (wsc_ctx->preedit_str);
+ LOGD ("wsc_ctx->surrounding_cursor = %d\n", wsc_ctx->surrounding_cursor);
}
if (wsc_ctx->preedit_str)
char buff[512];
int len = read (fd, buff, sizeof (buff) - 1);
if (len == 0) {
- LOGD ("update");
+ LOGD ("update, wsc_ctx->surrounding_cursor = %d\n", wsc_ctx->surrounding_cursor);
g_info_manager->socket_update_surrounding_text (wsc_ctx->surrounding_text ? wsc_ctx->surrounding_text : "", wsc_ctx->surrounding_cursor);
} else if (len < 0) {
LOGW ("failed");
} else {
buff[len] = '\0';
if (wsc_ctx->surrounding_text == NULL) {
- wsc_ctx->surrounding_text = (char*)malloc (len + 1);
+ /* Add one byte for terminating NULL character and subtract <int> byte for cursor position */
+ wsc_ctx->surrounding_text = (char*)malloc (len + 1 - sizeof(int));
if (wsc_ctx->surrounding_text) {
- memcpy (wsc_ctx->surrounding_text, buff, len);
- wsc_ctx->surrounding_text[len] = '\0';
+ memcpy(&(wsc_ctx->surrounding_cursor), buff, sizeof(int));
+ memcpy (wsc_ctx->surrounding_text, buff + sizeof(int), len - sizeof(int));
+ wsc_ctx->surrounding_text[len - sizeof(int)] = '\0';
return ECORE_CALLBACK_RENEW;
} else {
LOGE ("malloc failed");