summaryrefslogtreecommitdiff
path: root/src/modules/ecore/immodules/xim/ecore_imf_xim.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-08 13:49:18 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-08 13:49:18 +0000
commit457f91573a3bed0acd1507e04df8974836226ffc (patch)
treeb36351fc643336d25457fa8584a929061c3e5920 /src/modules/ecore/immodules/xim/ecore_imf_xim.c
parent26fa0cc64c82402f2846be28a9fdf7a75c7bc21d (diff)
efl/ecore_imf_xim: do not #ifdef in a module that is already conditionally compiled.
SVN revision: 82413
Diffstat (limited to '')
-rw-r--r--src/modules/ecore/immodules/xim/ecore_imf_xim.c137
1 files changed, 31 insertions, 106 deletions
diff --git a/src/modules/ecore/immodules/xim/ecore_imf_xim.c b/src/modules/ecore/immodules/xim/ecore_imf_xim.c
index 64fc46c122..ac6ecb0853 100644
--- a/src/modules/ecore/immodules/xim/ecore_imf_xim.c
+++ b/src/modules/ecore/immodules/xim/ecore_imf_xim.c
@@ -17,11 +17,8 @@
17#include <assert.h> 17#include <assert.h>
18 18
19#define CLAMP(x, low, high) (x > high) ? high : (x < low) ? low : x 19#define CLAMP(x, low, high) (x > high) ? high : (x < low) ? low : x
20#define _(x) x
21 20
22#ifdef ENABLE_XIM
23static Eina_List *open_ims = NULL; 21static Eina_List *open_ims = NULL;
24#endif
25 22
26#define FEEDBACK_MASK (XIMReverse | XIMUnderline | XIMHighlight) 23#define FEEDBACK_MASK (XIMReverse | XIMUnderline | XIMHighlight)
27 24
@@ -67,10 +64,9 @@ struct _Ecore_IMF_Context_Data
67}; 64};
68 65
69/* prototype */ 66/* prototype */
70Ecore_IMF_Context_Data *imf_context_data_new(); 67Ecore_IMF_Context_Data *imf_context_data_new(void);
71void imf_context_data_destroy(Ecore_IMF_Context_Data *imf_context_data); 68void imf_context_data_destroy(Ecore_IMF_Context_Data *imf_context_data);
72 69
73#ifdef ENABLE_XIM
74static void add_feedback_attr(Eina_List **attrs, 70static void add_feedback_attr(Eina_List **attrs,
75 const char *str, 71 const char *str,
76 XIMFeedback feedback, 72 XIMFeedback feedback,
@@ -110,9 +106,7 @@ static void setup_im(XIM_Im_Info *info);
110static void xim_destroy_callback(XIM xim, 106static void xim_destroy_callback(XIM xim,
111 XPointer client_data, 107 XPointer client_data,
112 XPointer call_data); 108 XPointer call_data);
113#endif
114 109
115#ifdef ENABLE_XIM
116static unsigned int 110static unsigned int
117utf8_offset_to_index(const char *str, int offset) 111utf8_offset_to_index(const char *str, int offset)
118{ 112{
@@ -126,15 +120,13 @@ utf8_offset_to_index(const char *str, int offset)
126 return idx; 120 return idx;
127} 121}
128 122
129#endif
130
131static void 123static void
132_ecore_imf_context_xim_add(Ecore_IMF_Context *ctx) 124_ecore_imf_context_xim_add(Ecore_IMF_Context *ctx)
133{ 125{
134 EINA_LOG_DBG("in");
135#ifdef ENABLE_XIM
136 Ecore_IMF_Context_Data *imf_context_data = NULL; 126 Ecore_IMF_Context_Data *imf_context_data = NULL;
137 127
128 EINA_LOG_DBG("in");
129
138 imf_context_data = imf_context_data_new(); 130 imf_context_data = imf_context_data_new();
139 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 131 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
140 132
@@ -144,17 +136,14 @@ _ecore_imf_context_xim_add(Ecore_IMF_Context *ctx)
144 imf_context_data->in_toplevel = EINA_FALSE; 136 imf_context_data->in_toplevel = EINA_FALSE;
145 137
146 ecore_imf_context_data_set(ctx, imf_context_data); 138 ecore_imf_context_data_set(ctx, imf_context_data);
147#else
148 (void)ctx;
149#endif
150} 139}
151 140
152static void 141static void
153_ecore_imf_context_xim_del(Ecore_IMF_Context *ctx) 142_ecore_imf_context_xim_del(Ecore_IMF_Context *ctx)
154{ 143{
155 EINA_LOG_DBG("in");
156#ifdef ENABLE_XIM
157 Ecore_IMF_Context_Data *imf_context_data; 144 Ecore_IMF_Context_Data *imf_context_data;
145
146 EINA_LOG_DBG("in");
158 imf_context_data = ecore_imf_context_data_get(ctx); 147 imf_context_data = ecore_imf_context_data_get(ctx);
159 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 148 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
160 149
@@ -184,9 +173,6 @@ _ecore_imf_context_xim_del(Ecore_IMF_Context *ctx)
184 set_ic_client_window(ctx, 0); 173 set_ic_client_window(ctx, 0);
185 174
186 imf_context_data_destroy(imf_context_data); 175 imf_context_data_destroy(imf_context_data);
187#else
188 (void)ctx;
189#endif
190} 176}
191 177
192static void 178static void
@@ -194,12 +180,7 @@ _ecore_imf_context_xim_client_window_set(Ecore_IMF_Context *ctx,
194 void *window) 180 void *window)
195{ 181{
196 EINA_LOG_DBG("in"); 182 EINA_LOG_DBG("in");
197#ifdef ENABLE_XIM
198 set_ic_client_window(ctx, (Ecore_X_Window)((Ecore_Window)window)); 183 set_ic_client_window(ctx, (Ecore_X_Window)((Ecore_Window)window));
199#else
200 (void)ctx;
201 (void)window;
202#endif
203} 184}
204 185
205static void 186static void
@@ -207,11 +188,12 @@ _ecore_imf_context_xim_preedit_string_get(Ecore_IMF_Context *ctx,
207 char **str, 188 char **str,
208 int *cursor_pos) 189 int *cursor_pos)
209{ 190{
210 EINA_LOG_DBG("in");
211#ifdef ENABLE_XIM
212 Ecore_IMF_Context_Data *imf_context_data; 191 Ecore_IMF_Context_Data *imf_context_data;
213 char *utf8; 192 char *utf8;
214 int len; 193 int len;
194
195 EINA_LOG_DBG("in");
196
215 imf_context_data = ecore_imf_context_data_get(ctx); 197 imf_context_data = ecore_imf_context_data_get(ctx);
216 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 198 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
217 199
@@ -234,13 +216,6 @@ _ecore_imf_context_xim_preedit_string_get(Ecore_IMF_Context *ctx,
234 216
235 if (cursor_pos) 217 if (cursor_pos)
236 *cursor_pos = imf_context_data->preedit_cursor; 218 *cursor_pos = imf_context_data->preedit_cursor;
237#else
238 (void)ctx;
239 if (str)
240 *str = NULL;
241 if (cursor_pos)
242 *cursor_pos = 0;
243#endif
244} 219}
245 220
246static void 221static void
@@ -249,11 +224,10 @@ _ecore_imf_context_xim_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx
249 Eina_List **attrs, 224 Eina_List **attrs,
250 int *cursor_pos) 225 int *cursor_pos)
251{ 226{
252 EINA_LOG_DBG("in");
253
254#ifdef ENABLE_XIM
255 Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx); 227 Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx);
256 228
229 EINA_LOG_DBG("in");
230
257 _ecore_imf_context_xim_preedit_string_get(ctx, str, cursor_pos); 231 _ecore_imf_context_xim_preedit_string_get(ctx, str, cursor_pos);
258 232
259 if (!attrs) return; 233 if (!attrs) return;
@@ -279,24 +253,16 @@ _ecore_imf_context_xim_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx
279 253
280 if (start >= 0) 254 if (start >= 0)
281 add_feedback_attr(attrs, *str, last_feedback, start, i); 255 add_feedback_attr(attrs, *str, last_feedback, start, i);
282#else
283 (void)ctx;
284 if (str)
285 *str = NULL;
286 if (attrs)
287 *attrs = NULL;
288 if (cursor_pos)
289 *cursor_pos = 0;
290#endif
291} 256}
292 257
293static void 258static void
294_ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx) 259_ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx)
295{ 260{
296 EINA_LOG_DBG("in");
297#ifdef ENABLE_XIM
298 XIC ic; 261 XIC ic;
299 Ecore_IMF_Context_Data *imf_context_data; 262 Ecore_IMF_Context_Data *imf_context_data;
263
264 EINA_LOG_DBG("in");
265
300 imf_context_data = ecore_imf_context_data_get(ctx); 266 imf_context_data = ecore_imf_context_data_get(ctx);
301 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 267 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
302 268
@@ -319,18 +285,16 @@ _ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx)
319 285
320 XSetICFocus(ic); 286 XSetICFocus(ic);
321 } 287 }
322#else
323 (void)ctx;
324#endif
325} 288}
326 289
327static void 290static void
328_ecore_imf_context_xim_focus_out(Ecore_IMF_Context *ctx) 291_ecore_imf_context_xim_focus_out(Ecore_IMF_Context *ctx)
329{ 292{
330 EINA_LOG_DBG("%s in", __FUNCTION__);
331#ifdef ENABLE_XIM
332 XIC ic; 293 XIC ic;
333 Ecore_IMF_Context_Data *imf_context_data; 294 Ecore_IMF_Context_Data *imf_context_data;
295
296 EINA_LOG_DBG("%s in", __FUNCTION__);
297
334 imf_context_data = ecore_imf_context_data_get(ctx); 298 imf_context_data = ecore_imf_context_data_get(ctx);
335 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 299 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
336 300
@@ -344,20 +308,17 @@ _ecore_imf_context_xim_focus_out(Ecore_IMF_Context *ctx)
344 if (ecore_imf_context_input_panel_enabled_get(ctx)) 308 if (ecore_imf_context_input_panel_enabled_get(ctx))
345 ecore_imf_context_input_panel_hide(ctx); 309 ecore_imf_context_input_panel_hide(ctx);
346 } 310 }
347#else
348 (void)ctx;
349#endif
350} 311}
351 312
352static void 313static void
353_ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx) 314_ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx)
354{ 315{
355 EINA_LOG_DBG("%s in", __FUNCTION__);
356#ifdef ENABLE_XIM
357 XIC ic; 316 XIC ic;
358 Ecore_IMF_Context_Data *imf_context_data; 317 Ecore_IMF_Context_Data *imf_context_data;
359 char *result; 318 char *result;
360 319
320 EINA_LOG_DBG("%s in", __FUNCTION__);
321
361 /* restore conversion state after resetting ic later */ 322 /* restore conversion state after resetting ic later */
362 XIMPreeditState preedit_state = XIMPreeditUnKnown; 323 XIMPreeditState preedit_state = XIMPreeditUnKnown;
363 XVaNestedList preedit_attr; 324 XVaNestedList preedit_attr;
@@ -423,18 +384,16 @@ _ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx)
423 } 384 }
424 385
425 XFree(result); 386 XFree(result);
426#else
427 (void)ctx;
428#endif
429} 387}
430 388
431static void 389static void
432_ecore_imf_context_xim_use_preedit_set(Ecore_IMF_Context *ctx, 390_ecore_imf_context_xim_use_preedit_set(Ecore_IMF_Context *ctx,
433 Eina_Bool use_preedit) 391 Eina_Bool use_preedit)
434{ 392{
435 EINA_LOG_DBG("in");
436#ifdef ENABLE_XIM
437 Ecore_IMF_Context_Data *imf_context_data; 393 Ecore_IMF_Context_Data *imf_context_data;
394
395 EINA_LOG_DBG("in");
396
438 imf_context_data = ecore_imf_context_data_get(ctx); 397 imf_context_data = ecore_imf_context_data_get(ctx);
439 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 398 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
440 399
@@ -445,13 +404,8 @@ _ecore_imf_context_xim_use_preedit_set(Ecore_IMF_Context *ctx,
445 imf_context_data->use_preedit = use_preedit; 404 imf_context_data->use_preedit = use_preedit;
446 reinitialize_ic(ctx); 405 reinitialize_ic(ctx);
447 } 406 }
448#else
449 (void)ctx;
450 (void)use_preedit;
451#endif
452} 407}
453 408
454#ifdef ENABLE_XIM
455static void 409static void
456add_feedback_attr(Eina_List **attrs, 410add_feedback_attr(Eina_List **attrs,
457 const char *str, 411 const char *str,
@@ -482,20 +436,17 @@ add_feedback_attr(Eina_List **attrs,
482 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3; 436 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3;
483} 437}
484 438
485#endif
486
487static void 439static void
488_ecore_imf_context_xim_cursor_location_set(Ecore_IMF_Context *ctx, 440_ecore_imf_context_xim_cursor_location_set(Ecore_IMF_Context *ctx,
489 int x, int y, int w, int h) 441 int x, int y, int w, int h)
490{ 442{
491 EINA_LOG_DBG("%s in", __FUNCTION__);
492
493#ifdef ENABLE_XIM
494 Ecore_IMF_Context_Data *imf_context_data; 443 Ecore_IMF_Context_Data *imf_context_data;
495 XIC ic; 444 XIC ic;
496 XVaNestedList preedit_attr; 445 XVaNestedList preedit_attr;
497 XPoint spot; 446 XPoint spot;
498 447
448 EINA_LOG_DBG("%s in", __FUNCTION__);
449
499 imf_context_data = ecore_imf_context_data_get(ctx); 450 imf_context_data = ecore_imf_context_data_get(ctx);
500 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 451 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
501 ic = imf_context_data->ic; 452 ic = imf_context_data->ic;
@@ -513,50 +464,37 @@ _ecore_imf_context_xim_cursor_location_set(Ecore_IMF_Context *ctx,
513 NULL); 464 NULL);
514 465
515 XFree(preedit_attr); 466 XFree(preedit_attr);
516#else
517 (void)ctx;
518 (void)x;
519 (void)y;
520 (void)h;
521#endif
522 (void)(w); // yes w is unused, but only a bi-product of the algorithm 467 (void)(w); // yes w is unused, but only a bi-product of the algorithm
523} 468}
524 469
525static void 470static void
526_ecore_imf_context_xim_input_panel_show(Ecore_IMF_Context *ctx) 471_ecore_imf_context_xim_input_panel_show(Ecore_IMF_Context *ctx)
527{ 472{
473 Ecore_IMF_Context_Data *imf_context_data;
474
528 EINA_LOG_DBG("%s in", __FUNCTION__); 475 EINA_LOG_DBG("%s in", __FUNCTION__);
529 476
530#ifdef ENABLE_XIM
531 Ecore_IMF_Context_Data *imf_context_data;
532 imf_context_data = ecore_imf_context_data_get(ctx); 477 imf_context_data = ecore_imf_context_data_get(ctx);
533 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 478 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
534 479
535 ecore_x_e_virtual_keyboard_state_set 480 ecore_x_e_virtual_keyboard_state_set
536 (imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_ON); 481 (imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_ON);
537#else
538 (void)ctx;
539#endif
540} 482}
541 483
542static void 484static void
543_ecore_imf_context_xim_input_panel_hide(Ecore_IMF_Context *ctx) 485_ecore_imf_context_xim_input_panel_hide(Ecore_IMF_Context *ctx)
544{ 486{
487 Ecore_IMF_Context_Data *imf_context_data;
488
545 EINA_LOG_DBG("%s in", __FUNCTION__); 489 EINA_LOG_DBG("%s in", __FUNCTION__);
546 490
547#ifdef ENABLE_XIM
548 Ecore_IMF_Context_Data *imf_context_data;
549 imf_context_data = ecore_imf_context_data_get(ctx); 491 imf_context_data = ecore_imf_context_data_get(ctx);
550 EINA_SAFETY_ON_NULL_RETURN(imf_context_data); 492 EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
551 493
552 ecore_x_e_virtual_keyboard_state_set 494 ecore_x_e_virtual_keyboard_state_set
553 (imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF); 495 (imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF);
554#else
555 (void)ctx;
556#endif
557} 496}
558 497
559#ifdef ENABLE_XIM
560static unsigned int 498static unsigned int
561_ecore_x_event_reverse_modifiers(unsigned int state) 499_ecore_x_event_reverse_modifiers(unsigned int state)
562{ 500{
@@ -618,15 +556,11 @@ _keycode_get(Ecore_X_Display *dsp,
618 return keycode; 556 return keycode;
619} 557}
620 558
621#endif
622
623static Eina_Bool 559static Eina_Bool
624_ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, 560_ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx,
625 Ecore_IMF_Event_Type type, 561 Ecore_IMF_Event_Type type,
626 Ecore_IMF_Event *event) 562 Ecore_IMF_Event *event)
627{ 563{
628 EINA_LOG_DBG("%s in", __FUNCTION__);
629#ifdef ENABLE_XIM
630 Ecore_IMF_Context_Data *imf_context_data; 564 Ecore_IMF_Context_Data *imf_context_data;
631 XIC ic; 565 XIC ic;
632 566
@@ -640,6 +574,8 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx,
640 char *tmp = NULL; 574 char *tmp = NULL;
641 Eina_Bool result = EINA_FALSE; 575 Eina_Bool result = EINA_FALSE;
642 576
577 EINA_LOG_DBG("%s in", __FUNCTION__);
578
643 imf_context_data = ecore_imf_context_data_get(ctx); 579 imf_context_data = ecore_imf_context_data_get(ctx);
644 if (!imf_context_data) return EINA_FALSE; 580 if (!imf_context_data) return EINA_FALSE;
645 ic = imf_context_data->ic; 581 ic = imf_context_data->ic;
@@ -759,17 +695,11 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx,
759 } 695 }
760 696
761 return result; 697 return result;
762#else
763 (void)ctx;
764 (void)type;
765 (void)event;
766 return EINA_FALSE;
767#endif
768} 698}
769 699
770static const Ecore_IMF_Context_Info xim_info = { 700static const Ecore_IMF_Context_Info xim_info = {
771 .id = "xim", 701 .id = "xim",
772 .description = _("X input method"), 702 .description = "X input method",
773 .default_locales = "ko:ja:th:zh", 703 .default_locales = "ko:ja:th:zh",
774 .canvas_type = "evas", 704 .canvas_type = "evas",
775 .canvas_required = 1, 705 .canvas_required = 1,
@@ -846,7 +776,6 @@ ecore_imf_xim_init(void)
846void 776void
847ecore_imf_xim_shutdown(void) 777ecore_imf_xim_shutdown(void)
848{ 778{
849#ifdef ENABLE_XIM
850 while (open_ims) 779 while (open_ims)
851 { 780 {
852 XIM_Im_Info *info = open_ims->data; 781 XIM_Im_Info *info = open_ims->data;
@@ -854,7 +783,6 @@ ecore_imf_xim_shutdown(void)
854 783
855 xim_info_display_closed(display, EINA_FALSE, info); 784 xim_info_display_closed(display, EINA_FALSE, info);
856 } 785 }
857#endif
858 786
859 ecore_x_shutdown(); 787 ecore_x_shutdown();
860 eina_shutdown(); 788 eina_shutdown();
@@ -863,12 +791,11 @@ ecore_imf_xim_shutdown(void)
863EINA_MODULE_INIT(ecore_imf_xim_init); 791EINA_MODULE_INIT(ecore_imf_xim_init);
864EINA_MODULE_SHUTDOWN(ecore_imf_xim_shutdown); 792EINA_MODULE_SHUTDOWN(ecore_imf_xim_shutdown);
865 793
866#ifdef ENABLE_XIM
867/* 794/*
868 * internal functions 795 * internal functions
869 */ 796 */
870Ecore_IMF_Context_Data * 797Ecore_IMF_Context_Data *
871imf_context_data_new() 798imf_context_data_new(void)
872{ 799{
873 Ecore_IMF_Context_Data *imf_context_data = NULL; 800 Ecore_IMF_Context_Data *imf_context_data = NULL;
874 char *locale; 801 char *locale;
@@ -1551,5 +1478,3 @@ xim_destroy_callback(XIM xim EINA_UNUSED,
1551 1478
1552 return; 1479 return;
1553} 1480}
1554
1555#endif /* ENABLE_XIM */