/*
* Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Jaguar Landrover
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wkb-log.h"
#include "wkb-ibus.h"
+#include "wkb-ibus-config.h"
#include "input-method-client-protocol.h"
#include "text-client-protocol.h"
char *surrounding_text;
char *preedit_str;
char *language;
+ char *theme;
uint32_t text_direction;
uint32_t preedit_style;
Eina_Bool context_changed;
};
+static Eina_Bool _wkb_ui_setup(struct weekeyboard *wkb);
+
static void
-_cb_wkb_delete_request(Ecore_Evas *ee EINA_UNUSED)
+_cb_wkb_delete_request(Ecore_Evas *ee)
{
if (!wkb_ibus_shutdown())
ecore_main_loop_quit();
}
static void
-_cb_wkb_on_key_down(void *data, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source)
+_cb_wkb_on_key_down(void *data, Evas_Object *obj, const char *emission, const char *source)
{
struct weekeyboard *wkb = data;
char *src;
case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
case WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER:
{
- edje_object_signal_emit(wkb->edje_obj, "show,numeric", "");
+ if (wkb->edje_obj)
+ edje_object_signal_emit(wkb->edje_obj, "show,numeric", "");
break;
}
default:
{
- edje_object_signal_emit(wkb->edje_obj, "show,alphanumeric", "");
+ if (wkb->edje_obj)
+ edje_object_signal_emit(wkb->edje_obj, "show,alphanumeric", "");
break;
}
}
DBG("Activate");
+ // check if the UI is valid and draw it if not
+ _wkb_ui_setup(wkb);
+
if (wkb->im_ctx)
wl_input_method_context_destroy(wkb->im_ctx);
wkb->im_ctx = NULL;
}
- evas_object_hide(wkb->edje_obj);
+ if (wkb->edje_obj)
+ evas_object_hide(wkb->edje_obj);
}
static const struct wl_input_method_listener wkb_im_listener = {
_wkb_ui_setup(struct weekeyboard *wkb)
{
char path[PATH_MAX];
- Evas *evas;
- Evas_Coord w, h;
+ int w = 1080, h;
char *ignore_keys;
+ const char *theme;
- ecore_evas_alpha_set(wkb->ee, EINA_TRUE);
- ecore_evas_title_set(wkb->ee, "Weekeyboard");
+ /* First run */
+ if (!wkb->edje_obj)
+ {
+ Evas *evas;
+ ecore_evas_alpha_set(wkb->ee, EINA_TRUE);
+ ecore_evas_title_set(wkb->ee, "Weekeyboard");
- evas = ecore_evas_get(wkb->ee);
- wkb->edje_obj = edje_object_add(evas);
- /*ecore_evas_object_associate(wkb->ee, edje_obj, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);*/
+ evas = ecore_evas_get(wkb->ee);
+ wkb->edje_obj = edje_object_add(evas);
+ }
- /* Check which theme we should use according to the screen width */
- ecore_wl_screen_size_get(&w, &h);
- if (w >= 720)
- w = 720;
- else
- w = 600;
+ /* Bail out if theme did not change */
+ if (!(theme = wkb_ibus_config_get_value_string("weekeyboard", "theme")))
+ theme = "default";
+
+ if (wkb->theme && strcmp(theme, wkb->theme) == 0)
+ return EINA_TRUE;
+
+ free(wkb->theme);
+ wkb->theme = strdup(theme);
+
+ if (strcmp(wkb->theme, "default") == 0)
+ {
+ /* Check which theme we should use according to the screen width */
+ ecore_wl_screen_size_get(&w, &h);
+ DBG("Screen size: w=%d, h=%d", w, h);
+ if (w >= 720)
+ w = 720;
+ else
+ w = 600;
- sprintf(path, PKGDATADIR"/default_%d.edj", w);
- DBG("Loading edje file: '%s'", path);
+ DBG("Using default_%d theme", w);
+ }
+
+ sprintf(path, PKGDATADIR"/%s_%d.edj", wkb->theme, w);
+ INF("Loading edje file: '%s'", path);
if (!edje_object_file_set(wkb->edje_obj, path, "main"))
{
}
edje_object_size_min_get(wkb->edje_obj, &w, &h);
+ DBG("edje_object_size_min_get - w: %d h: %d", w, h);
if (w == 0 || h == 0)
{
edje_object_size_min_restricted_calc(wkb->edje_obj, &w, &h, w, h);
+ DBG("edje_object_size_min_restricted_calc - w: %d h: %d", w, h);
if (w == 0 || h == 0)
- edje_object_parts_extends_calc(wkb->edje_obj, NULL, NULL, &w, &h);
+ {
+ edje_object_parts_extends_calc(wkb->edje_obj, NULL, NULL, &w, &h);
+ DBG("edje_object_parts_extends_calc - w: %d h: %d", w, h);
+ }
}
ecore_evas_move_resize(wkb->ee, 0, 0, w, h);
evas_object_size_hint_max_set(wkb->edje_obj, w, h);
edje_object_signal_callback_add(wkb->edje_obj, "key_down", "*", _cb_wkb_on_key_down, wkb);
- ecore_evas_callback_delete_request_set(wkb->ee, _cb_wkb_delete_request);
/*
* The keyboard surface is bigger than it appears so that we can show the
Eina_Inlist *globals;
struct wl_registry *registry;
Ecore_Wl_Global *global;
-
struct wl_input_panel_surface *ips;
globals = ecore_wl_globals_get();
registry = ecore_wl_registry_get();
EINA_INLIST_FOREACH(globals, global)
{
+ DBG("interface: <%s>", global->interface);
if (strcmp(global->interface, "wl_input_panel") == 0)
+ {
wkb->ip = wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
+ DBG("binding wl_input_panel");
+ }
else if (strcmp(global->interface, "wl_input_method") == 0)
+ {
wkb->im = wl_registry_bind(registry, global->id, &wl_input_method_interface, 1);
+ DBG("binding wl_input_method, id = %d", global->id);
+ }
+
else if (strcmp(global->interface, "wl_output") == 0)
+ {
wkb->output = wl_registry_bind(registry, global->id, &wl_output_interface, 1);
+ DBG("binding wl_output");
+ }
}
+ /* invalidate the UI so it is drawn when invoked */
+ wkb->theme = NULL;
+
/* Set input panel surface */
DBG("Setting up input panel");
wkb->win = ecore_evas_wayland_window_get(wkb->ee);
/* Input method listener */
DBG("Adding wl_input_method listener");
wl_input_method_add_listener(wkb->im, &wkb_im_listener, wkb);
+
+ wkb->edje_obj = NULL;
}
static void
free(wkb->preedit_str);
free(wkb->surrounding_text);
+ free(wkb->theme);
}
static Eina_Bool
return ECORE_CALLBACK_DONE;
}
+ DBG("wkb_ibus_is_connected() : %s", wkb_ibus_is_connected() ? "TRUE" : "FALSE");
return !wkb_ibus_is_connected();
}
int
-main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
+main(int argc, char **argv)
{
struct weekeyboard wkb = {0};
int ret = EXIT_FAILURE;
_wkb_setup(&wkb);
wkb_ibus_init();
+ wkb_ibus_connect();
- if (!_wkb_ui_setup(&wkb))
- goto end;
+ ecore_evas_callback_delete_request_set(wkb.ee, _cb_wkb_delete_request);
- wkb_ibus_connect();
ecore_timer_add(1, _wkb_check_ibus_connection, NULL);
ecore_main_loop_begin();
ret = EXIT_SUCCESS;
-end:
_wkb_free(&wkb);
ecore_evas_free(wkb.ee);