char *preedit_str = NULL;
int cursor_pos = 0;
- isf_wsc_context_preedit_string_get(ctx->wsc_ctx, &preedit_str, &cursor_pos);
+ if (!ctx)
+ return;
+
+ if (ctx->wsc_ctx)
+ isf_wsc_context_preedit_string_get(ctx->wsc_ctx, &preedit_str, &cursor_pos);
+
if (ctx->preedit_str) {
free(ctx->preedit_str);
ctx->preedit_str = NULL;
char *preedit_str = NULL;
int cursor_pos = 0;
- isf_wsc_context_preedit_string_get(ctx->wsc_ctx, &preedit_str, &cursor_pos);
+ if (!ctx)
+ return;
+
+ if (ctx->wsc_ctx)
+ isf_wsc_context_preedit_string_get(ctx->wsc_ctx, &preedit_str, &cursor_pos);
+
if (ctx->preedit_str) {
free(ctx->preedit_str);
ctx->preedit_str = NULL;
uint32_t keycode;
KeycodeRepository::iterator it = _keysym2keycode.find(keysym);
+ if (!ctx || !ctx->im_ctx)
+ return;
+
if(it == _keysym2keycode.end())
return;
_wsc_im_ctx_surrounding_text(void *data, struct wl_input_method_context *im_ctx, const char *text, uint32_t cursor, uint32_t anchor)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
if (wsc->surrounding_text)
free (wsc->surrounding_text);
{
struct weescim *wsc = (weescim*)data;
- isf_wsc_context_reset(wsc->wsc_ctx);
+ if (wsc)
+ isf_wsc_context_reset(wsc->wsc_ctx);
}
static void
{
struct weescim *wsc = (weescim*)data;
- ISF_LOG ("im_context = %p hint = %d purpose = %d", im_ctx, hint, purpose);
+ LOGD ("im_context = %p hint = %d purpose = %d", im_ctx, hint, purpose);
- if (!wsc->context_changed)
+ if (!wsc || !wsc->context_changed)
return;
wsc->content_hint = hint;
if (button != BTN_LEFT)
return;
- wsc_context_send_preedit_string (wsc);
+ if (wsc)
+ wsc_context_send_preedit_string (wsc);
}
static void
_wsc_im_ctx_commit_state(void *data, struct wl_input_method_context *im_ctx, uint32_t serial)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
wsc->serial = serial;
if (wsc->surrounding_text)
- ISF_LOG ("Surrounding text updated: %s", wsc->surrounding_text);
+ LOGD ("Surrounding text updated: %s", wsc->surrounding_text);
if(wsc->language)
wl_input_method_context_language (im_ctx, wsc->serial, wsc->language);
_wsc_im_ctx_preferred_language(void *data, struct wl_input_method_context *im_ctx, const char *language)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
if (language && wsc->language && !strcmp (language, wsc->language))
return;
if (language) {
wsc->language = strdup (language);
- ISF_LOG ("Language changed, new: '%s'", language);
+ LOGD ("Language changed, new: '%s'", language);
}
}
uint32_t num_syms;
const xkb_keysym_t *syms;
- if (!wsc->state)
+ if (!wsc || !wsc->state)
return;
for (i = 0; i < 256; i++) {
struct weescim *wsc = (weescim*)data;
char *map_str;
+ if (!wsc) return;
+
_fini_keysym2keycode(wsc);
if (wsc->state) {
close(fd);
if (!wsc->keymap) {
- fprintf(stderr, "failed to compile keymap\n");
+ LOGW ("failed to compile keymap\n");
return;
}
wsc->state = xkb_state_new(wsc->keymap);
if (!wsc->state) {
- fprintf(stderr, "failed to create XKB state\n");
+ LOGW ("failed to create XKB state\n");
xkb_map_unref(wsc->keymap);
return;
}
wsc->shift_mask =
1 << xkb_map_mod_get_index(wsc->keymap, "Shift");
- fprintf(stderr, "create _keysym2keycode\n");
+ LOGW ("create _keysym2keycode\n");
_init_keysym2keycode(wsc);
}
xkb_keysym_t sym;
enum wl_keyboard_key_state state = (wl_keyboard_key_state)state_w;
- if (!wsc->state)
+ if (!wsc || !wsc->state)
return;
code = key + 8;
struct wl_input_method_context *context = wsc->im_ctx;
xkb_mod_mask_t mask;
- if (!wsc->state)
+ if (!wsc || !wsc->state)
return;
xkb_state_update_mask(wsc->state, mods_depressed,
_wsc_im_activate(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
if (wsc->im_ctx)
wl_input_method_context_destroy (wsc->im_ctx);
_wsc_im_deactivate(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
isf_wsc_context_input_panel_hide (wsc->wsc_ctx);
isf_wsc_context_focus_out (wsc->wsc_ctx);
uint32_t caps)
{
struct weescim *wsc = (weescim*)data;
+ if (!wsc) return;
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
wsc->hw_kbd = true;
{
}
-static void
+static bool
_wsc_setup(struct weescim *wsc)
{
Eina_Inlist *globals;
struct wl_registry *registry;
Ecore_Wl_Global *global;
+ if (!wsc) return false;
+
wsc->xkb_context = xkb_context_new((xkb_context_flags)0);
if (wsc->xkb_context == NULL) {
- fprintf(stderr, "Failed to create XKB context\n");
- return;
+ LOGW ("Failed to create XKB context\n");
+ return false;
}
wsc->key_handler = _wsc_im_key_handler;
wsc->wsc_ctx = isf_wsc_context_new ();
+ if (!wsc->wsc_ctx) return false;
+
wsc->wsc_ctx->ctx = wsc;
get_language(&wsc->language);
if (!(registry = ecore_wl_registry_get()))
- return;
+ return false;
if (!(globals = ecore_wl_globals_get()))
- return;
+ return false;
EINA_INLIST_FOREACH(globals, global) {
if (strcmp (global->interface, "wl_input_method") == 0)
}
if (wsc->im == NULL) {
- fprintf(stderr, "Failed because wl_input_method is null\n");
- return;
+ LOGW ("Failed because wl_input_method is null\n");
+ return false;
}
/* Input method listener */
- ISF_LOG ("Adding wl_input_method listener");
- wl_input_method_add_listener (wsc->im, &wsc_im_listener, wsc);
+ LOGD ("Adding wl_input_method listener");
- wl_seat_add_listener(wsc->seat, &wsc_seat_listener, wsc);
+ if (wsc->im)
+ wl_input_method_add_listener (wsc->im, &wsc_im_listener, wsc);
+ else {
+ LOGW ("Couldn't get wayland input method interface\n");
+ return false;
+ }
+
+ if (wsc->seat)
+ wl_seat_add_listener(wsc->seat, &wsc_seat_listener, wsc);
+ else {
+ LOGW ("Couldn't get wayland seat interface\n");
+ return false;
+ }
isf_wsc_context_add (wsc->wsc_ctx);
+
+ return true;
}
static void
-_wsc_free(struct weescim *wsc)
+_wsc_free (struct weescim *wsc)
{
- _fini_keysym2keycode(wsc);
+ if (!wsc) return;
+
+ _fini_keysym2keycode (wsc);
if (wsc->state) {
- xkb_state_unref(wsc->state);
+ xkb_state_unref (wsc->state);
wsc->state = NULL;
}
if (wsc->keymap) {
- xkb_map_unref(wsc->keymap);
+ xkb_map_unref (wsc->keymap);
wsc->keymap = NULL;
}
- if (wsc->im_ctx)
+ if (wsc->im_ctx) {
wl_input_method_context_destroy (wsc->im_ctx);
+ wsc->im_ctx = NULL;
+ }
+
+ if (wsc->wsc_ctx) {
+ isf_wsc_context_del (wsc->wsc_ctx);
+ wsc->wsc_ctx = NULL;
+ }
- isf_wsc_context_del(wsc->wsc_ctx);
isf_wsc_context_shutdown ();
if (wsc->preedit_str) {
{
sleep(1);
- _wsc_setup(&_wsc);
+ if (!_wsc_setup (&_wsc)) {
+ _wsc_free (&_wsc);
+ return 0;
+ }
ecore_main_loop_begin();
- _wsc_free(&_wsc);
+ _wsc_free (&_wsc);
return 0;
}