static const unsigned int IBUS_RELEASE_MASK = 1 << 30;
+struct wkb_ibus_key
+{
+ unsigned int code;
+ unsigned int sym;
+ unsigned int state;
+};
struct wkb_ibus_input_context
{
}
static unsigned int
-_key_sym_to_key_code(unsigned int key_sym)
+_key_sym_to_key_code(unsigned int *key_sym)
{
#define CASE_SYM(_sym, _code) \
case XKB_KEY_ ##_sym: \
case XKB_KEY_ ##_low: \
CASE_SYM(_up, _up)
- switch(key_sym)
+ switch(*key_sym)
{
CASE_NUMBER(0);
CASE_NUMBER(1);
#undef CASE_LETTER
}
+static unsigned int
+_key_to_key_code(const char *key, unsigned int *key_sym)
+{
+ if (strcmp(key, "shift") == 0)
+ {
+ *key_sym = XKB_KEY_Shift_L;
+ return KEY_LEFTSHIFT;
+ }
+ else if (strcmp(key, "backspace") == 0)
+ {
+ *key_sym = XKB_KEY_BackSpace;
+ return KEY_BACKSPACE;
+ }
+ else if (strcmp(key, "enter") == 0)
+ {
+ *key_sym = XKB_KEY_Return;
+ return KEY_ENTER;
+ }
+ else if (strcmp(key, "space") == 0)
+ {
+ *key_sym = XKB_KEY_space;
+ return KEY_SPACE;
+ }
+
+ *key_sym = *key;
+ return _key_sym_to_key_code(*key_sym);
+}
+
void
wkb_ibus_input_context_process_key_event(const char *key)
{
+ static Eina_Bool key_shift = 0;
static unsigned int key_code = KEY_RESERVED;
unsigned int key_sym = XKB_KEY_NoSymbol;
if (!wkb_ibus || !wkb_ibus->input_ctx)
return;
- key_sym = *key;
- key_code = _key_sym_to_key_code(key_sym) + 8;
+ key_code = _key_to_key_code(key, &key_sym);
+
+ if (key_code == KEY_RESERVED)
+ {
+ ERR("Unexpected key '%s'", key);
+ return;
+ }
+
+ key_code += 8;
if (!wkb_ibus->input_ctx->ibus_ctx)
{
INF("Process key event with '%s'", key);
+ /* XXX H4X0R */
+ if (key_code-8 == KEY_LEFTSHIFT)
+ {
+ key_shift = !key_shift;
+ if (!key_shift)
+ goto release;
+ }
+
eldbus_proxy_call(wkb_ibus->input_ctx->ibus_ctx, "ProcessKeyEvent",
_ibus_input_ctx_key_press, &key_code,
-1, "uuu", key_sym, key_code, 0);
+
+
+ /* XXX H4X0R */
+ if (key_code-8 == KEY_LEFTSHIFT)
+ return;
+
+release:
eldbus_proxy_call(wkb_ibus->input_ctx->ibus_ctx, "ProcessKeyEvent",
_ibus_input_ctx_key_release, &key_code,
-1, "uuu", key_sym, key_code, IBUS_RELEASE_MASK);
}
wkb_ibus_input_context_process_key_event(key);
-#if 0
- else if (strcmp(key, "backspace") == 0)
- {
- if (strlen(wkb->preedit_str) == 0)
- {
- wl_input_method_context_delete_surrounding_text(wkb->im_ctx, -1, 1);
- wl_input_method_context_commit_string(wkb->im_ctx, wkb->serial, "");
- }
- else
- {
- wkb->preedit_str[strlen(wkb->preedit_str) - 1] = '\0';
- _wkb_send_preedit_str(wkb, -1);
- }
- goto end;
- }
- else if (strcmp(key, "enter") == 0)
- {
- _wkb_commit_preedit_str(wkb);
- wl_input_method_context_keysym(wkb->im_ctx, wkb->serial, 0,
- XKB_KEY_Return, WL_KEYBOARD_KEY_STATE_PRESSED,
- 0);
- goto end;
- }
- else if (strcmp(key, "space") == 0)
- {
- key = " ";
- }
-
- DBG("Key pressed: '%s'", key);
-
- _wkb_update_preedit_str(wkb, key);
-#endif
end:
free(src);
}