diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 11 | ||||
-rw-r--r-- | src/wkb-ibus-panel.c | 4 | ||||
-rw-r--r-- | src/wkb-ibus.c | 35 | ||||
-rw-r--r-- | src/wkb-ibus.h | 2 | ||||
-rw-r--r-- | src/wkb-main.c | 110 |
5 files changed, 109 insertions, 53 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ee0b7cf..bb6c7a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,17 @@ weekeyboard_SOURCES= \ wkb-main.c \ wkb-log.c \ wkb-log.h \ + wkb-ibus.h \ + wkb-ibus.c \ + wkb-ibus-helper.h \ + wkb-ibus-helper.c \ + wkb-ibus-defs.h \ + wkb-ibus-panel.c \ + wkb-ibus-config.c \ + wkb-ibus-config-key.c \ + wkb-ibus-config-key.h \ + wkb-ibus-config-eet.c \ + wkb-ibus-config-eet.h \ input-method-protocol.c \ input-method-client-protocol.h \ text-protocol.c \ diff --git a/src/wkb-ibus-panel.c b/src/wkb-ibus-panel.c index d4398e2..a52f471 100644 --- a/src/wkb-ibus-panel.c +++ b/src/wkb-ibus-panel.c @@ -236,8 +236,6 @@ _panel_focus_in(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg { _panel_check_message_errors(msg); - INF("FOCUS IN!!!"); - return NULL; } @@ -246,8 +244,6 @@ _panel_focus_out(const Eldbus_Service_Interface *iface, const Eldbus_Message *ms { _panel_check_message_errors(msg); - INF("FOCUS OUT!!!"); - return NULL; } diff --git a/src/wkb-ibus.c b/src/wkb-ibus.c index 5d48e32..a884c22 100644 --- a/src/wkb-ibus.c +++ b/src/wkb-ibus.c @@ -546,30 +546,32 @@ _wkb_ibus_shutdown_finish(void) 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 @@ -730,7 +732,7 @@ _ibus_input_ctx_update_preedit_text(void *data, const Eldbus_Message *msg) } 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; @@ -740,8 +742,7 @@ _ibus_input_ctx_update_preedit_text(void *data, const Eldbus_Message *msg) 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); } @@ -851,9 +852,12 @@ _ibus_input_ctx_key_press(void *data, const Eldbus_Message *msg, Eldbus_Pending } 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 @@ -871,9 +875,12 @@ _ibus_input_ctx_key_release(void *data, const Eldbus_Message *msg, Eldbus_Pendin } 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 diff --git a/src/wkb-ibus.h b/src/wkb-ibus.h index bca1bcd..8a2512d 100644 --- a/src/wkb-ibus.h +++ b/src/wkb-ibus.h @@ -31,7 +31,7 @@ extern int WKB_IBUS_CONNECTED; extern int WKB_IBUS_DISCONNECTED; int wkb_ibus_init(void); -void wkb_ibus_shutdown(void); +Eina_Bool wkb_ibus_shutdown(void); Eina_Bool wkb_ibus_connect(void); void wkb_ibus_disconnect(void); diff --git a/src/wkb-main.c b/src/wkb-main.c index dd10b29..945cac6 100644 --- a/src/wkb-main.c +++ b/src/wkb-main.c @@ -30,6 +30,8 @@ #include <string.h> #include "wkb-log.h" +#include "wkb-ibus.h" + #include "input-method-client-protocol.h" #include "text-client-protocol.h" @@ -55,7 +57,6 @@ struct weekeyboard uint32_t preedit_style; uint32_t content_hint; uint32_t content_purpose; - uint32_t serial; uint32_t surrounding_cursor; Eina_Bool context_changed; @@ -64,7 +65,8 @@ struct weekeyboard 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 * @@ -89,7 +91,7 @@ _wkb_commit_preedit_str(struct weekeyboard *wkb) 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) { @@ -120,7 +122,7 @@ _wkb_send_preedit_str(struct weekeyboard *wkb, int cursor) 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 @@ -175,6 +177,9 @@ _cb_wkb_on_key_down(void *data, Evas_Object *obj, const char *emission EINA_UNUS 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) @@ -206,7 +211,7 @@ _cb_wkb_on_key_down(void *data, Evas_Object *obj, const char *emission EINA_UNUS DBG("Key pressed: '%s'", key); _wkb_update_preedit_str(wkb, key); - +#endif end: free(src); } @@ -214,26 +219,27 @@ end: 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 @@ -270,13 +276,14 @@ _wkb_im_ctx_content_type(void *data, struct wl_input_method_context *im_ctx, uin 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 @@ -284,19 +291,21 @@ _wkb_im_ctx_commit_state(void *data, struct wl_input_method_context *im_ctx, uin { 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)) @@ -313,6 +322,7 @@ _wkb_im_ctx_preferred_language(void *data, struct wl_input_method_context *im_ct wkb->language = strdup(language); INF("Language changed, new: '%s'", language); } +#endif } static const struct wl_input_method_context_listener wkb_im_context_listener = { @@ -328,7 +338,8 @@ static void _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); @@ -339,16 +350,21 @@ _wkb_im_activate(void *data, struct wl_input_method *input_method, struct wl_inp 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"); @@ -363,9 +379,9 @@ _wkb_im_activate(void *data, struct wl_input_method *input_method, struct wl_inp */ /* 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); } @@ -375,11 +391,16 @@ _wkb_im_deactivate(void *data, struct wl_input_method *input_method, struct wl_i { 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); } @@ -398,7 +419,7 @@ _wkb_ui_setup(struct weekeyboard *wkb) 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); @@ -417,7 +438,7 @@ _wkb_ui_setup(struct weekeyboard *wkb) 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; } @@ -495,6 +516,7 @@ _wkb_setup(struct weekeyboard *wkb) } /* 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); @@ -502,6 +524,7 @@ _wkb_setup(struct weekeyboard *wkb) 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); } @@ -511,13 +534,15 @@ _wkb_free(struct weekeyboard *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); } @@ -553,6 +578,20 @@ err: 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) { @@ -563,13 +602,13 @@ 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"); @@ -582,25 +621,28 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) _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; |