Exemplo n.º 1
0
static void
_ibus_input_ctx_key_release(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
{
   struct wkb_ibus_key *key = (struct wkb_ibus_key *) data;
   Eina_Bool ret = EINA_FALSE;

   if (msg)
     {
        _check_message_errors(msg);

        if (!eldbus_message_arguments_get(msg, "b", &ret))
           ERR("Error reading message arguments");
     }

   if (!ret)
     {
        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);

        if (key->modifiers)
           wl_input_method_context_modifiers(wkb_ibus->input_ctx->wl_ctx,
                                             wkb_ibus->input_ctx->serial,
                                             0, 0, 0, 0);

     }
}
Exemplo n.º 2
0
static void
_wkb_name_acquired_cb(void *data, const Eldbus_Message *msg)
{
   const char *name, *path;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "s", &name))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("NameAcquired: '%s'", name);

   if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0)
     {
        wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn);
        INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail");
     }
   else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0)
     {
        path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get());
        wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path);
        eina_stringshare_del(path);
        INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail");
     }
   else
     {
        WRN("Unexpected name %s", name);
     }
}
Exemplo n.º 3
0
static void
_ibus_input_ctx_create(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
{
   const char *obj_path;
   Eldbus_Object *obj;
   Eldbus_Proxy *ibus_ctx;
   unsigned int capabilities = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_SURROUNDING_TEXT;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "o", &obj_path))
     {
        ERR("Error reading message arguments");
        goto end;
     }

   DBG("Got new IBus input context: '%s'", obj_path);

   obj = eldbus_object_get(wkb_ibus->conn, IBUS_SERVICE_IBUS, obj_path);
   wkb_ibus->input_ctx->ibus_ctx = ibus_ctx = eldbus_proxy_get(obj, IBUS_INTERFACE_INPUT_CONTEXT);

   eldbus_proxy_signal_handler_add(ibus_ctx, "CommitText", _ibus_input_ctx_commit_text, NULL);
   eldbus_proxy_signal_handler_add(ibus_ctx, "ForwardKeyEvent", _ibus_input_ctx_forward_key_event, NULL);
   eldbus_proxy_signal_handler_add(ibus_ctx, "UpdatePreeditText", _ibus_input_ctx_update_preedit_text, NULL);
   eldbus_proxy_signal_handler_add(ibus_ctx, "ShowPreeditText", _ibus_input_ctx_show_preedit_text, NULL);
   eldbus_proxy_signal_handler_add(ibus_ctx, "HidePreeditText", _ibus_input_ctx_hide_preedit_text, NULL);

   eldbus_proxy_call(ibus_ctx, "FocusIn", NULL, NULL, -1, "");
   eldbus_proxy_call(ibus_ctx, "SetCapabilities", NULL, NULL, -1, "u", capabilities);

end:
   wkb_ibus->input_ctx->pending = NULL;
}
Exemplo n.º 4
0
static void
_wkb_config_value_changed_cb(void *data, const Eldbus_Message *msg)
{
   const char *section, *name;
   Eldbus_Message_Iter *value;
   struct wkb_config_key *key;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "ssv", &section, &name, &value))
     {
        ERR("Error reading message arguments");
        return;
     }

   INF("ValueChanged: section: '%s', name: '%s'", section, name);

   /* Emit general CONFIG_VALUE_CHANGED event */
   if (!(key = wkb_ibus_config_get_key(section, name)))
     {
        ERR("Config key '%s' or section '%s' not found", section, name);
        return;
     }

   ecore_event_add(WKB_IBUS_CONFIG_VALUE_CHANGED, key, _wkb_config_value_changed_end_cb, NULL);

   /* If theme changed, emit specific THEME_CHANGED event */
   if (strncmp(section, "weekeyboard", strlen("weekeyboard")) == 0 && strncmp(name, "theme", strlen("theme")) == 0)
      _wkb_config_theme_changed(key);
}
Exemplo n.º 5
0
static void
_ibus_input_ctx_show_preedit_text(void *data, const Eldbus_Message *msg)
{
   _check_message_errors(msg);
   wl_input_method_context_preedit_cursor(wkb_ibus->input_ctx->wl_ctx,
                                          wkb_ibus->input_ctx->cursor);
   _set_preedit_text(wkb_ibus->input_ctx->preedit);
}
Exemplo n.º 6
0
static void
_wkb_config_value_changed_cb(void *data, const Eldbus_Message *msg)
{
   const char *section, *name;
   Eldbus_Message_Iter *value;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "ssv", &section, &name, &value))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("section: '%s', name: '%s', value: '%p", section, name, value);
}
Exemplo n.º 7
0
static void
_wkb_name_lost_cb(void *data, const Eldbus_Message *msg)
{
   const char *name;

   DBG("NameLost");

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "s", &name))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("Name = %s", name);
}
Exemplo n.º 8
0
static void
_ibus_input_ctx_forward_key_event(void *data, const Eldbus_Message *msg)
{
   unsigned int val, code, modifiers, state = WL_KEYBOARD_KEY_STATE_PRESSED;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "uuu", &val, &code, &modifiers))
     {
        ERR("Error reading message arguments");
        return;
     }

   if (modifiers & IBUS_RELEASE_MASK)
      state = WL_KEYBOARD_KEY_STATE_RELEASED;

   wl_input_method_context_keysym(wkb_ibus->input_ctx->wl_ctx,
                                  wkb_ibus->input_ctx->serial,
                                  0, val, state, modifiers);
}
Exemplo n.º 9
0
static void
_ibus_input_ctx_commit_text(void *data, const Eldbus_Message *msg)
{
   Eldbus_Message_Iter *iter = NULL;
   struct wkb_ibus_text *txt;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "v", &iter))
     {
        ERR("Error reading message arguments");
        return;
     }

   txt = wkb_ibus_text_from_message_iter(iter);
   DBG("Commit text: '%s'", txt->text);
   wl_input_method_context_commit_string(wkb_ibus->input_ctx->wl_ctx,
                                         wkb_ibus->input_ctx->serial,
                                         txt->text);
   wkb_ibus_text_free(txt);
}
Exemplo n.º 10
0
static void
_wkb_name_acquired_cb(void *data, const Eldbus_Message *msg)
{
   const char *name, *path;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "s", &name))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("NameAcquired: '%s'", name);

   if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0)
     {
        wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn);
        INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail");
     }
   else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0)
     {
        path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get());
        wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path);
        eina_stringshare_del(path);
        INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail");
        if (wkb_ibus->config)
          {
             Eldbus_Object *obj = eldbus_object_get(wkb_ibus->conn, IBUS_SERVICE_CONFIG, IBUS_PATH_CONFIG);
             Eldbus_Proxy *config = eldbus_proxy_get(obj, IBUS_INTERFACE_CONFIG);
             eldbus_proxy_signal_handler_add(config, "ValueChanged", _wkb_config_value_changed_cb, wkb_ibus);
          }
     }
   else
     {
        INF("Unexpected name %s, ignoring", name);
     }
}
Exemplo n.º 11
0
static void
_ibus_input_ctx_update_preedit_text(void *data, const Eldbus_Message *msg)
{
   Eldbus_Message_Iter *iter = NULL;
   unsigned int cursor;
   struct wkb_ibus_text *txt;
   Eina_Bool visible;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "vub", &iter, &cursor, &visible))
     {
        ERR("Error reading message arguments");
        return;
     }

   if (wkb_ibus->input_ctx->preedit)
     {
        free(wkb_ibus->input_ctx->preedit);
        wkb_ibus->input_ctx->preedit = NULL;
     }

   txt = wkb_ibus_text_from_message_iter(iter);
   DBG("Preedit text: '%s', Cursor: '%d'", txt->text, cursor);
   wkb_ibus->input_ctx->preedit = strdup(txt->text);
   wkb_ibus->input_ctx->cursor = cursor;

   if (!visible)
     {
        _set_preedit_text("");
        return;
     }

   wl_input_method_context_preedit_cursor(wkb_ibus->input_ctx->wl_ctx, cursor);
   _set_preedit_text(wkb_ibus->input_ctx->preedit);
}
Exemplo n.º 12
0
static void
_ibus_input_ctx_hide_preedit_text(void *data, const Eldbus_Message *msg)
{
   _check_message_errors(msg);
   _set_preedit_text("");
}