2 * Copyright © 2012, 2013 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include <Ecore_IMF.h>
25 #include <Ecore_Wayland.h>
28 #include "wayland_imcontext.h"
29 #include <text-client-protocol.h>
31 int _ecore_imf_wayland_log_dom = -1;
33 static const Ecore_IMF_Context_Info wayland_im_info =
42 static Ecore_IMF_Context_Class wayland_imf_class =
44 wayland_im_context_add, /* add */
45 wayland_im_context_del, /* del */
46 wayland_im_context_client_window_set, /* client_window_set */
47 wayland_im_context_client_canvas_set, /* client_canvas_set */
48 wayland_im_context_show, /* show */
49 wayland_im_context_hide, /* hide */
50 wayland_im_context_preedit_string_get, /* get_preedit_string */
51 wayland_im_context_focus_in, /* focus_in */
52 wayland_im_context_focus_out, /* focus_out */
53 wayland_im_context_reset, /* reset */
54 wayland_im_context_cursor_position_set, /* cursor_position_set */
55 wayland_im_context_use_preedit_set, /* use_preedit_set */
56 wayland_im_context_input_mode_set, /* input_mode_set */
57 wayland_im_context_filter_event, /* filter_event */
58 wayland_im_context_preedit_string_with_attributes_get, /* preedit_string_with_attribute_get */
59 wayland_im_context_prediction_allow_set, /* prediction_allow_set */
60 wayland_im_context_autocapital_type_set, /* autocapital_type_set */
61 NULL, /* control panel show */
62 NULL, /* control panel hide */
63 wayland_im_context_input_panel_layout_set, /* input_panel_layout_set */
64 wayland_im_context_input_panel_layout_get, /* input_panel_layout_get */
65 wayland_im_context_input_panel_language_set,/* input_panel_language_set, */
66 NULL, /* input_panel_language_get, */
67 wayland_im_context_cursor_location_set, /* cursor_location_set */
68 wayland_im_context_input_panel_imdata_set, /* input_panel_imdata_set */
69 wayland_im_context_input_panel_imdata_get, /* input_panel_imdata_get */
70 wayland_im_context_input_panel_return_key_type_set, /* input_panel_return_key_type_set */
71 wayland_im_context_input_panel_return_key_disabled_set, /* input_panel_return_key_disabled_set */
72 NULL, /* input_panel_caps_lock_mode_set */
73 wayland_im_context_input_panel_geometry_get, /* input_panel_geometry_get */
74 wayland_im_context_input_panel_state_get, /* input_panel_state_get */
75 NULL, /* input_panel_event_callback_add */
76 NULL, /* input_panel_event_callback_del */
77 wayland_im_context_input_panel_language_locale_get, /* input_panel_language_locale_get */
78 NULL, /* candidate_window_geometry_get */
79 wayland_im_context_input_hint_set, /* input_hint_set */
80 wayland_im_context_bidi_direction_set /* bidi_direction_set */
83 static struct wl_text_input_manager *text_input_manager = NULL;
85 static Ecore_IMF_Context *
91 static Ecore_IMF_Context *
94 Ecore_IMF_Context *ctx = NULL;
95 WaylandIMContext *ctxd = NULL;
97 if (!text_input_manager) {
98 Ecore_Wl_Global *global;
99 struct wl_registry *registry;
100 Eina_Inlist *globals;
102 if (!(registry = ecore_wl_registry_get()))
105 if (!(globals = ecore_wl_globals_get()))
108 EINA_INLIST_FOREACH(globals, global)
110 if (!strcmp(global->interface, "wl_text_input_manager")) {
112 wl_registry_bind(registry, global->id,
113 &wl_text_input_manager_interface, 1);
114 EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom,
115 "bound wl_text_input_manager interface");
120 if (!text_input_manager)
124 ctxd = wayland_im_context_new(text_input_manager);
125 if (!ctxd) return NULL;
127 ctx = ecore_imf_context_new(&wayland_imf_class);
133 ecore_imf_context_data_set(ctx, ctxd);
143 _ecore_imf_wayland_log_dom =
144 eina_log_domain_register("ecore_imf_wayland", EINA_COLOR_YELLOW);
146 if (!getenv("WAYLAND_DISPLAY")) return EINA_FALSE;
147 if ((s = getenv("ELM_DISPLAY"))) {
148 if (strcmp(s, "wl")) return EINA_FALSE;
151 if (!ecore_wl_init(NULL))
154 ecore_imf_module_register(&wayland_im_info, im_module_create,
157 // TIZEN_ONLY(20150708): Support back key
158 register_key_handler();
160 EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "im module initalized");
166 im_module_shutdown(void)
168 // TIZEN_ONLY(20150708): Support back key
169 unregister_key_handler();
171 EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "im module shutdown");
175 EINA_MODULE_INIT(im_module_init);
176 EINA_MODULE_SHUTDOWN(im_module_shutdown);