eldbus_shutdown();
}
-void
+Eina_Bool
wkb_ibus_shutdown(void)
{
if (!wkb_ibus)
{
ERR("Not initialized");
- return;
+ return EINA_FALSE;
}
if (wkb_ibus->shutting_down)
- return;
+ return EINA_TRUE;
if (wkb_ibus->refcount == 0)
{
ERR("Refcount already 0");
- return;
+ return EINA_FALSE;
}
if (--(wkb_ibus->refcount) != 0)
- return;
+ return EINA_TRUE;
DBG("Shutting down");
wkb_ibus->shutting_down = EINA_TRUE;
wkb_ibus_disconnect();
+
+ return EINA_TRUE;
}
void
}
txt = wkb_ibus_text_from_message_iter(iter);
- DBG("Preedit text: '%s'", txt->text);
+ DBG("Preedit text: '%s', Cursor: '%d'", txt->text, cursor);
wkb_ibus->input_ctx->preedit = strdup(txt->text);
wkb_ibus->input_ctx->cursor = cursor;
return;
}
- wl_input_method_context_preedit_cursor(wkb_ibus->input_ctx->wl_ctx,
- wkb_ibus->input_ctx->cursor);
+ wl_input_method_context_preedit_cursor(wkb_ibus->input_ctx->wl_ctx, cursor);
_set_preedit_text(wkb_ibus->input_ctx->preedit);
}
}
if (!ret)
- wl_input_method_context_key(wkb_ibus->input_ctx->wl_ctx,
- wkb_ibus->input_ctx->serial,
- 0, *key_code-8, WL_KEYBOARD_KEY_STATE_PRESSED);
+ {
+ INF("Key press was not handled by IBus");
+ wl_input_method_context_key(wkb_ibus->input_ctx->wl_ctx,
+ wkb_ibus->input_ctx->serial,
+ 0, *key_code-8, WL_KEYBOARD_KEY_STATE_PRESSED);
+ }
}
static void
}
if (!ret)
- wl_input_method_context_key(wkb_ibus->input_ctx->wl_ctx,
- wkb_ibus->input_ctx->serial,
- 0, *key_code-8, WL_KEYBOARD_KEY_STATE_RELEASED);
+ {
+ INF("Key release was not handled by IBus");
+ wl_input_method_context_key(wkb_ibus->input_ctx->wl_ctx,
+ wkb_ibus->input_ctx->serial,
+ 0, *key_code-8, WL_KEYBOARD_KEY_STATE_RELEASED);
+ }
}
static unsigned int
#include <string.h>
#include "wkb-log.h"
+#include "wkb-ibus.h"
+
#include "input-method-client-protocol.h"
#include "text-client-protocol.h"
uint32_t preedit_style;
uint32_t content_hint;
uint32_t content_purpose;
- uint32_t serial;
uint32_t surrounding_cursor;
Eina_Bool context_changed;
static void
_cb_wkb_delete_request(Ecore_Evas *ee EINA_UNUSED)
{
- ecore_main_loop_quit();
+ if (!wkb_ibus_shutdown())
+ ecore_main_loop_quit();
}
static char *
return;
wl_input_method_context_cursor_position(wkb->im_ctx, 0, 0);
- wl_input_method_context_commit_string(wkb->im_ctx, wkb->serial, wkb->preedit_str);
+ wl_input_method_context_commit_string(wkb->im_ctx, wkb_ibus_input_context_serial(), wkb->preedit_str);
if (wkb->surrounding_text)
{
index = cursor;
wl_input_method_context_preedit_cursor(wkb->im_ctx, index);
- wl_input_method_context_preedit_string(wkb->im_ctx, wkb->serial, wkb->preedit_str, wkb->preedit_str);
+ wl_input_method_context_preedit_string(wkb->im_ctx, wkb_ibus_input_context_serial(), wkb->preedit_str, wkb->preedit_str);
}
static void
DBG("Ignoring key: '%s'", key);
goto end;
}
+
+ wkb_ibus_input_context_process_key_event(key);
+#if 0
else if (strcmp(key, "backspace") == 0)
{
if (strlen(wkb->preedit_str) == 0)
DBG("Key pressed: '%s'", key);
_wkb_update_preedit_str(wkb, key);
-
+#endif
end:
free(src);
}
static void
_wkb_im_ctx_surrounding_text(void *data, struct wl_input_method_context *im_ctx, const char *text, uint32_t cursor, uint32_t anchor)
{
+#if 0
struct weekeyboard *wkb = data;
- DBG("");
free(wkb->surrounding_text);
wkb->surrounding_text = strdup(text);
wkb->surrounding_cursor = cursor;
+#endif
}
static void
_wkb_im_ctx_reset(void *data, struct wl_input_method_context *im_ctx)
{
+#if 0
struct weekeyboard *wkb = data;
- DBG("");
-
if (strlen(wkb->preedit_str))
{
free(wkb->preedit_str);
wkb->preedit_str = strdup("");
}
+#endif
}
static void
static void
_wkb_im_ctx_invoke_action(void *data, struct wl_input_method_context *im_ctx, uint32_t button, uint32_t index)
{
+#if 0
struct weekeyboard *wkb = data;
- DBG("");
if (button != BTN_LEFT)
return;
_wkb_send_preedit_str(wkb, index);
+#endif
}
static void
{
struct weekeyboard *wkb = data;
- DBG("");
if (wkb->surrounding_text)
INF("Surrounding text updated: %s", wkb->surrounding_text);
- wkb->serial = serial;
+ wkb_ibus_input_context_set_serial(serial);
+#if 0
/* FIXME */
- wl_input_method_context_language(im_ctx, wkb->serial, "en");//wkb->language);
- wl_input_method_context_text_direction(im_ctx, wkb->serial, WL_TEXT_INPUT_TEXT_DIRECTION_LTR);//wkb->text_direction);
+ wl_input_method_context_language(im_ctx, wkb_ibus_input_context_serial(), "en");//wkb->language);
+ wl_input_method_context_text_direction(im_ctx, wkb_ibus_input_context_serial(), WL_TEXT_INPUT_TEXT_DIRECTION_LTR);//wkb->text_direction);
+#endif
}
static void
_wkb_im_ctx_preferred_language(void *data, struct wl_input_method_context *im_ctx, const char *language)
{
+#if 0
struct weekeyboard *wkb = data;
if (language && wkb->language && !strcmp(language, wkb->language))
wkb->language = strdup(language);
INF("Language changed, new: '%s'", language);
}
+#endif
}
static const struct wl_input_method_context_listener wkb_im_context_listener = {
_wkb_im_activate(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weekeyboard *wkb = data;
- struct wl_array modifiers_map;
+
+ DBG("Activate");
if (wkb->im_ctx)
wl_input_method_context_destroy(wkb->im_ctx);
wkb->preedit_str = strdup("");
wkb->content_hint = WL_TEXT_INPUT_CONTENT_HINT_NONE;
wkb->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NORMAL;
+
free(wkb->language);
wkb->language = NULL;
+
free(wkb->surrounding_text);
wkb->surrounding_text = NULL;
- wkb->serial = 0;
+
+ wkb_ibus_input_context_set_serial(0);
wkb->im_ctx = im_ctx;
wl_input_method_context_add_listener(im_ctx, &wkb_im_context_listener, wkb);
+ wkb_ibus_input_context_create(im_ctx);
- /*
+#if 0
+ struct wl_array modifiers_map;
wl_array_init(&modifiers_map);
keysym_modifiers_add(&modifiers_map, "Shift");
*/
/* FIXME */
- wl_input_method_context_language(im_ctx, wkb->serial, "en");//wkb->language);
- wl_input_method_context_text_direction(im_ctx, wkb->serial, WL_TEXT_INPUT_TEXT_DIRECTION_LTR);//wkb->text_direction);
-
+ wl_input_method_context_language(im_ctx, wkb_ibus_input_context_serial(), "en");//wkb->language);
+ wl_input_method_context_text_direction(im_ctx, wkb_ibus_input_context_serial(), WL_TEXT_INPUT_TEXT_DIRECTION_LTR);//wkb->text_direction);
+#endif
wkb->context_changed = EINA_TRUE;
evas_object_show(wkb->edje_obj);
}
{
struct weekeyboard *wkb = data;
- if (!wkb->im_ctx)
- return;
+ DBG("Deactivate");
+
+ wkb_ibus_input_context_destroy();
+
+ if (wkb->im_ctx)
+ {
+ wl_input_method_context_destroy(wkb->im_ctx);
+ wkb->im_ctx = NULL;
+ }
- wl_input_method_context_destroy(wkb->im_ctx);
- wkb->im_ctx = NULL;
evas_object_hide(wkb->edje_obj);
}
char *ignore_keys;
ecore_evas_alpha_set(wkb->ee, EINA_TRUE);
- ecore_evas_title_set(wkb->ee, "EFL virtual keyboard");
+ ecore_evas_title_set(wkb->ee, "Weekeyboard");
evas = ecore_evas_get(wkb->ee);
wkb->edje_obj = edje_object_add(evas);
if (!edje_object_file_set(wkb->edje_obj, path, "main"))
{
int err = edje_object_load_error_get(wkb->edje_obj);
- ERR("error loading the edje file: '%s'", edje_load_error_str(err));
+ ERR("Unable to load the edje file: '%s'", edje_load_error_str(err));
return EINA_FALSE;
}
}
/* Set input panel surface */
+ DBG("Setting up input panel");
wkb->win = ecore_evas_wayland_window_get(wkb->ee);
ecore_wl_window_type_set(wkb->win, ECORE_WL_WINDOW_TYPE_NONE);
wkb->surface = ecore_wl_window_surface_create(wkb->win);
wl_input_panel_surface_set_toplevel(ips, wkb->output, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
/* Input method listener */
+ DBG("Adding wl_input_method listener");
wl_input_method_add_listener(wkb->im, &wkb_im_listener, wkb);
}
if (wkb->im_ctx)
wl_input_method_context_destroy(wkb->im_ctx);
+ if (wkb->edje_obj)
+ evas_object_del(wkb->edje_obj);
+
if (wkb->ignore_keys)
{
free(*wkb->ignore_keys);
free(wkb->ignore_keys);
}
- evas_object_del(wkb->edje_obj);
free(wkb->preedit_str);
free(wkb->surrounding_text);
}
return ret;
}
+static Eina_Bool
+_wkb_check_ibus_connection(void *data)
+{
+ static int tries = 0;
+
+ if (tries++ > 5)
+ {
+ CRITICAL("Unable to establish connection to IBus.");
+ return ECORE_CALLBACK_DONE;
+ }
+
+ return !wkb_ibus_is_connected();
+}
+
int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
return ret;
if (!ecore_evas_init())
- goto log_err;
+ goto ee_err;
if (!edje_init())
- goto ee_err;
+ goto edj_err;
if (!_wkb_check_evas_engine(&wkb))
- goto edj_err;
+ goto engine_err;
DBG("Selected engine: '%s'", wkb.ee_engine);
wkb.ee = ecore_evas_new(wkb.ee_engine, 0, 0, 1, 1, "frame=0");
_wkb_setup(&wkb);
+ wkb_ibus_init();
+
if (!_wkb_ui_setup(&wkb))
goto end;
+ wkb_ibus_connect();
+ ecore_timer_add(1, _wkb_check_ibus_connection, NULL);
ecore_main_loop_begin();
ret = EXIT_SUCCESS;
- _wkb_free(&wkb);
-
end:
+ _wkb_free(&wkb);
ecore_evas_free(wkb.ee);
-edj_err:
+engine_err:
edje_shutdown();
-ee_err:
+edj_err:
ecore_evas_shutdown();
-log_err:
+ee_err:
wkb_log_shutdown();
return ret;