static Eina_Bool check_serial(WaylandIMContext *imcontext, uint32_t serial) { Ecore_IMF_Preedit_Attr *attr; if ((imcontext->serial - serial) > (imcontext->serial - imcontext->reset_serial)) { EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "outdated serial: %u, current: %u, reset: %u", serial, imcontext->serial, imcontext->reset_serial); /* Clear pending data */ imcontext->pending_commit.delete_index = 0; imcontext->pending_commit.delete_length = 0; imcontext->pending_commit.cursor = 0; imcontext->pending_commit.anchor = 0; imcontext->pending_preedit.cursor = 0; if (imcontext->pending_preedit.attrs) { EINA_LIST_FREE(imcontext->pending_preedit.attrs, attr) free(attr); imcontext->pending_preedit.attrs = NULL; } return EINA_FALSE; } return EINA_TRUE; }
static Ecore_IMF_Context * im_module_create() { Ecore_IMF_Context *ctx = NULL; WaylandIMContext *ctxd = NULL; if (!text_input_manager) { Ecore_Wl_Global *global; struct wl_registry *registry; Eina_Inlist *globals; if (!(registry = ecore_wl_registry_get())) return NULL; if (!(globals = ecore_wl_globals_get())) return NULL; EINA_INLIST_FOREACH(globals, global) { if (!strcmp(global->interface, "wl_text_input_manager")) { text_input_manager = wl_registry_bind(registry, global->id, &wl_text_input_manager_interface, 1); EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "bound wl_text_input_manager interface"); break; } } }
static void update_state(WaylandIMContext *imcontext) { char *surrounding = NULL; int cursor_pos; Ecore_Evas *ee; int canvas_x = 0, canvas_y = 0; Eina_Bool changed = EINA_FALSE; if (!imcontext->ctx) return; /* cursor_pos is a byte index */ if (ecore_imf_context_surrounding_get(imcontext->ctx, &surrounding, &cursor_pos)) { if (imcontext->text_input) { zwp_text_input_v1_set_surrounding_text(imcontext->text_input, surrounding, cursor_pos, cursor_pos); changed = EINA_TRUE; } if (surrounding) free(surrounding); } if (imcontext->canvas) { ee = ecore_evas_ecore_evas_get(imcontext->canvas); if (ee) ecore_evas_geometry_get(ee, &canvas_x, &canvas_y, NULL, NULL); } EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "canvas (x: %d, y: %d)", canvas_x, canvas_y); if (imcontext->text_input) { if (imcontext->cursor_location.do_set) { zwp_text_input_v1_set_cursor_rectangle(imcontext->text_input, imcontext->cursor_location.x + canvas_x, imcontext->cursor_location.y + canvas_y, imcontext->cursor_location.width, imcontext->cursor_location.height); imcontext->cursor_location.do_set = EINA_FALSE; changed = EINA_TRUE; } } if (changed) zwp_text_input_v1_commit_state(imcontext->text_input, ++imcontext->serial); _clear_hide_timer(); }