static Eina_Bool
_ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
{
- Ecore_Pipe *p;
- double start_time;
+ Ecore_Pipe *p = (Ecore_Pipe *)data;
int i;
- p = (Ecore_Pipe *)data;
- start_time = ecore_time_get();
-
p->handling++;
for (i = 0; i < 16; i++)
{
ret = pipe_read(p->fd_read, &p->len, sizeof(p->len));
/* catch the non error case first */
+ /* read amount ok - nothing more to do */
if (ret == sizeof(p->len))
;
else if (ret > 0)
{
- /* XXX What should we do here? */
- ERR("Only read %zd bytes from the pipe, although"
- " we need to read %zd bytes.", ret, sizeof(p->len));
+ /* we got more data than we asked for - definite error */
+ ERR("Only read %i bytes from the pipe, although"
+ " we need to read %i bytes.",
+ (int)ret, (int)sizeof(p->len));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else if (ret == 0)
{
+ /* we got no data even though we had data to read */
if (!p->delete_me)
- p->handler((void *)p->data, NULL, 0);
+ p->handler((void *)p->data, NULL, 0);
+ if (p->passed_data) free(p->passed_data);
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
}
else
{
- ERR("An unhandled error (ret: %zd errno: %d [%s])"
+ ERR("An unhandled error (ret: %i errno: %i [%s])"
"occurred while reading from the pipe the length",
- ret, errno, strerror(errno));
+ (int)ret, errno, strerror(errno));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
+ if (p->passed_data) free(p->passed_data);
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
#endif
}
+ /* if somehow we got less than or equal to 0 we got an errnoneous
+ * messages so call callback with null and len we got */
+ if (p->len <= 0)
+ {
+ if (!p->delete_me)
+ p->handler((void *)p->data, NULL, p->len);
+ /* reset all values to 0 */
+ if (p->passed_data) free(p->passed_data);
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
+ _ecore_pipe_unhandle(p);
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ /* we dont have a buffer to hold the data, so alloc it */
if (!p->passed_data)
- p->passed_data = malloc(p->len);
+ {
+ p->passed_data = malloc(p->len);
+ /* alloc failed - error case */
+ if (!p->passed_data)
+ {
+ if (!p->delete_me)
+ p->handler((void *)p->data, NULL, 0);
+ /* close the pipe */
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
+ p->fd_handler = NULL;
+ _ecore_pipe_unhandle(p);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
/* and read the passed data */
ret = pipe_read(p->fd_read,
p->len - p->already_read);
/* catch the non error case first */
+ /* if we read enough data to finish the message/buffer */
if (ret == (ssize_t)(p->len - p->already_read))
{
if (!p->delete_me)
p->len = 0;
p->message++;
}
- else if (ret >= 0)
+ else if (ret > 0)
{
+ /* more data left to read */
p->already_read += ret;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else if (ret == 0)
{
+ /* 0 bytes available when woken up to handle read - error */
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
+ if (p->passed_data) free(p->passed_data);
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
#ifndef _WIN32
else if ((ret == PIPE_FD_ERROR) &&
((errno == EINTR) || (errno == EAGAIN)))
- return ECORE_CALLBACK_RENEW;
+ {
+ _ecore_pipe_unhandle(p);
+ return ECORE_CALLBACK_RENEW;
+ }
else
{
ERR("An unhandled error (ret: %zd errno: %d)"
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
+ if (p->passed_data) free(p->passed_data);
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
Ecore_IMF_Input_Panel_Layout (*input_panel_layout_get) (Ecore_IMF_Context *ctx);
void (*input_panel_language_set) (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Lang lang);
Ecore_IMF_Input_Panel_Lang (*input_panel_language_get) (Ecore_IMF_Context *ctx);
+ void (*cursor_location_set) (Ecore_IMF_Context *ctx, int x, int y, int w, int h);
};
struct _Ecore_IMF_Context_Info
EAPI void ecore_imf_context_focus_out(Ecore_IMF_Context *ctx);
EAPI void ecore_imf_context_reset(Ecore_IMF_Context *ctx);
EAPI void ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos);
+EAPI void ecore_imf_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int w, int h);
EAPI void ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit);
EAPI void ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos), const void *data);
EAPI void ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode);
}
/**
+ * Notify the Input Method Context that a change in the cursor
+ * location has been made. The location is relative to the canvas.
+ *
+ * @param ctx An #Ecore_IMF_Context.
+ * @param x cursor x position.
+ * @param x cursor y position.
+ * @param w cursor width.
+ * @param h cursor height.
+ * @ingroup Ecore_IMF_Context_Group
+ */
+EAPI void
+ecore_imf_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int w, int h)
+{
+ if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
+ {
+ ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
+ "ecore_imf_context_cursor_position_set");
+ return;
+ }
+ if (ctx->klass->cursor_location_set) ctx->klass->cursor_location_set(ctx, x, y, w, h);
+}
+
+/**
* Set whether the IM context should use the preedit string
* to display feedback. If @use_preedit is EINA_FALSE (default
* is EINA_TRUE), then the IM context may use some other method to display