summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp
diff options
context:
space:
mode:
authorJihoon Kim <imfine98@gmail.com>2012-02-03 06:32:24 +0000
committerJihoon Kim <imfine98@gmail.com>2012-02-03 06:32:24 +0000
commit29f18d42a586d917a16a43aedfe79230614cfc2e (patch)
tree2c3bb2889d7fc134a84272570d0dc46ff056d24a /legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp
parent0cfdf167d032e0a685202589cdecaf35a379e895 (diff)
scim_imcontext.cpp: fix formatting
SVN revision: 67692
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp1263
1 files changed, 631 insertions, 632 deletions
diff --git a/legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp b/legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp
index 6cb72c2954..e7c00d0369 100644
--- a/legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp
+++ b/legacy/ecore/src/modules/immodules/scim/scim_imcontext.cpp
@@ -223,18 +223,18 @@ static int __current_super_mask = 0;
223static int __current_hyper_mask = 0; 223static int __current_hyper_mask = 0;
224static int __current_numlock_mask = Mod2Mask; 224static int __current_numlock_mask = Mod2Mask;
225 225
226// A hack to shutdown the immodule cleanly even if im_module_exit () is not called when exiting. 226// A hack to shutdown the immodule cleanly even if im_module_exit() is not called when exiting.
227class FinalizeHandler 227class FinalizeHandler
228{ 228{
229public: 229public:
230 FinalizeHandler () 230 FinalizeHandler()
231 { 231 {
232 SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::FinalizeHandler ()\n"; 232 SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::FinalizeHandler()\n";
233 } 233 }
234 ~FinalizeHandler () 234 ~FinalizeHandler()
235 { 235 {
236 SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::~FinalizeHandler ()\n"; 236 SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::~FinalizeHandler()\n";
237 isf_imf_context_shutdown (); 237 isf_imf_context_shutdown();
238 } 238 }
239}; 239};
240 240
@@ -254,12 +254,12 @@ utf8_offset_to_index(const char *str, int offset)
254} 254}
255 255
256static unsigned int 256static unsigned int
257get_time (void) 257get_time(void)
258{ 258{
259 unsigned int tint; 259 unsigned int tint;
260 struct timeval tv; 260 struct timeval tv;
261 struct timezone tz; /* is not used since ages */ 261 struct timezone tz; /* is not used since ages */
262 gettimeofday (&tv, &tz); 262 gettimeofday(&tv, &tz);
263 tint = tv.tv_sec * 1000; 263 tint = tv.tv_sec * 1000;
264 tint = tint / 1000 * 1000; 264 tint = tint / 1000 * 1000;
265 tint = tint + tv.tv_usec / 1000; 265 tint = tint + tv.tv_usec / 1000;
@@ -268,7 +268,7 @@ get_time (void)
268 268
269/* Function Implementations */ 269/* Function Implementations */
270static EcoreIMFContextISFImpl * 270static EcoreIMFContextISFImpl *
271new_ic_impl (EcoreIMFContextISF *parent) 271new_ic_impl(EcoreIMFContextISF *parent)
272{ 272{
273 EcoreIMFContextISFImpl *impl = NULL; 273 EcoreIMFContextISFImpl *impl = NULL;
274 274
@@ -295,7 +295,7 @@ new_ic_impl (EcoreIMFContextISF *parent)
295} 295}
296 296
297static void 297static void
298delete_ic_impl (EcoreIMFContextISFImpl *impl) 298delete_ic_impl(EcoreIMFContextISFImpl *impl)
299{ 299{
300 EcoreIMFContextISFImpl *rec = _used_ic_impl_list, *last = 0; 300 EcoreIMFContextISFImpl *rec = _used_ic_impl_list, *last = 0;
301 301
@@ -312,10 +312,10 @@ delete_ic_impl (EcoreIMFContextISFImpl *impl)
312 _free_ic_impl_list = rec; 312 _free_ic_impl_list = rec;
313 313
314 rec->parent = 0; 314 rec->parent = 0;
315 rec->si.reset (); 315 rec->si.reset();
316 rec->client_window = 0; 316 rec->client_window = 0;
317 rec->preedit_string = WideString (); 317 rec->preedit_string = WideString();
318 rec->preedit_attrlist.clear (); 318 rec->preedit_attrlist.clear();
319 319
320 return; 320 return;
321 } 321 }
@@ -323,7 +323,7 @@ delete_ic_impl (EcoreIMFContextISFImpl *impl)
323} 323}
324 324
325static void 325static void
326delete_all_ic_impl (void) 326delete_all_ic_impl(void)
327{ 327{
328 EcoreIMFContextISFImpl *it = _used_ic_impl_list; 328 EcoreIMFContextISFImpl *it = _used_ic_impl_list;
329 329
@@ -344,7 +344,7 @@ delete_all_ic_impl (void)
344} 344}
345 345
346static EcoreIMFContextISF * 346static EcoreIMFContextISF *
347find_ic (int id) 347find_ic(int id)
348{ 348{
349 EcoreIMFContextISFImpl *rec = _used_ic_impl_list; 349 EcoreIMFContextISFImpl *rec = _used_ic_impl_list;
350 350
@@ -373,7 +373,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx)
373 EcoreIMFContextISF *context_scim; 373 EcoreIMFContextISF *context_scim;
374 374
375 if (!ctx) return EINA_FALSE; 375 if (!ctx) return EINA_FALSE;
376 context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 376 context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
377 if (!context_scim || !context_scim->impl) return EINA_FALSE; 377 if (!context_scim || !context_scim->impl) return EINA_FALSE;
378 378
379 switch (context_scim->impl->autocapital_type) 379 switch (context_scim->impl->autocapital_type)
@@ -386,7 +386,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx)
386 break; 386 break;
387 } 387 }
388 388
389 for (i=0; i<3; i++) 389 for (i = 0; i < 3; i++)
390 uni_puncs[i] = eina_unicode_utf8_to_unicode(puncs[i], NULL); 390 uni_puncs[i] = eina_unicode_utf8_to_unicode(puncs[i], NULL);
391 391
392 ecore_imf_context_surrounding_get(ctx, &markup_str, &cursor_pos); 392 ecore_imf_context_surrounding_get(ctx, &markup_str, &cursor_pos);
@@ -432,7 +432,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx)
432 432
433 if (tail) 433 if (tail)
434 { 434 {
435 for (i=0; i<3; i++) 435 for (i = 0; i < 3; i++)
436 { 436 {
437 if (!eina_unicode_strcmp(tail, uni_puncs[i])) 437 if (!eina_unicode_strcmp(tail, uni_puncs[i]))
438 { 438 {
@@ -450,7 +450,7 @@ done:
450 if (markup_str) free(markup_str); 450 if (markup_str) free(markup_str);
451 if (plain_str) free(plain_str); 451 if (plain_str) free(plain_str);
452 452
453 for (i=0; i<3; i++) 453 for (i = 0; i < 3; i++)
454 if (uni_puncs[i]) free(uni_puncs[i]); 454 if (uni_puncs[i]) free(uni_puncs[i]);
455 455
456 return ret; 456 return ret;
@@ -463,7 +463,7 @@ caps_mode_check(Ecore_IMF_Context *ctx, Eina_Bool force)
463 EcoreIMFContextISF *context_scim; 463 EcoreIMFContextISF *context_scim;
464 464
465 if (!ctx) return; 465 if (!ctx) return;
466 context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 466 context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
467 467
468 if (autocap_allow == EINA_FALSE) 468 if (autocap_allow == EINA_FALSE)
469 return; 469 return;
@@ -485,25 +485,25 @@ caps_mode_check(Ecore_IMF_Context *ctx, Eina_Bool force)
485} 485}
486 486
487static void 487static void
488feed_key_event (Evas *evas, const char *str, Eina_Bool fake) 488feed_key_event(Evas *evas, const char *str, Eina_Bool fake)
489{ 489{
490 char key_string[128] = {0}; 490 char key_string[128] = {0};
491 unsigned int timestamp = 0; 491 unsigned int timestamp = 0;
492 492
493 if (!fake) 493 if (!fake)
494 timestamp = get_time (); 494 timestamp = get_time();
495 495
496 if (strncmp (str, "KeyRelease+", 11) == 0) 496 if (strncmp(str, "KeyRelease+", 11) == 0)
497 { 497 {
498 strncpy(key_string, str + 11, strlen(str)-11); 498 strncpy(key_string, str + 11, strlen(str)-11);
499 evas_event_feed_key_up (evas, key_string, key_string, NULL, NULL, timestamp, NULL); 499 evas_event_feed_key_up(evas, key_string, key_string, NULL, NULL, timestamp, NULL);
500 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up ()...\n"; 500 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up()...\n";
501 } 501 }
502 else 502 else
503 { 503 {
504 strncpy(key_string, str, strlen(str)); 504 strncpy(key_string, str, strlen(str));
505 evas_event_feed_key_down (evas, key_string, key_string, NULL, NULL, timestamp, NULL); 505 evas_event_feed_key_down(evas, key_string, key_string, NULL, NULL, timestamp, NULL);
506 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down ()...\n"; 506 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down()...\n";
507 } 507 }
508} 508}
509 509
@@ -517,15 +517,15 @@ feed_key_event (Evas *evas, const char *str, Eina_Bool fake)
517 * Return value: A pointer to the newly created EcoreIMFContextISF instance 517 * Return value: A pointer to the newly created EcoreIMFContextISF instance
518 */ 518 */
519EAPI EcoreIMFContextISF * 519EAPI EcoreIMFContextISF *
520isf_imf_context_new (void) 520isf_imf_context_new(void)
521{ 521{
522 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 522 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
523 char *env; 523 char *env;
524 524
525 Ecore_X_Display *display = ecore_x_display_get (); 525 Ecore_X_Display *display = ecore_x_display_get();
526 if (!display) 526 if (!display)
527 { 527 {
528 std::cerr << "ecore_x_display_get () failed !!!"; 528 std::cerr << "ecore_x_display_get() failed !!!";
529 return NULL; 529 return NULL;
530 } 530 }
531 531
@@ -540,7 +540,7 @@ isf_imf_context_new (void)
540 540
541 if (!_scim_initialized) 541 if (!_scim_initialized)
542 { 542 {
543 initialize (); 543 initialize();
544 _scim_initialized = true; 544 _scim_initialized = true;
545 } 545 }
546 546
@@ -558,61 +558,61 @@ isf_imf_context_new (void)
558 * cleanup job. 558 * cleanup job.
559 */ 559 */
560EAPI void 560EAPI void
561isf_imf_context_shutdown (void) 561isf_imf_context_shutdown(void)
562{ 562{
563 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 563 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
564 564
565 if (_scim_initialized) 565 if (_scim_initialized)
566 { 566 {
567 _scim_initialized = false; 567 _scim_initialized = false;
568 finalize (); 568 finalize();
569 } 569 }
570} 570}
571 571
572EAPI void 572EAPI void
573isf_imf_context_add (Ecore_IMF_Context *ctx) 573isf_imf_context_add(Ecore_IMF_Context *ctx)
574{ 574{
575 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 575 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
576 576
577 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 577 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
578 578
579 if (!context_scim) return; 579 if (!context_scim) return;
580 580
581 context_scim->impl = NULL; 581 context_scim->impl = NULL;
582 582
583 if (_backend.null ()) 583 if (_backend.null())
584 return; 584 return;
585 585
586 IMEngineInstancePointer si; 586 IMEngineInstancePointer si;
587 587
588 // Use the default instance if "shared input method" mode is enabled. 588 // Use the default instance if "shared input method" mode is enabled.
589 if (_shared_input_method && !_default_instance.null ()) 589 if (_shared_input_method && !_default_instance.null())
590 { 590 {
591 si = _default_instance; 591 si = _default_instance;
592 SCIM_DEBUG_FRONTEND(2) << "use default instance: " << si->get_id () << " " << si->get_factory_uuid () << "\n"; 592 SCIM_DEBUG_FRONTEND(2) << "use default instance: " << si->get_id() << " " << si->get_factory_uuid() << "\n";
593 } 593 }
594 594
595 // Not in "shared input method" mode, or no default instance, create an instance. 595 // Not in "shared input method" mode, or no default instance, create an instance.
596 if (si.null ()) 596 if (si.null())
597 { 597 {
598 IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); 598 IMEngineFactoryPointer factory = _backend->get_default_factory(_language, "UTF-8");
599 if (factory.null ()) return; 599 if (factory.null()) return;
600 si = factory->create_instance ("UTF-8", _instance_count++); 600 si = factory->create_instance("UTF-8", _instance_count++);
601 if (si.null ()) return; 601 if (si.null()) return;
602 attach_instance (si); 602 attach_instance(si);
603 SCIM_DEBUG_FRONTEND(2) << "create new instance: " << si->get_id () << " " << si->get_factory_uuid () << "\n"; 603 SCIM_DEBUG_FRONTEND(2) << "create new instance: " << si->get_id() << " " << si->get_factory_uuid() << "\n";
604 } 604 }
605 605
606 // If "shared input method" mode is enabled, and there is no default instance, 606 // If "shared input method" mode is enabled, and there is no default instance,
607 // then store this instance as default one. 607 // then store this instance as default one.
608 if (_shared_input_method && _default_instance.null ()) 608 if (_shared_input_method && _default_instance.null())
609 { 609 {
610 SCIM_DEBUG_FRONTEND(2) << "update default instance.\n"; 610 SCIM_DEBUG_FRONTEND(2) << "update default instance.\n";
611 _default_instance = si; 611 _default_instance = si;
612 } 612 }
613 613
614 context_scim->ctx = ctx; 614 context_scim->ctx = ctx;
615 context_scim->impl = new_ic_impl (context_scim); 615 context_scim->impl = new_ic_impl(context_scim);
616 if (context_scim->impl == NULL) 616 if (context_scim->impl == NULL)
617 { 617 {
618 std::cerr << "memory allocation failed in " << __FUNCTION__ << "\n"; 618 std::cerr << "memory allocation failed in " << __FUNCTION__ << "\n";
@@ -640,24 +640,24 @@ isf_imf_context_add (Ecore_IMF_Context *ctx)
640 _ic_list = context_scim; 640 _ic_list = context_scim;
641 641
642 if (_shared_input_method) 642 if (_shared_input_method)
643 context_scim->impl->is_on = _config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on); 643 context_scim->impl->is_on = _config->read(String(SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on);
644 644
645 _panel_client.prepare (context_scim->id); 645 _panel_client.prepare(context_scim->id);
646 _panel_client.register_input_context (context_scim->id, si->get_factory_uuid ()); 646 _panel_client.register_input_context(context_scim->id, si->get_factory_uuid());
647 set_ic_capabilities (context_scim); 647 set_ic_capabilities(context_scim);
648 _panel_client.send (); 648 _panel_client.send();
649 649
650 SCIM_DEBUG_FRONTEND(2) << "input context created: id = " << context_scim->id << "\n"; 650 SCIM_DEBUG_FRONTEND(2) << "input context created: id = " << context_scim->id << "\n";
651} 651}
652 652
653EAPI void 653EAPI void
654isf_imf_context_del (Ecore_IMF_Context *ctx) 654isf_imf_context_del(Ecore_IMF_Context *ctx)
655{ 655{
656 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 656 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
657 657
658 if (!_ic_list) return; 658 if (!_ic_list) return;
659 659
660 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 660 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
661 661
662 if (context_scim) 662 if (context_scim)
663 { 663 {
@@ -682,32 +682,32 @@ isf_imf_context_del (Ecore_IMF_Context *ctx)
682 682
683 if (context_scim && context_scim->impl) 683 if (context_scim && context_scim->impl)
684 { 684 {
685 _panel_client.prepare (context_scim->id); 685 _panel_client.prepare(context_scim->id);
686 686
687 if (context_scim == _focused_ic) 687 if (context_scim == _focused_ic)
688 context_scim->impl->si->focus_out (); 688 context_scim->impl->si->focus_out();
689 689
690 // Delete the instance. 690 // Delete the instance.
691 EcoreIMFContextISF *old_focused = _focused_ic; 691 EcoreIMFContextISF *old_focused = _focused_ic;
692 _focused_ic = context_scim; 692 _focused_ic = context_scim;
693 context_scim->impl->si.reset (); 693 context_scim->impl->si.reset();
694 _focused_ic = old_focused; 694 _focused_ic = old_focused;
695 695
696 if (context_scim == _focused_ic) 696 if (context_scim == _focused_ic)
697 { 697 {
698 _panel_client.turn_off (context_scim->id); 698 _panel_client.turn_off(context_scim->id);
699 _panel_client.focus_out (context_scim->id); 699 _panel_client.focus_out(context_scim->id);
700 } 700 }
701 701
702 _panel_client.remove_input_context (context_scim->id); 702 _panel_client.remove_input_context(context_scim->id);
703 _panel_client.send (); 703 _panel_client.send();
704 704
705 if (context_scim->impl->client_window) 705 if (context_scim->impl->client_window)
706 isf_imf_context_client_window_set (ctx, NULL); 706 isf_imf_context_client_window_set(ctx, NULL);
707 707
708 if (context_scim->impl) 708 if (context_scim->impl)
709 { 709 {
710 delete_ic_impl (context_scim->impl); 710 delete_ic_impl(context_scim->impl);
711 context_scim->impl = 0; 711 context_scim->impl = 0;
712 } 712 }
713 } 713 }
@@ -738,11 +738,11 @@ isf_imf_context_del (Ecore_IMF_Context *ctx)
738 * be used for purposes internal to the Input Method Context. 738 * be used for purposes internal to the Input Method Context.
739 */ 739 */
740EAPI void 740EAPI void
741isf_imf_context_client_canvas_set (Ecore_IMF_Context *ctx, void *canvas) 741isf_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
742{ 742{
743 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 743 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
744 744
745 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 745 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
746 746
747 if (context_scim && context_scim->impl && context_scim->impl->client_canvas != (Evas*) canvas) 747 if (context_scim && context_scim->impl && context_scim->impl->client_canvas != (Evas*) canvas)
748 context_scim->impl->client_canvas = (Evas*)canvas; 748 context_scim->impl->client_canvas = (Evas*)canvas;
@@ -762,11 +762,11 @@ isf_imf_context_client_canvas_set (Ecore_IMF_Context *ctx, void *canvas)
762 * and may also be used for purposes internal to the Input Method Context. 762 * and may also be used for purposes internal to the Input Method Context.
763 */ 763 */
764EAPI void 764EAPI void
765isf_imf_context_client_window_set (Ecore_IMF_Context *ctx, void *window) 765isf_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
766{ 766{
767 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 767 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
768 768
769 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 769 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
770 770
771 if (context_scim && context_scim->impl && context_scim->impl->client_window != (Ecore_X_Window)((Ecore_Window)window)) 771 if (context_scim && context_scim->impl && context_scim->impl->client_window != (Ecore_X_Window)((Ecore_Window)window))
772 { 772 {
@@ -789,29 +789,29 @@ isf_imf_context_client_window_set (Ecore_IMF_Context *ctx, void *window)
789 * to clear the preedit state. 789 * to clear the preedit state.
790 */ 790 */
791EAPI void 791EAPI void
792isf_imf_context_reset (Ecore_IMF_Context *ctx) 792isf_imf_context_reset(Ecore_IMF_Context *ctx)
793{ 793{
794 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 794 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
795 795
796 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 796 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
797 797
798 if (context_scim && context_scim->impl && context_scim == _focused_ic) 798 if (context_scim && context_scim->impl && context_scim == _focused_ic)
799 { 799 {
800 WideString wstr = context_scim->impl->preedit_string; 800 WideString wstr = context_scim->impl->preedit_string;
801 801
802 _panel_client.prepare (context_scim->id); 802 _panel_client.prepare(context_scim->id);
803 context_scim->impl->si->reset (); 803 context_scim->impl->si->reset();
804 _panel_client.send (); 804 _panel_client.send();
805 805
806 if (context_scim->impl->need_commit_preedit) 806 if (context_scim->impl->need_commit_preedit)
807 { 807 {
808 if (wstr.length ()) 808 if (wstr.length())
809 { 809 {
810 ecore_imf_context_commit_event_add (context_scim->ctx, utf8_wcstombs (wstr).c_str ()); 810 ecore_imf_context_commit_event_add(context_scim->ctx, utf8_wcstombs(wstr).c_str());
811 ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); 811 ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str());
812 } 812 }
813 _panel_client.prepare (context_scim->id); 813 _panel_client.prepare(context_scim->id);
814 _panel_client.send (); 814 _panel_client.send();
815 } 815 }
816 } 816 }
817} 817}
@@ -825,9 +825,9 @@ isf_imf_context_reset (Ecore_IMF_Context *ctx)
825 * Notify the Input Method Context that the widget to which its correspond has gained focus. 825 * Notify the Input Method Context that the widget to which its correspond has gained focus.
826 */ 826 */
827EAPI void 827EAPI void
828isf_imf_context_focus_in (Ecore_IMF_Context *ctx) 828isf_imf_context_focus_in(Ecore_IMF_Context *ctx)
829{ 829{
830 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 830 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
831 831
832 if (!context_scim) 832 if (!context_scim)
833 return; 833 return;
@@ -839,12 +839,11 @@ isf_imf_context_focus_in (Ecore_IMF_Context *ctx)
839 if (_focused_ic == context_scim) 839 if (_focused_ic == context_scim)
840 { 840 {
841 SCIM_DEBUG_FRONTEND(1) << "It's already focused.\n"; 841 SCIM_DEBUG_FRONTEND(1) << "It's already focused.\n";
842 //isf_imf_context_cursor_position_set (ctx, 0);
843 return; 842 return;
844 } 843 }
845 SCIM_DEBUG_FRONTEND(1) << "Focus out previous IC first: " << _focused_ic->id << "\n"; 844 SCIM_DEBUG_FRONTEND(1) << "Focus out previous IC first: " << _focused_ic->id << "\n";
846 if (_focused_ic->ctx) 845 if (_focused_ic->ctx)
847 isf_imf_context_focus_out (_focused_ic->ctx); 846 isf_imf_context_focus_out(_focused_ic->ctx);
848 } 847 }
849 848
850 bool need_cap = false; 849 bool need_cap = false;
@@ -854,28 +853,28 @@ isf_imf_context_focus_in (Ecore_IMF_Context *ctx)
854 if (context_scim && context_scim->impl) 853 if (context_scim && context_scim->impl)
855 { 854 {
856 _focused_ic = context_scim; 855 _focused_ic = context_scim;
857 _panel_client.prepare (context_scim->id); 856 _panel_client.prepare(context_scim->id);
858 857
859 // Handle the "Shared Input Method" mode. 858 // Handle the "Shared Input Method" mode.
860 if (_shared_input_method) 859 if (_shared_input_method)
861 { 860 {
862 SCIM_DEBUG_FRONTEND(2) << "shared input method.\n"; 861 SCIM_DEBUG_FRONTEND(2) << "shared input method.\n";
863 IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); 862 IMEngineFactoryPointer factory = _backend->get_default_factory(_language, "UTF-8");
864 if (!factory.null ()) 863 if (!factory.null())
865 { 864 {
866 if (_default_instance.null () || _default_instance->get_factory_uuid () != factory->get_uuid ()) 865 if (_default_instance.null() || _default_instance->get_factory_uuid() != factory->get_uuid())
867 { 866 {
868 _default_instance = factory->create_instance ("UTF-8", _default_instance.null () ? _instance_count++ : _default_instance->get_id ()); 867 _default_instance = factory->create_instance("UTF-8", _default_instance.null() ? _instance_count++ : _default_instance->get_id());
869 attach_instance (_default_instance); 868 attach_instance(_default_instance);
870 SCIM_DEBUG_FRONTEND(2) << "create new default instance: " << _default_instance->get_id () << " " << _default_instance->get_factory_uuid () << "\n"; 869 SCIM_DEBUG_FRONTEND(2) << "create new default instance: " << _default_instance->get_id() << " " << _default_instance->get_factory_uuid() << "\n";
871 } 870 }
872 871
873 context_scim->impl->shared_si = true; 872 context_scim->impl->shared_si = true;
874 context_scim->impl->si = _default_instance; 873 context_scim->impl->si = _default_instance;
875 874
876 context_scim->impl->is_on = _config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on); 875 context_scim->impl->is_on = _config->read(String(SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on);
877 context_scim->impl->preedit_string.clear (); 876 context_scim->impl->preedit_string.clear();
878 context_scim->impl->preedit_attrlist.clear (); 877 context_scim->impl->preedit_attrlist.clear();
879 context_scim->impl->preedit_caret = 0; 878 context_scim->impl->preedit_caret = 0;
880 context_scim->impl->preedit_started = false; 879 context_scim->impl->preedit_started = false;
881 need_cap = true; 880 need_cap = true;
@@ -886,46 +885,46 @@ isf_imf_context_focus_in (Ecore_IMF_Context *ctx)
886 else if (context_scim->impl->shared_si) 885 else if (context_scim->impl->shared_si)
887 { 886 {
888 SCIM_DEBUG_FRONTEND(2) << "exit shared input method.\n"; 887 SCIM_DEBUG_FRONTEND(2) << "exit shared input method.\n";
889 IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); 888 IMEngineFactoryPointer factory = _backend->get_default_factory(_language, "UTF-8");
890 if (!factory.null ()) 889 if (!factory.null())
891 { 890 {
892 context_scim->impl->si = factory->create_instance ("UTF-8", _instance_count++); 891 context_scim->impl->si = factory->create_instance("UTF-8", _instance_count++);
893 context_scim->impl->preedit_string.clear (); 892 context_scim->impl->preedit_string.clear();
894 context_scim->impl->preedit_attrlist.clear (); 893 context_scim->impl->preedit_attrlist.clear();
895 context_scim->impl->preedit_caret = 0; 894 context_scim->impl->preedit_caret = 0;
896 context_scim->impl->preedit_started = false; 895 context_scim->impl->preedit_started = false;
897 attach_instance (context_scim->impl->si); 896 attach_instance(context_scim->impl->si);
898 need_cap = true; 897 need_cap = true;
899 need_reg = true; 898 need_reg = true;
900 context_scim->impl->shared_si = false; 899 context_scim->impl->shared_si = false;
901 SCIM_DEBUG_FRONTEND(2) << "create new instance: " << context_scim->impl->si->get_id () << " " << context_scim->impl->si->get_factory_uuid () << "\n"; 900 SCIM_DEBUG_FRONTEND(2) << "create new instance: " << context_scim->impl->si->get_id() << " " << context_scim->impl->si->get_factory_uuid() << "\n";
902 } 901 }
903 } 902 }
904 903
905 context_scim->impl->si->set_frontend_data (static_cast <void*> (context_scim)); 904 context_scim->impl->si->set_frontend_data(static_cast <void*>(context_scim));
906 905
907 if (need_reg) _panel_client.register_input_context (context_scim->id, context_scim->impl->si->get_factory_uuid ()); 906 if (need_reg) _panel_client.register_input_context(context_scim->id, context_scim->impl->si->get_factory_uuid());
908 if (need_cap) set_ic_capabilities (context_scim); 907 if (need_cap) set_ic_capabilities(context_scim);
909 if (need_reset) context_scim->impl->si->reset (); 908 if (need_reset) context_scim->impl->si->reset();
910 909
911 panel_req_focus_in (context_scim); 910 panel_req_focus_in(context_scim);
912 panel_req_update_spot_location (context_scim); 911 panel_req_update_spot_location(context_scim);
913 panel_req_update_factory_info (context_scim); 912 panel_req_update_factory_info(context_scim);
914 913
915 if (context_scim->impl->is_on) 914 if (context_scim->impl->is_on)
916 { 915 {
917 _panel_client.turn_on (context_scim->id); 916 _panel_client.turn_on(context_scim->id);
918 _panel_client.hide_preedit_string (context_scim->id); 917 _panel_client.hide_preedit_string(context_scim->id);
919 _panel_client.hide_aux_string (context_scim->id); 918 _panel_client.hide_aux_string(context_scim->id);
920 _panel_client.hide_lookup_table (context_scim->id); 919 _panel_client.hide_lookup_table(context_scim->id);
921 context_scim->impl->si->focus_in (); 920 context_scim->impl->si->focus_in();
922 } 921 }
923 else 922 else
924 { 923 {
925 _panel_client.turn_off (context_scim->id); 924 _panel_client.turn_off(context_scim->id);
926 } 925 }
927 926
928 _panel_client.send (); 927 _panel_client.send();
929 } 928 }
930} 929}
931 930
@@ -938,9 +937,9 @@ isf_imf_context_focus_in (Ecore_IMF_Context *ctx)
938 * Notify the Input Method Context that the widget to which its correspond has lost focus. 937 * Notify the Input Method Context that the widget to which its correspond has lost focus.
939 */ 938 */
940EAPI void 939EAPI void
941isf_imf_context_focus_out (Ecore_IMF_Context *ctx) 940isf_imf_context_focus_out(Ecore_IMF_Context *ctx)
942{ 941{
943 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 942 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
944 943
945 if (!context_scim) return; 944 if (!context_scim) return;
946 945
@@ -952,21 +951,21 @@ isf_imf_context_focus_out (Ecore_IMF_Context *ctx)
952 951
953 if (context_scim->impl->need_commit_preedit) 952 if (context_scim->impl->need_commit_preedit)
954 { 953 {
955 if (wstr.length ()) 954 if (wstr.length())
956 { 955 {
957 ecore_imf_context_commit_event_add (context_scim->ctx, utf8_wcstombs (wstr).c_str ()); 956 ecore_imf_context_commit_event_add(context_scim->ctx, utf8_wcstombs(wstr).c_str());
958 ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); 957 ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str());
959 } 958 }
960 _panel_client.prepare (context_scim->id); 959 _panel_client.prepare(context_scim->id);
961 _panel_client.send (); 960 _panel_client.send();
962 } 961 }
963 962
964 _panel_client.prepare (context_scim->id); 963 _panel_client.prepare(context_scim->id);
965 context_scim->impl->si->focus_out (); 964 context_scim->impl->si->focus_out();
966 context_scim->impl->si->reset (); 965 context_scim->impl->si->reset();
967 _panel_client.turn_off (context_scim->id); 966 _panel_client.turn_off(context_scim->id);
968 _panel_client.focus_out (context_scim->id); 967 _panel_client.focus_out(context_scim->id);
969 _panel_client.send (); 968 _panel_client.send();
970 _focused_ic = 0; 969 _focused_ic = 0;
971 } 970 }
972} 971}
@@ -984,11 +983,11 @@ isf_imf_context_focus_out (Ecore_IMF_Context *ctx)
984 * Notify the Input Method Context that a change in the cursor location has been made. 983 * Notify the Input Method Context that a change in the cursor location has been made.
985 */ 984 */
986EAPI void 985EAPI void
987isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int cx, int cy, int cw, int ch) 986isf_imf_context_cursor_location_set(Ecore_IMF_Context *ctx, int cx, int cy, int cw, int ch)
988{ 987{
989 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 988 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
990 989
991 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 990 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
992 Ecore_Evas *ee; 991 Ecore_Evas *ee;
993 int canvas_x, canvas_y; 992 int canvas_x, canvas_y;
994 993
@@ -1007,15 +1006,15 @@ isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int cx, int cy, int
1007 ee = ecore_evas_ecore_evas_get(context_scim->impl->client_canvas); 1006 ee = ecore_evas_ecore_evas_get(context_scim->impl->client_canvas);
1008 if (!ee) return; 1007 if (!ee) return;
1009 1008
1010 ecore_evas_geometry_get (ee, &canvas_x, &canvas_y, NULL, NULL); 1009 ecore_evas_geometry_get(ee, &canvas_x, &canvas_y, NULL, NULL);
1011 1010
1012 if (context_scim->impl->cursor_x != canvas_x + cx || context_scim->impl->cursor_y != canvas_y + cy + ch) 1011 if (context_scim->impl->cursor_x != canvas_x + cx || context_scim->impl->cursor_y != canvas_y + cy + ch)
1013 { 1012 {
1014 context_scim->impl->cursor_x = canvas_x + cx; 1013 context_scim->impl->cursor_x = canvas_x + cx;
1015 context_scim->impl->cursor_y = canvas_y + cy + ch; 1014 context_scim->impl->cursor_y = canvas_y + cy + ch;
1016 _panel_client.prepare (context_scim->id); 1015 _panel_client.prepare(context_scim->id);
1017 panel_req_update_spot_location (context_scim); 1016 panel_req_update_spot_location(context_scim);
1018 _panel_client.send (); 1017 _panel_client.send();
1019 SCIM_DEBUG_FRONTEND(2) << "new cursor location = " << context_scim->impl->cursor_x << "," << context_scim->impl->cursor_y << "\n"; 1018 SCIM_DEBUG_FRONTEND(2) << "new cursor location = " << context_scim->impl->cursor_x << "," << context_scim->impl->cursor_y << "\n";
1020 } 1019 }
1021 } 1020 }
@@ -1033,11 +1032,11 @@ isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int cx, int cy, int
1033 * display feedback, such as displaying it in a child of the root window. 1032 * display feedback, such as displaying it in a child of the root window.
1034 */ 1033 */
1035EAPI void 1034EAPI void
1036isf_imf_context_use_preedit_set (Ecore_IMF_Context* ctx, Eina_Bool use_preedit) 1035isf_imf_context_use_preedit_set(Ecore_IMF_Context* ctx, Eina_Bool use_preedit)
1037{ 1036{
1038 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (use_preedit ? "true" : "false") << "...\n"; 1037 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (use_preedit ? "true" : "false") << "...\n";
1039 1038
1040 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 1039 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
1041 1040
1042 if (!_on_the_spot) return; 1041 if (!_on_the_spot) return;
1043 1042
@@ -1047,36 +1046,36 @@ isf_imf_context_use_preedit_set (Ecore_IMF_Context* ctx, Eina_Bool use_preedit)
1047 context_scim->impl->use_preedit = use_preedit; 1046 context_scim->impl->use_preedit = use_preedit;
1048 if (context_scim == _focused_ic) 1047 if (context_scim == _focused_ic)
1049 { 1048 {
1050 _panel_client.prepare (context_scim->id); 1049 _panel_client.prepare(context_scim->id);
1051 1050
1052 if (old != use_preedit) 1051 if (old != use_preedit)
1053 set_ic_capabilities (context_scim); 1052 set_ic_capabilities(context_scim);
1054 1053
1055 if (context_scim->impl->preedit_string.length ()) 1054 if (context_scim->impl->preedit_string.length())
1056 slot_show_preedit_string (context_scim->impl->si); 1055 slot_show_preedit_string(context_scim->impl->si);
1057 1056
1058 _panel_client.send (); 1057 _panel_client.send();
1059 } 1058 }
1060 } 1059 }
1061} 1060}
1062 1061
1063EAPI void 1062EAPI void
1064isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char** str, Eina_List **attrs, int *cursor_pos) 1063isf_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char** str, Eina_List **attrs, int *cursor_pos)
1065{ 1064{
1066 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1065 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1067 1066
1068 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 1067 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
1069 1068
1070 if (context_scim && context_scim->impl && context_scim->impl->is_on) 1069 if (context_scim && context_scim->impl && context_scim->impl->is_on)
1071 { 1070 {
1072 String mbs = utf8_wcstombs (context_scim->impl->preedit_string); 1071 String mbs = utf8_wcstombs(context_scim->impl->preedit_string);
1073 1072
1074 if (str) 1073 if (str)
1075 { 1074 {
1076 if (mbs.length ()) 1075 if (mbs.length())
1077 *str = strdup (mbs.c_str ()); 1076 *str = strdup(mbs.c_str());
1078 else 1077 else
1079 *str = strdup (""); 1078 *str = strdup("");
1080 } 1079 }
1081 1080
1082 if (cursor_pos) 1081 if (cursor_pos)
@@ -1086,28 +1085,28 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1086 1085
1087 if (attrs) 1086 if (attrs)
1088 { 1087 {
1089 if (mbs.length ()) 1088 if (mbs.length())
1090 { 1089 {
1091 int start_index, end_index; 1090 int start_index, end_index;
1092 int wlen = context_scim->impl->preedit_string.length (); 1091 int wlen = context_scim->impl->preedit_string.length();
1093 1092
1094 Ecore_IMF_Preedit_Attr *attr = NULL; 1093 Ecore_IMF_Preedit_Attr *attr = NULL;
1095 AttributeList::const_iterator i; 1094 AttributeList::const_iterator i;
1096 bool *attrs_flag = new bool [mbs.length ()]; 1095 bool *attrs_flag = new bool [mbs.length()];
1097 memset (attrs_flag, 0, mbs.length () *sizeof (bool)); 1096 memset(attrs_flag, 0, mbs.length() *sizeof(bool));
1098 1097
1099 for (i = context_scim->impl->preedit_attrlist.begin (); 1098 for (i = context_scim->impl->preedit_attrlist.begin();
1100 i != context_scim->impl->preedit_attrlist.end (); ++i) 1099 i != context_scim->impl->preedit_attrlist.end(); ++i)
1101 { 1100 {
1102 start_index = i->get_start (); 1101 start_index = i->get_start();
1103 end_index = i->get_end (); 1102 end_index = i->get_end();
1104 1103
1105 if (end_index <= wlen && start_index < end_index && i->get_type () != SCIM_ATTR_DECORATE_NONE) 1104 if (end_index <= wlen && start_index < end_index && i->get_type() != SCIM_ATTR_DECORATE_NONE)
1106 { 1105 {
1107 start_index = utf8_offset_to_index (mbs.c_str (), i->get_start ()); 1106 start_index = utf8_offset_to_index(mbs.c_str(), i->get_start());
1108 end_index = utf8_offset_to_index (mbs.c_str (), i->get_end ()); 1107 end_index = utf8_offset_to_index(mbs.c_str(), i->get_end());
1109 1108
1110 if (i->get_type () == SCIM_ATTR_DECORATE) 1109 if (i->get_type() == SCIM_ATTR_DECORATE)
1111 { 1110 {
1112 attr = (Ecore_IMF_Preedit_Attr *)calloc(1, sizeof(Ecore_IMF_Preedit_Attr)); 1111 attr = (Ecore_IMF_Preedit_Attr *)calloc(1, sizeof(Ecore_IMF_Preedit_Attr));
1113 if (attr == NULL) 1112 if (attr == NULL)
@@ -1115,24 +1114,24 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1115 attr->start_index = start_index; 1114 attr->start_index = start_index;
1116 attr->end_index = end_index; 1115 attr->end_index = end_index;
1117 1116
1118 if (i->get_value () == SCIM_ATTR_DECORATE_UNDERLINE) 1117 if (i->get_value() == SCIM_ATTR_DECORATE_UNDERLINE)
1119 { 1118 {
1120 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB1; 1119 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB1;
1121 *attrs = eina_list_append(*attrs, (void *)attr); 1120 *attrs = eina_list_append(*attrs, (void *)attr);
1122 } 1121 }
1123 else if (i->get_value () == SCIM_ATTR_DECORATE_REVERSE) 1122 else if (i->get_value() == SCIM_ATTR_DECORATE_REVERSE)
1124 { 1123 {
1125 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2; 1124 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2;
1126 *attrs = eina_list_append(*attrs, (void *)attr); 1125 *attrs = eina_list_append(*attrs, (void *)attr);
1127 } 1126 }
1128 else if (i->get_value () == SCIM_ATTR_DECORATE_HIGHLIGHT) 1127 else if (i->get_value() == SCIM_ATTR_DECORATE_HIGHLIGHT)
1129 { 1128 {
1130 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3; 1129 attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3;
1131 *attrs = eina_list_append(*attrs, (void *)attr); 1130 *attrs = eina_list_append(*attrs, (void *)attr);
1132 } 1131 }
1133 else 1132 else
1134 { 1133 {
1135 free (attr); 1134 free(attr);
1136 } 1135 }
1137 1136
1138 switch(i->get_value()) 1137 switch(i->get_value())
@@ -1148,11 +1147,11 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1148 break; 1147 break;
1149 } 1148 }
1150 } 1149 }
1151 else if (i->get_type () == SCIM_ATTR_FOREGROUND) 1150 else if (i->get_type() == SCIM_ATTR_FOREGROUND)
1152 { 1151 {
1153 SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_FOREGROUND\n"; 1152 SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_FOREGROUND\n";
1154 } 1153 }
1155 else if (i->get_type () == SCIM_ATTR_BACKGROUND) 1154 else if (i->get_type() == SCIM_ATTR_BACKGROUND)
1156 { 1155 {
1157 SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_BACKGROUND\n"; 1156 SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_BACKGROUND\n";
1158 } 1157 }
@@ -1160,13 +1159,13 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1160 } 1159 }
1161 1160
1162 // Add underline for all characters which don't have attribute. 1161 // Add underline for all characters which don't have attribute.
1163 for (unsigned int pos = 0; pos < mbs.length (); ++pos) 1162 for (unsigned int pos = 0; pos < mbs.length(); ++pos)
1164 { 1163 {
1165 if (!attrs_flag [pos]) 1164 if (!attrs_flag [pos])
1166 { 1165 {
1167 int begin_pos = pos; 1166 int begin_pos = pos;
1168 1167
1169 while (pos < mbs.length () && !attrs_flag [pos]) 1168 while (pos < mbs.length() && !attrs_flag[pos])
1170 ++pos; 1169 ++pos;
1171 1170
1172 // use REVERSE style as default 1171 // use REVERSE style as default
@@ -1187,7 +1186,7 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1187 else 1186 else
1188 { 1187 {
1189 if (str) 1188 if (str)
1190 *str = strdup (""); 1189 *str = strdup("");
1191 1190
1192 if (cursor_pos) 1191 if (cursor_pos)
1193 *cursor_pos = 0; 1192 *cursor_pos = 0;
@@ -1208,22 +1207,22 @@ isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char
1208 * To get the preedit string of the input method. 1207 * To get the preedit string of the input method.
1209 */ 1208 */
1210EAPI void 1209EAPI void
1211isf_imf_context_preedit_string_get (Ecore_IMF_Context *ctx, char** str, int *cursor_pos) 1210isf_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char** str, int *cursor_pos)
1212{ 1211{
1213 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1212 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1214 1213
1215 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 1214 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
1216 1215
1217 if (context_scim && context_scim->impl && context_scim->impl->is_on) 1216 if (context_scim && context_scim->impl && context_scim->impl->is_on)
1218 { 1217 {
1219 String mbs = utf8_wcstombs (context_scim->impl->preedit_string); 1218 String mbs = utf8_wcstombs(context_scim->impl->preedit_string);
1220 1219
1221 if (str) 1220 if (str)
1222 { 1221 {
1223 if (mbs.length ()) 1222 if (mbs.length())
1224 *str = strdup (mbs.c_str ()); 1223 *str = strdup(mbs.c_str());
1225 else 1224 else
1226 *str = strdup (""); 1225 *str = strdup("");
1227 } 1226 }
1228 1227
1229 if (cursor_pos) 1228 if (cursor_pos)
@@ -1232,7 +1231,7 @@ isf_imf_context_preedit_string_get (Ecore_IMF_Context *ctx, char** str, int *cur
1232 else 1231 else
1233 { 1232 {
1234 if (str) 1233 if (str)
1235 *str = strdup (""); 1234 *str = strdup("");
1236 1235
1237 if (cursor_pos) 1236 if (cursor_pos)
1238 *cursor_pos = 0; 1237 *cursor_pos = 0;
@@ -1249,11 +1248,11 @@ isf_imf_context_preedit_string_get (Ecore_IMF_Context *ctx, char** str, int *cur
1249 * Notify the Input Method Context that a change in the cursor position has been made. 1248 * Notify the Input Method Context that a change in the cursor position has been made.
1250 */ 1249 */
1251EAPI void 1250EAPI void
1252isf_imf_context_cursor_position_set (Ecore_IMF_Context *ctx, int cursor_pos) 1251isf_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
1253{ 1252{
1254 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1253 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1255 1254
1256 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 1255 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
1257 1256
1258 if (context_scim && context_scim->impl && context_scim == _focused_ic) 1257 if (context_scim && context_scim->impl && context_scim == _focused_ic)
1259 { 1258 {
@@ -1280,11 +1279,11 @@ isf_imf_context_cursor_position_set (Ecore_IMF_Context *ctx, int cursor_pos)
1280 * is in Ecore_IMF.h. 1279 * is in Ecore_IMF.h.
1281 */ 1280 */
1282EAPI void 1281EAPI void
1283isf_imf_context_input_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode) 1282isf_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
1284{ 1283{
1285 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1284 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1286 1285
1287 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 1286 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
1288 if (context_scim && context_scim->impl) 1287 if (context_scim && context_scim->impl)
1289 context_scim->impl->input_mode = input_mode; 1288 context_scim->impl->input_mode = input_mode;
1290} 1289}
@@ -1299,22 +1298,22 @@ isf_imf_context_input_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode inp
1299 * Set whether the IM context should use the prediction. 1298 * Set whether the IM context should use the prediction.
1300 */ 1299 */
1301EAPI void 1300EAPI void
1302isf_imf_context_prediction_allow_set (Ecore_IMF_Context* ctx, Eina_Bool prediction) 1301isf_imf_context_prediction_allow_set(Ecore_IMF_Context* ctx, Eina_Bool prediction)
1303{ 1302{
1304 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (prediction ? "true" : "false") << "...\n"; 1303 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (prediction ? "true" : "false") << "...\n";
1305 1304
1306 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 1305 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
1307 1306
1308 if (context_scim && context_scim->impl && context_scim->impl->prediction_allow != prediction) 1307 if (context_scim && context_scim->impl && context_scim->impl->prediction_allow != prediction)
1309 context_scim->impl->prediction_allow = prediction; 1308 context_scim->impl->prediction_allow = prediction;
1310} 1309}
1311 1310
1312EAPI void 1311EAPI void
1313isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapital_Type autocapital_type) 1312isf_imf_context_autocapital_type_set(Ecore_IMF_Context* ctx, Ecore_IMF_Autocapital_Type autocapital_type)
1314{ 1313{
1315 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << autocapital_type << "...\n"; 1314 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << autocapital_type << "...\n";
1316 1315
1317 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); 1316 EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get(ctx);
1318 1317
1319 if (context_scim && context_scim->impl && context_scim->impl->autocapital_type != autocapital_type) 1318 if (context_scim && context_scim->impl && context_scim->impl->autocapital_type != autocapital_type)
1320 context_scim->impl->autocapital_type = autocapital_type; 1319 context_scim->impl->autocapital_type = autocapital_type;
@@ -1337,11 +1336,11 @@ isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapi
1337 */ 1336 */
1338 1337
1339EAPI Eina_Bool 1338EAPI Eina_Bool
1340isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event) 1339isf_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
1341{ 1340{
1342 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1341 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1343 1342
1344 EcoreIMFContextISF *ic = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); 1343 EcoreIMFContextISF *ic = (EcoreIMFContextISF*)ecore_imf_context_data_get(ctx);
1345 Eina_Bool ret = EINA_FALSE; 1344 Eina_Bool ret = EINA_FALSE;
1346 1345
1347 if (ic == NULL || ic->impl == NULL) 1346 if (ic == NULL || ic->impl == NULL)
@@ -1352,7 +1351,7 @@ isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type,
1352 if (type == ECORE_IMF_EVENT_KEY_DOWN) 1351 if (type == ECORE_IMF_EVENT_KEY_DOWN)
1353 { 1352 {
1354 Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event; 1353 Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event;
1355 scim_string_to_key (key, ev->key); 1354 scim_string_to_key(key, ev->key);
1356 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask; 1355 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask;
1357 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask; 1356 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask;
1358 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) key.mask |=SCIM_KEY_AltMask; 1357 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) key.mask |=SCIM_KEY_AltMask;
@@ -1362,7 +1361,7 @@ isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type,
1362 else if (type == ECORE_IMF_EVENT_KEY_UP) 1361 else if (type == ECORE_IMF_EVENT_KEY_UP)
1363 { 1362 {
1364 Ecore_IMF_Event_Key_Up *ev = (Ecore_IMF_Event_Key_Up *)event; 1363 Ecore_IMF_Event_Key_Up *ev = (Ecore_IMF_Event_Key_Up *)event;
1365 scim_string_to_key (key, ev->key); 1364 scim_string_to_key(key, ev->key);
1366 key.mask = SCIM_KEY_ReleaseMask; 1365 key.mask = SCIM_KEY_ReleaseMask;
1367 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask; 1366 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask;
1368 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask; 1367 if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask;
@@ -1377,264 +1376,264 @@ isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type,
1377 1376
1378 key.mask &= _valid_key_mask; 1377 key.mask &= _valid_key_mask;
1379 1378
1380 _panel_client.prepare (ic->id); 1379 _panel_client.prepare(ic->id);
1381 1380
1382 ret = EINA_TRUE; 1381 ret = EINA_TRUE;
1383 if (!filter_hotkeys (ic, key)) 1382 if (!filter_hotkeys(ic, key))
1384 { 1383 {
1385 if (!_focused_ic || !_focused_ic->impl->is_on || 1384 if (!_focused_ic || !_focused_ic->impl->is_on ||
1386 !_focused_ic->impl->si->process_key_event (key)) 1385 !_focused_ic->impl->si->process_key_event(key))
1387 ret = EINA_FALSE; 1386 ret = EINA_FALSE;
1388 } 1387 }
1389 1388
1390 _panel_client.send (); 1389 _panel_client.send();
1391 1390
1392 return ret; 1391 return ret;
1393} 1392}
1394 1393
1395/* Panel Slot functions */ 1394/* Panel Slot functions */
1396static void 1395static void
1397panel_slot_reload_config (int context __UNUSED__) 1396panel_slot_reload_config(int context __UNUSED__)
1398{ 1397{
1399 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1398 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1400 _config->reload (); 1399 _config->reload();
1401} 1400}
1402 1401
1403static void 1402static void
1404panel_slot_exit (int /* context */) 1403panel_slot_exit(int /* context */)
1405{ 1404{
1406 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1405 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1407 1406
1408 finalize (); 1407 finalize();
1409} 1408}
1410 1409
1411static void 1410static void
1412panel_slot_update_lookup_table_page_size (int context, int page_size) 1411panel_slot_update_lookup_table_page_size(int context, int page_size)
1413{ 1412{
1414 EcoreIMFContextISF *ic = find_ic (context); 1413 EcoreIMFContextISF *ic = find_ic(context);
1415 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " page_size=" << page_size << " ic=" << ic << "\n"; 1414 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " page_size=" << page_size << " ic=" << ic << "\n";
1416 if (ic && ic->impl) 1415 if (ic && ic->impl)
1417 { 1416 {
1418 _panel_client.prepare (ic->id); 1417 _panel_client.prepare(ic->id);
1419 ic->impl->si->update_lookup_table_page_size (page_size); 1418 ic->impl->si->update_lookup_table_page_size(page_size);
1420 _panel_client.send (); 1419 _panel_client.send();
1421 } 1420 }
1422} 1421}
1423 1422
1424static void 1423static void
1425panel_slot_lookup_table_page_up (int context) 1424panel_slot_lookup_table_page_up(int context)
1426{ 1425{
1427 EcoreIMFContextISF *ic = find_ic (context); 1426 EcoreIMFContextISF *ic = find_ic(context);
1428 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; 1427 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n";
1429 if (ic && ic->impl) 1428 if (ic && ic->impl)
1430 { 1429 {
1431 _panel_client.prepare (ic->id); 1430 _panel_client.prepare(ic->id);
1432 ic->impl->si->lookup_table_page_up (); 1431 ic->impl->si->lookup_table_page_up();
1433 _panel_client.send (); 1432 _panel_client.send();
1434 } 1433 }
1435} 1434}
1436 1435
1437static void 1436static void
1438panel_slot_lookup_table_page_down (int context) 1437panel_slot_lookup_table_page_down(int context)
1439{ 1438{
1440 EcoreIMFContextISF *ic = find_ic (context); 1439 EcoreIMFContextISF *ic = find_ic(context);
1441 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; 1440 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n";
1442 if (ic && ic->impl) 1441 if (ic && ic->impl)
1443 { 1442 {
1444 _panel_client.prepare (ic->id); 1443 _panel_client.prepare(ic->id);
1445 ic->impl->si->lookup_table_page_down (); 1444 ic->impl->si->lookup_table_page_down();
1446 _panel_client.send (); 1445 _panel_client.send();
1447 } 1446 }
1448} 1447}
1449 1448
1450static void 1449static void
1451panel_slot_trigger_property (int context, const String &property) 1450panel_slot_trigger_property(int context, const String &property)
1452{ 1451{
1453 EcoreIMFContextISF *ic = find_ic (context); 1452 EcoreIMFContextISF *ic = find_ic(context);
1454 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " property=" << property << " ic=" << ic << "\n"; 1453 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " property=" << property << " ic=" << ic << "\n";
1455 if (ic && ic->impl) 1454 if (ic && ic->impl)
1456 { 1455 {
1457 _panel_client.prepare (ic->id); 1456 _panel_client.prepare(ic->id);
1458 ic->impl->si->trigger_property (property); 1457 ic->impl->si->trigger_property(property);
1459 _panel_client.send (); 1458 _panel_client.send();
1460 } 1459 }
1461} 1460}
1462 1461
1463static void 1462static void
1464panel_slot_process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans) 1463panel_slot_process_helper_event(int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans)
1465{ 1464{
1466 EcoreIMFContextISF *ic = find_ic (context); 1465 EcoreIMFContextISF *ic = find_ic(context);
1467 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " target=" << target_uuid 1466 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " target=" << target_uuid
1468 << " helper=" << helper_uuid << " ic=" << ic << " ic->impl=" << (ic ? ic->impl : 0) << " ic-uuid=" 1467 << " helper=" << helper_uuid << " ic=" << ic << " ic->impl=" << (ic ? ic->impl : 0) << " ic-uuid="
1469 << ((ic && ic->impl) ? ic->impl->si->get_factory_uuid () : "" ) << "\n"; 1468 << ((ic && ic->impl) ? ic->impl->si->get_factory_uuid() : "" ) << "\n";
1470 if (ic && ic->impl && ic->impl->si->get_factory_uuid () == target_uuid) 1469 if (ic && ic->impl && ic->impl->si->get_factory_uuid() == target_uuid)
1471 { 1470 {
1472 _panel_client.prepare (ic->id); 1471 _panel_client.prepare(ic->id);
1473 SCIM_DEBUG_FRONTEND(2) << "call process_helper_event\n"; 1472 SCIM_DEBUG_FRONTEND(2) << "call process_helper_event\n";
1474 ic->impl->si->process_helper_event (helper_uuid, trans); 1473 ic->impl->si->process_helper_event(helper_uuid, trans);
1475 _panel_client.send (); 1474 _panel_client.send();
1476 } 1475 }
1477} 1476}
1478 1477
1479static void 1478static void
1480panel_slot_move_preedit_caret (int context, int caret_pos) 1479panel_slot_move_preedit_caret(int context, int caret_pos)
1481{ 1480{
1482 EcoreIMFContextISF *ic = find_ic (context); 1481 EcoreIMFContextISF *ic = find_ic(context);
1483 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " caret=" << caret_pos << " ic=" << ic << "\n"; 1482 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " caret=" << caret_pos << " ic=" << ic << "\n";
1484 if (ic && ic->impl) 1483 if (ic && ic->impl)
1485 { 1484 {
1486 _panel_client.prepare (ic->id); 1485 _panel_client.prepare(ic->id);
1487 ic->impl->si->move_preedit_caret (caret_pos); 1486 ic->impl->si->move_preedit_caret(caret_pos);
1488 _panel_client.send (); 1487 _panel_client.send();
1489 } 1488 }
1490} 1489}
1491 1490
1492static void 1491static void
1493panel_slot_select_candidate (int context, int cand_index) 1492panel_slot_select_candidate(int context, int cand_index)
1494{ 1493{
1495 EcoreIMFContextISF *ic = find_ic (context); 1494 EcoreIMFContextISF *ic = find_ic(context);
1496 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " candidate=" << cand_index << " ic=" << ic << "\n"; 1495 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " candidate=" << cand_index << " ic=" << ic << "\n";
1497 if (ic && ic->impl) 1496 if (ic && ic->impl)
1498 { 1497 {
1499 _panel_client.prepare (ic->id); 1498 _panel_client.prepare(ic->id);
1500 ic->impl->si->select_candidate (cand_index); 1499 ic->impl->si->select_candidate(cand_index);
1501 _panel_client.send (); 1500 _panel_client.send();
1502 } 1501 }
1503} 1502}
1504 1503
1505static void 1504static void
1506panel_slot_process_key_event (int context, const KeyEvent &key) 1505panel_slot_process_key_event(int context, const KeyEvent &key)
1507{ 1506{
1508 EcoreIMFContextISF *ic = find_ic (context); 1507 EcoreIMFContextISF *ic = find_ic(context);
1509 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string () << " ic=" << ic << "\n"; 1508 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string() << " ic=" << ic << "\n";
1510 1509
1511 if (ic && ic->impl && ic->impl->client_canvas) 1510 if (ic && ic->impl && ic->impl->client_canvas)
1512 feed_key_event(ic->impl->client_canvas, key.get_key_string().c_str(), EINA_FALSE); 1511 feed_key_event(ic->impl->client_canvas, key.get_key_string().c_str(), EINA_FALSE);
1513} 1512}
1514 1513
1515static void 1514static void
1516panel_slot_commit_string (int context, const WideString &wstr) 1515panel_slot_commit_string(int context, const WideString &wstr)
1517{ 1516{
1518 EcoreIMFContextISF *ic = find_ic (context); 1517 EcoreIMFContextISF *ic = find_ic(context);
1519 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " str=" << utf8_wcstombs (wstr) << " ic=" << ic << "\n"; 1518 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " str=" << utf8_wcstombs(wstr) << " ic=" << ic << "\n";
1520 1519
1521 if (ic && ic->impl) 1520 if (ic && ic->impl)
1522 { 1521 {
1523 if (_focused_ic != ic) 1522 if (_focused_ic != ic)
1524 return; 1523 return;
1525 1524
1526 ecore_imf_context_commit_event_add (ic->ctx, utf8_wcstombs (wstr).c_str ()); 1525 ecore_imf_context_commit_event_add(ic->ctx, utf8_wcstombs(wstr).c_str());
1527 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); 1526 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str());
1528 } 1527 }
1529} 1528}
1530 1529
1531static void 1530static void
1532panel_slot_forward_key_event (int context, const KeyEvent &key) 1531panel_slot_forward_key_event(int context, const KeyEvent &key)
1533{ 1532{
1534 EcoreIMFContextISF *ic = find_ic (context); 1533 EcoreIMFContextISF *ic = find_ic(context);
1535 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string () << " ic=" << ic << "\n"; 1534 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string() << " ic=" << ic << "\n";
1536 1535
1537 if (ic && ic->impl && ic->impl->client_canvas) 1536 if (ic && ic->impl && ic->impl->client_canvas)
1538 feed_key_event (ic->impl->client_canvas, key.get_key_string ().c_str (), EINA_TRUE); 1537 feed_key_event(ic->impl->client_canvas, key.get_key_string().c_str(), EINA_TRUE);
1539} 1538}
1540 1539
1541static void 1540static void
1542panel_slot_request_help (int context) 1541panel_slot_request_help(int context)
1543{ 1542{
1544 EcoreIMFContextISF *ic = find_ic (context); 1543 EcoreIMFContextISF *ic = find_ic(context);
1545 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; 1544 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n";
1546 1545
1547 if (ic && ic->impl) 1546 if (ic && ic->impl)
1548 { 1547 {
1549 _panel_client.prepare (ic->id); 1548 _panel_client.prepare(ic->id);
1550 panel_req_show_help (ic); 1549 panel_req_show_help(ic);
1551 _panel_client.send (); 1550 _panel_client.send();
1552 } 1551 }
1553} 1552}
1554 1553
1555static void 1554static void
1556panel_slot_request_factory_menu (int context) 1555panel_slot_request_factory_menu(int context)
1557{ 1556{
1558 EcoreIMFContextISF *ic = find_ic (context); 1557 EcoreIMFContextISF *ic = find_ic(context);
1559 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; 1558 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n";
1560 1559
1561 if (ic && ic->impl) 1560 if (ic && ic->impl)
1562 { 1561 {
1563 _panel_client.prepare (ic->id); 1562 _panel_client.prepare(ic->id);
1564 panel_req_show_factory_menu (ic); 1563 panel_req_show_factory_menu(ic);
1565 _panel_client.send (); 1564 _panel_client.send();
1566 } 1565 }
1567} 1566}
1568 1567
1569static void 1568static void
1570panel_slot_change_factory (int context, const String &uuid) 1569panel_slot_change_factory(int context, const String &uuid)
1571{ 1570{
1572 EcoreIMFContextISF *ic = find_ic (context); 1571 EcoreIMFContextISF *ic = find_ic(context);
1573 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " factory=" << uuid << " ic=" << ic << "\n"; 1572 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " factory=" << uuid << " ic=" << ic << "\n";
1574 1573
1575 if (ic && ic->impl) 1574 if (ic && ic->impl)
1576 { 1575 {
1577 ic->impl->si->reset (); 1576 ic->impl->si->reset();
1578 _panel_client.prepare (ic->id); 1577 _panel_client.prepare(ic->id);
1579 open_specific_factory (ic, uuid); 1578 open_specific_factory(ic, uuid);
1580 _panel_client.send (); 1579 _panel_client.send();
1581 } 1580 }
1582} 1581}
1583 1582
1584/* Panel Requestion functions. */ 1583/* Panel Requestion functions. */
1585static void 1584static void
1586panel_req_show_help (EcoreIMFContextISF *ic) 1585panel_req_show_help(EcoreIMFContextISF *ic)
1587{ 1586{
1588 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1587 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1589 1588
1590 String help; 1589 String help;
1591 1590
1592 help = String ("Smart Common Input Method platform ") + 1591 help = String("Smart Common Input Method platform ") +
1593 //String (SCIM_VERSION) + 1592 //String(SCIM_VERSION) +
1594 String ("\n(C) 2002-2005 James Su <suzhe@tsinghua.org.cn>\n\n"); 1593 String("\n(C) 2002-2005 James Su <suzhe@tsinghua.org.cn>\n\n");
1595 1594
1596 if (ic && ic->impl) 1595 if (ic && ic->impl)
1597 { 1596 {
1598 IMEngineFactoryPointer sf = _backend->get_factory (ic->impl->si->get_factory_uuid ()); 1597 IMEngineFactoryPointer sf = _backend->get_factory(ic->impl->si->get_factory_uuid());
1599 if (sf) 1598 if (sf)
1600 { 1599 {
1601 help += utf8_wcstombs (sf->get_name ()); 1600 help += utf8_wcstombs(sf->get_name());
1602 help += String (":\n\n"); 1601 help += String(":\n\n");
1603 1602
1604 help += utf8_wcstombs (sf->get_help ()); 1603 help += utf8_wcstombs(sf->get_help());
1605 help += String ("\n\n"); 1604 help += String("\n\n");
1606 1605
1607 help += utf8_wcstombs (sf->get_credits ()); 1606 help += utf8_wcstombs(sf->get_credits());
1608 } 1607 }
1609 _panel_client.show_help (ic->id, help); 1608 _panel_client.show_help(ic->id, help);
1610 } 1609 }
1611} 1610}
1612 1611
1613static void 1612static void
1614panel_req_show_factory_menu (EcoreIMFContextISF *ic) 1613panel_req_show_factory_menu(EcoreIMFContextISF *ic)
1615{ 1614{
1616 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1615 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1617 1616
1618 std::vector<IMEngineFactoryPointer> factories; 1617 std::vector<IMEngineFactoryPointer> factories;
1619 std::vector <PanelFactoryInfo> menu; 1618 std::vector <PanelFactoryInfo> menu;
1620 1619
1621 _backend->get_factories_for_encoding (factories, "UTF-8"); 1620 _backend->get_factories_for_encoding(factories, "UTF-8");
1622 1621
1623 for (size_t i = 0; i < factories.size (); ++ i) 1622 for (size_t i = 0; i < factories.size(); ++ i)
1624 { 1623 {
1625 menu.push_back (PanelFactoryInfo ( 1624 menu.push_back(PanelFactoryInfo(
1626 factories [i]->get_uuid (), 1625 factories [i]->get_uuid(),
1627 utf8_wcstombs (factories [i]->get_name ()), 1626 utf8_wcstombs(factories [i]->get_name()),
1628 factories [i]->get_language (), 1627 factories [i]->get_language(),
1629 factories [i]->get_icon_file ())); 1628 factories [i]->get_icon_file()));
1630 } 1629 }
1631 1630
1632 if (menu.size ()) 1631 if (menu.size())
1633 _panel_client.show_factory_menu (ic->id, menu); 1632 _panel_client.show_factory_menu(ic->id, menu);
1634} 1633}
1635 1634
1636static void 1635static void
1637panel_req_update_factory_info (EcoreIMFContextISF *ic) 1636panel_req_update_factory_info(EcoreIMFContextISF *ic)
1638{ 1637{
1639 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1638 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1640 1639
@@ -1643,160 +1642,160 @@ panel_req_update_factory_info (EcoreIMFContextISF *ic)
1643 PanelFactoryInfo info; 1642 PanelFactoryInfo info;
1644 if (ic->impl->is_on) 1643 if (ic->impl->is_on)
1645 { 1644 {
1646 IMEngineFactoryPointer sf = _backend->get_factory (ic->impl->si->get_factory_uuid ()); 1645 IMEngineFactoryPointer sf = _backend->get_factory(ic->impl->si->get_factory_uuid());
1647 if (sf) 1646 if (sf)
1648 info = PanelFactoryInfo (sf->get_uuid (), utf8_wcstombs (sf->get_name ()), sf->get_language (), sf->get_icon_file ()); 1647 info = PanelFactoryInfo(sf->get_uuid(), utf8_wcstombs(sf->get_name()), sf->get_language(), sf->get_icon_file());
1649 } 1648 }
1650 else 1649 else
1651 { 1650 {
1652 info = PanelFactoryInfo (String (""), String ("English/Keyboard"), String ("C"), ""); 1651 info = PanelFactoryInfo(String(""), String("English/Keyboard"), String("C"), "");
1653 } 1652 }
1654 _panel_client.update_factory_info (ic->id, info); 1653 _panel_client.update_factory_info(ic->id, info);
1655 } 1654 }
1656} 1655}
1657 1656
1658static void 1657static void
1659panel_req_focus_in (EcoreIMFContextISF *ic) 1658panel_req_focus_in(EcoreIMFContextISF *ic)
1660{ 1659{
1661 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1660 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1662 1661
1663 _panel_client.focus_in (ic->id, ic->impl->si->get_factory_uuid ()); 1662 _panel_client.focus_in(ic->id, ic->impl->si->get_factory_uuid());
1664} 1663}
1665 1664
1666static void 1665static void
1667panel_req_update_spot_location (EcoreIMFContextISF *ic) 1666panel_req_update_spot_location(EcoreIMFContextISF *ic)
1668{ 1667{
1669 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1668 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1670 1669
1671 _panel_client.update_spot_location (ic->id, ic->impl->cursor_x, ic->impl->cursor_y); 1670 _panel_client.update_spot_location(ic->id, ic->impl->cursor_x, ic->impl->cursor_y);
1672} 1671}
1673 1672
1674static bool 1673static bool
1675filter_hotkeys (EcoreIMFContextISF *ic, const KeyEvent &key) 1674filter_hotkeys(EcoreIMFContextISF *ic, const KeyEvent &key)
1676{ 1675{
1677 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1676 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1678 1677
1679 bool ret = false; 1678 bool ret = false;
1680 1679
1681 _frontend_hotkey_matcher.push_key_event (key); 1680 _frontend_hotkey_matcher.push_key_event(key);
1682 _imengine_hotkey_matcher.push_key_event (key); 1681 _imengine_hotkey_matcher.push_key_event(key);
1683 1682
1684 FrontEndHotkeyAction hotkey_action = _frontend_hotkey_matcher.get_match_result (); 1683 FrontEndHotkeyAction hotkey_action = _frontend_hotkey_matcher.get_match_result();
1685 1684
1686 if (hotkey_action == SCIM_FRONTEND_HOTKEY_TRIGGER) 1685 if (hotkey_action == SCIM_FRONTEND_HOTKEY_TRIGGER)
1687 { 1686 {
1688 if (!ic->impl->is_on) 1687 if (!ic->impl->is_on)
1689 turn_on_ic (ic); 1688 turn_on_ic(ic);
1690 else 1689 else
1691 turn_off_ic (ic); 1690 turn_off_ic(ic);
1692 ret = true; 1691 ret = true;
1693 } 1692 }
1694 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_ON) 1693 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_ON)
1695 { 1694 {
1696 if (!ic->impl->is_on) 1695 if (!ic->impl->is_on)
1697 turn_on_ic (ic); 1696 turn_on_ic(ic);
1698 ret = true; 1697 ret = true;
1699 } 1698 }
1700 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_OFF) 1699 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_OFF)
1701 { 1700 {
1702 if (ic->impl->is_on) 1701 if (ic->impl->is_on)
1703 turn_off_ic (ic); 1702 turn_off_ic(ic);
1704 ret = true; 1703 ret = true;
1705 } 1704 }
1706 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_NEXT_FACTORY) 1705 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_NEXT_FACTORY)
1707 { 1706 {
1708 open_next_factory (ic); 1707 open_next_factory(ic);
1709 ret = true; 1708 ret = true;
1710 } 1709 }
1711 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_PREVIOUS_FACTORY) 1710 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_PREVIOUS_FACTORY)
1712 { 1711 {
1713 open_previous_factory (ic); 1712 open_previous_factory(ic);
1714 ret = true; 1713 ret = true;
1715 } 1714 }
1716 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU) 1715 else if (hotkey_action == SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU)
1717 { 1716 {
1718 panel_req_show_factory_menu (ic); 1717 panel_req_show_factory_menu(ic);
1719 ret = true; 1718 ret = true;
1720 } 1719 }
1721 else if (_imengine_hotkey_matcher.is_matched ()) 1720 else if (_imengine_hotkey_matcher.is_matched())
1722 { 1721 {
1723 String sfid = _imengine_hotkey_matcher.get_match_result (); 1722 String sfid = _imengine_hotkey_matcher.get_match_result();
1724 open_specific_factory (ic, sfid); 1723 open_specific_factory(ic, sfid);
1725 ret = true; 1724 ret = true;
1726 } 1725 }
1727 return ret; 1726 return ret;
1728} 1727}
1729 1728
1730static bool 1729static bool
1731panel_initialize (void) 1730panel_initialize(void)
1732{ 1731{
1733 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1732 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1734 1733
1735 String display_name; 1734 String display_name;
1736 { 1735 {
1737 const char *p = getenv ("DISPLAY"); 1736 const char *p = getenv("DISPLAY");
1738 if (p) display_name = String (p); 1737 if (p) display_name = String(p);
1739 } 1738 }
1740 1739
1741 if (_panel_client.open_connection (_config->get_name (), display_name) >= 0) 1740 if (_panel_client.open_connection(_config->get_name(), display_name) >= 0)
1742 { 1741 {
1743 int fd = _panel_client.get_connection_number (); 1742 int fd = _panel_client.get_connection_number();
1744 1743
1745 _panel_iochannel_read_handler = ecore_main_fd_handler_add (fd, ECORE_FD_READ, panel_iochannel_handler, NULL, NULL, NULL); 1744 _panel_iochannel_read_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, panel_iochannel_handler, NULL, NULL, NULL);
1746 1745
1747 SCIM_DEBUG_FRONTEND(2) << " Panel FD= " << fd << "\n"; 1746 SCIM_DEBUG_FRONTEND(2) << " Panel FD= " << fd << "\n";
1748 1747
1749 return true; 1748 return true;
1750 } 1749 }
1751 std::cerr << "panel_initialize () failed!!!\n"; 1750 std::cerr << "panel_initialize() failed!!!\n";
1752 return false; 1751 return false;
1753} 1752}
1754 1753
1755static void 1754static void
1756panel_finalize (void) 1755panel_finalize(void)
1757{ 1756{
1758 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1757 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1759 1758
1760 _panel_client.close_connection (); 1759 _panel_client.close_connection();
1761 1760
1762 if (_panel_iochannel_read_handler) 1761 if (_panel_iochannel_read_handler)
1763 { 1762 {
1764 ecore_main_fd_handler_del (_panel_iochannel_read_handler); 1763 ecore_main_fd_handler_del(_panel_iochannel_read_handler);
1765 _panel_iochannel_read_handler = 0; 1764 _panel_iochannel_read_handler = 0;
1766 } 1765 }
1767 1766
1768 if (_panel_iochannel_err_handler) 1767 if (_panel_iochannel_err_handler)
1769 { 1768 {
1770 ecore_main_fd_handler_del (_panel_iochannel_err_handler); 1769 ecore_main_fd_handler_del(_panel_iochannel_err_handler);
1771 _panel_iochannel_err_handler = 0; 1770 _panel_iochannel_err_handler = 0;
1772 } 1771 }
1773} 1772}
1774 1773
1775static Eina_Bool 1774static Eina_Bool
1776panel_iochannel_handler (void *data __UNUSED__, Ecore_Fd_Handler *fd_handler) 1775panel_iochannel_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler)
1777{ 1776{
1778 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1777 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1779 1778
1780 if (fd_handler == _panel_iochannel_read_handler) 1779 if (fd_handler == _panel_iochannel_read_handler)
1781 { 1780 {
1782 if (!_panel_client.filter_event ()) 1781 if (!_panel_client.filter_event())
1783 { 1782 {
1784 panel_finalize (); 1783 panel_finalize();
1785 panel_initialize (); 1784 panel_initialize();
1786 return ECORE_CALLBACK_CANCEL; 1785 return ECORE_CALLBACK_CANCEL;
1787 } 1786 }
1788 } 1787 }
1789 else if (fd_handler == _panel_iochannel_err_handler) 1788 else if (fd_handler == _panel_iochannel_err_handler)
1790 { 1789 {
1791 panel_finalize (); 1790 panel_finalize();
1792 panel_initialize (); 1791 panel_initialize();
1793 return ECORE_CALLBACK_CANCEL; 1792 return ECORE_CALLBACK_CANCEL;
1794 } 1793 }
1795 return ECORE_CALLBACK_RENEW; 1794 return ECORE_CALLBACK_RENEW;
1796} 1795}
1797 1796
1798static void 1797static void
1799turn_on_ic (EcoreIMFContextISF *ic) 1798turn_on_ic(EcoreIMFContextISF *ic)
1800{ 1799{
1801 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1800 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1802 1801
@@ -1806,25 +1805,25 @@ turn_on_ic (EcoreIMFContextISF *ic)
1806 1805
1807 if (ic == _focused_ic) 1806 if (ic == _focused_ic)
1808 { 1807 {
1809 panel_req_focus_in (ic); 1808 panel_req_focus_in(ic);
1810 panel_req_update_spot_location (ic); 1809 panel_req_update_spot_location(ic);
1811 panel_req_update_factory_info (ic); 1810 panel_req_update_factory_info(ic);
1812 _panel_client.turn_on (ic->id); 1811 _panel_client.turn_on(ic->id);
1813 _panel_client.hide_preedit_string (ic->id); 1812 _panel_client.hide_preedit_string(ic->id);
1814 _panel_client.hide_aux_string (ic->id); 1813 _panel_client.hide_aux_string(ic->id);
1815 _panel_client.hide_lookup_table (ic->id); 1814 _panel_client.hide_lookup_table(ic->id);
1816 ic->impl->si->focus_in (); 1815 ic->impl->si->focus_in();
1817 } 1816 }
1818 1817
1819 //Record the IC on/off status 1818 //Record the IC on/off status
1820 if (_shared_input_method) 1819 if (_shared_input_method)
1821 _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), true); 1820 _config->write(String(SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), true);
1822 1821
1823 if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) 1822 if (ic->impl->use_preedit && ic->impl->preedit_string.length())
1824 { 1823 {
1825 ecore_imf_context_preedit_start_event_add (ic->ctx); 1824 ecore_imf_context_preedit_start_event_add(ic->ctx);
1826 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); 1825 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL);
1827 ecore_imf_context_preedit_changed_event_add (ic->ctx); 1826 ecore_imf_context_preedit_changed_event_add(ic->ctx);
1828 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 1827 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
1829 ic->impl->preedit_started = true; 1828 ic->impl->preedit_started = true;
1830 } 1829 }
@@ -1832,7 +1831,7 @@ turn_on_ic (EcoreIMFContextISF *ic)
1832} 1831}
1833 1832
1834static void 1833static void
1835turn_off_ic (EcoreIMFContextISF *ic) 1834turn_off_ic(EcoreIMFContextISF *ic)
1836{ 1835{
1837 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1836 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1838 1837
@@ -1842,21 +1841,21 @@ turn_off_ic (EcoreIMFContextISF *ic)
1842 1841
1843 if (ic == _focused_ic) 1842 if (ic == _focused_ic)
1844 { 1843 {
1845 ic->impl->si->focus_out (); 1844 ic->impl->si->focus_out();
1846 1845
1847 panel_req_update_factory_info (ic); 1846 panel_req_update_factory_info(ic);
1848 _panel_client.turn_off (ic->id); 1847 _panel_client.turn_off(ic->id);
1849 } 1848 }
1850 1849
1851 //Record the IC on/off status 1850 //Record the IC on/off status
1852 if (_shared_input_method) 1851 if (_shared_input_method)
1853 _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false); 1852 _config->write(String(SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false);
1854 1853
1855 if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) 1854 if (ic->impl->use_preedit && ic->impl->preedit_string.length())
1856 { 1855 {
1857 ecore_imf_context_preedit_changed_event_add (ic->ctx); 1856 ecore_imf_context_preedit_changed_event_add(ic->ctx);
1858 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 1857 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
1859 ecore_imf_context_preedit_end_event_add (ic->ctx); 1858 ecore_imf_context_preedit_end_event_add(ic->ctx);
1860 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); 1859 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL);
1861 ic->impl->preedit_started = false; 1860 ic->impl->preedit_started = false;
1862 } 1861 }
@@ -1864,7 +1863,7 @@ turn_off_ic (EcoreIMFContextISF *ic)
1864} 1863}
1865 1864
1866static void 1865static void
1867set_ic_capabilities (EcoreIMFContextISF *ic) 1866set_ic_capabilities(EcoreIMFContextISF *ic)
1868{ 1867{
1869 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1868 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1870 1869
@@ -1875,12 +1874,12 @@ set_ic_capabilities (EcoreIMFContextISF *ic)
1875 if (!_on_the_spot || !ic->impl->use_preedit) 1874 if (!_on_the_spot || !ic->impl->use_preedit)
1876 cap -= SCIM_CLIENT_CAP_ONTHESPOT_PREEDIT; 1875 cap -= SCIM_CLIENT_CAP_ONTHESPOT_PREEDIT;
1877 1876
1878 ic->impl->si->update_client_capabilities (cap); 1877 ic->impl->si->update_client_capabilities(cap);
1879 } 1878 }
1880} 1879}
1881 1880
1882static bool 1881static bool
1883check_socket_frontend (void) 1882check_socket_frontend(void)
1884{ 1883{
1885 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 1884 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
1886 1885
@@ -1889,23 +1888,23 @@ check_socket_frontend (void)
1889 1888
1890 uint32 magic; 1889 uint32 magic;
1891 1890
1892 address.set_address (scim_get_default_socket_frontend_address ()); 1891 address.set_address(scim_get_default_socket_frontend_address());
1893 1892
1894 if (!client.connect (address)) 1893 if (!client.connect(address))
1895 return false; 1894 return false;
1896 1895
1897 if (!scim_socket_open_connection (magic, 1896 if (!scim_socket_open_connection(magic,
1898 String ("ConnectionTester"), 1897 String("ConnectionTester"),
1899 String ("SocketFrontEnd"), 1898 String("SocketFrontEnd"),
1900 client, 1899 client,
1901 1000)) 1900 1000))
1902 return false; 1901 return false;
1903 1902
1904 return true; 1903 return true;
1905} 1904}
1906 1905
1907void 1906void
1908initialize (void) 1907initialize(void)
1909{ 1908{
1910 std::vector<String> config_list; 1909 std::vector<String> config_list;
1911 std::vector<String> engine_list; 1910 std::vector<String> engine_list;
@@ -1924,31 +1923,31 @@ initialize (void)
1924 SCIM_DEBUG_FRONTEND(1) << "Initializing Ecore SCIM IMModule...\n"; 1923 SCIM_DEBUG_FRONTEND(1) << "Initializing Ecore SCIM IMModule...\n";
1925 1924
1926 // Get system language. 1925 // Get system language.
1927 _language = scim_get_locale_language (scim_get_current_locale ()); 1926 _language = scim_get_locale_language(scim_get_current_locale());
1928 1927
1929 if (socket) 1928 if (socket)
1930 { 1929 {
1931 // If no Socket FrontEnd is running, then launch one. 1930 // If no Socket FrontEnd is running, then launch one.
1932 // And set manual to false. 1931 // And set manual to false.
1933 bool check_result = check_socket_frontend (); 1932 bool check_result = check_socket_frontend();
1934 if (!check_result) 1933 if (!check_result)
1935 { 1934 {
1936 std::cerr << "Launching a SCIM daemon with Socket FrontEnd...\n"; 1935 std::cerr << "Launching a SCIM daemon with Socket FrontEnd...\n";
1937 //get modules list 1936 //get modules list
1938 scim_get_imengine_module_list (engine_list); 1937 scim_get_imengine_module_list(engine_list);
1939 1938
1940 for (it = engine_list.begin (); it != engine_list.end (); it++) 1939 for (it = engine_list.begin(); it != engine_list.end(); it++)
1941 { 1940 {
1942 if (*it != "socket") 1941 if (*it != "socket")
1943 load_engine_list.push_back (*it); 1942 load_engine_list.push_back(*it);
1944 } 1943 }
1945 1944
1946 const char *new_argv [] = { "--no-stay", 0 }; 1945 const char *new_argv [] = { "--no-stay", 0 };
1947 scim_launch (true, 1946 scim_launch(true,
1948 config_module_name, 1947 config_module_name,
1949 (load_engine_list.size () ? scim_combine_string_list (load_engine_list, ',') : "none"), 1948 (load_engine_list.size() ? scim_combine_string_list(load_engine_list, ',') : "none"),
1950 "socket", 1949 "socket",
1951 (char **)new_argv); 1950 (char **)new_argv);
1952 manual = false; 1951 manual = false;
1953 } 1952 }
1954 1953
@@ -1961,12 +1960,12 @@ initialize (void)
1961 if (check_result) 1960 if (check_result)
1962 { 1961 {
1963 config_module_name = "socket"; 1962 config_module_name = "socket";
1964 load_engine_list.clear (); 1963 load_engine_list.clear();
1965 load_engine_list.push_back ("socket"); 1964 load_engine_list.push_back("socket");
1966 break; 1965 break;
1967 } 1966 }
1968 scim_usleep (50000); 1967 scim_usleep(50000);
1969 check_result = check_socket_frontend (); 1968 check_result = check_socket_frontend();
1970 } 1969 }
1971 } 1970 }
1972 } 1971 }
@@ -1975,69 +1974,69 @@ initialize (void)
1975 { 1974 {
1976 //load config module 1975 //load config module
1977 SCIM_DEBUG_FRONTEND(1) << "Loading Config module: " << config_module_name << "...\n"; 1976 SCIM_DEBUG_FRONTEND(1) << "Loading Config module: " << config_module_name << "...\n";
1978 _config_module = new ConfigModule (config_module_name); 1977 _config_module = new ConfigModule(config_module_name);
1979 1978
1980 //create config instance 1979 //create config instance
1981 if (_config_module != NULL && _config_module->valid ()) 1980 if (_config_module != NULL && _config_module->valid())
1982 _config = _config_module->create_config (); 1981 _config = _config_module->create_config();
1983 } 1982 }
1984 1983
1985 if (_config.null ()) 1984 if (_config.null())
1986 { 1985 {
1987 SCIM_DEBUG_FRONTEND(1) << "Config module cannot be loaded, using dummy Config.\n"; 1986 SCIM_DEBUG_FRONTEND(1) << "Config module cannot be loaded, using dummy Config.\n";
1988 1987
1989 if (_config_module) delete _config_module; 1988 if (_config_module) delete _config_module;
1990 _config_module = NULL; 1989 _config_module = NULL;
1991 1990
1992 _config = new DummyConfig (); 1991 _config = new DummyConfig();
1993 config_module_name = "dummy"; 1992 config_module_name = "dummy";
1994 } 1993 }
1995 1994
1996 reload_config_callback (_config); 1995 reload_config_callback(_config);
1997 _config->signal_connect_reload (slot (reload_config_callback)); 1996 _config->signal_connect_reload(slot(reload_config_callback));
1998 1997
1999 // create backend 1998 // create backend
2000 _backend = new CommonBackEnd (_config, load_engine_list.size () ? load_engine_list : engine_list); 1999 _backend = new CommonBackEnd(_config, load_engine_list.size() ? load_engine_list : engine_list);
2001 2000
2002 if (_backend.null ()) 2001 if (_backend.null())
2003 std::cerr << "Cannot create BackEnd Object!\n"; 2002 std::cerr << "Cannot create BackEnd Object!\n";
2004 else 2003 else
2005 _fallback_factory = _backend->get_factory (SCIM_COMPOSE_KEY_FACTORY_UUID); 2004 _fallback_factory = _backend->get_factory(SCIM_COMPOSE_KEY_FACTORY_UUID);
2006 2005
2007 if (_fallback_factory.null ()) 2006 if (_fallback_factory.null())
2008 _fallback_factory = new DummyIMEngineFactory (); 2007 _fallback_factory = new DummyIMEngineFactory();
2009 2008
2010 _fallback_instance = _fallback_factory->create_instance (String ("UTF-8"), 0); 2009 _fallback_instance = _fallback_factory->create_instance(String("UTF-8"), 0);
2011 _fallback_instance->signal_connect_commit_string (slot (fallback_commit_string_cb)); 2010 _fallback_instance->signal_connect_commit_string(slot(fallback_commit_string_cb));
2012 2011
2013 // Attach Panel Client signal. 2012 // Attach Panel Client signal.
2014 _panel_client.signal_connect_reload_config (slot (panel_slot_reload_config)); 2013 _panel_client.signal_connect_reload_config (slot(panel_slot_reload_config));
2015 _panel_client.signal_connect_exit (slot (panel_slot_exit)); 2014 _panel_client.signal_connect_exit (slot(panel_slot_exit));
2016 _panel_client.signal_connect_update_lookup_table_page_size (slot (panel_slot_update_lookup_table_page_size)); 2015 _panel_client.signal_connect_update_lookup_table_page_size(slot(panel_slot_update_lookup_table_page_size));
2017 _panel_client.signal_connect_lookup_table_page_up (slot (panel_slot_lookup_table_page_up)); 2016 _panel_client.signal_connect_lookup_table_page_up (slot(panel_slot_lookup_table_page_up));
2018 _panel_client.signal_connect_lookup_table_page_down (slot (panel_slot_lookup_table_page_down)); 2017 _panel_client.signal_connect_lookup_table_page_down (slot(panel_slot_lookup_table_page_down));
2019 _panel_client.signal_connect_trigger_property (slot (panel_slot_trigger_property)); 2018 _panel_client.signal_connect_trigger_property (slot(panel_slot_trigger_property));
2020 _panel_client.signal_connect_process_helper_event (slot (panel_slot_process_helper_event)); 2019 _panel_client.signal_connect_process_helper_event (slot(panel_slot_process_helper_event));
2021 _panel_client.signal_connect_move_preedit_caret (slot (panel_slot_move_preedit_caret)); 2020 _panel_client.signal_connect_move_preedit_caret (slot(panel_slot_move_preedit_caret));
2022 _panel_client.signal_connect_select_candidate (slot (panel_slot_select_candidate)); 2021 _panel_client.signal_connect_select_candidate (slot(panel_slot_select_candidate));
2023 _panel_client.signal_connect_process_key_event (slot (panel_slot_process_key_event)); 2022 _panel_client.signal_connect_process_key_event (slot(panel_slot_process_key_event));
2024 _panel_client.signal_connect_commit_string (slot (panel_slot_commit_string)); 2023 _panel_client.signal_connect_commit_string (slot(panel_slot_commit_string));
2025 _panel_client.signal_connect_forward_key_event (slot (panel_slot_forward_key_event)); 2024 _panel_client.signal_connect_forward_key_event (slot(panel_slot_forward_key_event));
2026 _panel_client.signal_connect_request_help (slot (panel_slot_request_help)); 2025 _panel_client.signal_connect_request_help (slot(panel_slot_request_help));
2027 _panel_client.signal_connect_request_factory_menu (slot (panel_slot_request_factory_menu)); 2026 _panel_client.signal_connect_request_factory_menu (slot(panel_slot_request_factory_menu));
2028 _panel_client.signal_connect_change_factory (slot (panel_slot_change_factory)); 2027 _panel_client.signal_connect_change_factory (slot(panel_slot_change_factory));
2029 2028
2030 if (!panel_initialize ()) 2029 if (!panel_initialize())
2031 std::cerr << "Ecore IM Module: Cannot connect to Panel!\n"; 2030 std::cerr << "Ecore IM Module: Cannot connect to Panel!\n";
2032} 2031}
2033 2032
2034static void 2033static void
2035finalize (void) 2034finalize(void)
2036{ 2035{
2037 SCIM_DEBUG_FRONTEND(1) << "Finalizing Ecore ISF IMModule...\n"; 2036 SCIM_DEBUG_FRONTEND(1) << "Finalizing Ecore ISF IMModule...\n";
2038 2037
2039 // Reset this first so that the shared instance could be released correctly afterwards. 2038 // Reset this first so that the shared instance could be released correctly afterwards.
2040 _default_instance.reset (); 2039 _default_instance.reset();
2041 2040
2042 SCIM_DEBUG_FRONTEND(2) << "Finalize all IC partially.\n"; 2041 SCIM_DEBUG_FRONTEND(2) << "Finalize all IC partially.\n";
2043 while (_used_ic_impl_list) 2042 while (_used_ic_impl_list)
@@ -2045,20 +2044,20 @@ finalize (void)
2045 // In case in "shared input method" mode, 2044 // In case in "shared input method" mode,
2046 // all contexts share only one instance, 2045 // all contexts share only one instance,
2047 // so we need point the reference pointer correctly before finalizing. 2046 // so we need point the reference pointer correctly before finalizing.
2048 _used_ic_impl_list->si->set_frontend_data (static_cast <void*> (_used_ic_impl_list->parent)); 2047 _used_ic_impl_list->si->set_frontend_data(static_cast <void*>(_used_ic_impl_list->parent));
2049 isf_imf_context_del (_used_ic_impl_list->parent->ctx); 2048 isf_imf_context_del(_used_ic_impl_list->parent->ctx);
2050 } 2049 }
2051 2050
2052 delete_all_ic_impl (); 2051 delete_all_ic_impl();
2053 2052
2054 _fallback_instance.reset (); 2053 _fallback_instance.reset();
2055 _fallback_factory.reset (); 2054 _fallback_factory.reset();
2056 2055
2057 SCIM_DEBUG_FRONTEND(2) << " Releasing BackEnd...\n"; 2056 SCIM_DEBUG_FRONTEND(2) << " Releasing BackEnd...\n";
2058 _backend.reset (); 2057 _backend.reset();
2059 2058
2060 SCIM_DEBUG_FRONTEND(2) << " Releasing Config...\n"; 2059 SCIM_DEBUG_FRONTEND(2) << " Releasing Config...\n";
2061 _config.reset (); 2060 _config.reset();
2062 2061
2063 if (_config_module) 2062 if (_config_module)
2064 { 2063 {
@@ -2072,27 +2071,27 @@ finalize (void)
2072 2071
2073 _scim_initialized = false; 2072 _scim_initialized = false;
2074 2073
2075 panel_finalize (); 2074 panel_finalize();
2076} 2075}
2077 2076
2078static void 2077static void
2079open_next_factory (EcoreIMFContextISF *ic) 2078open_next_factory(EcoreIMFContextISF *ic)
2080{ 2079{
2081 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; 2080 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n";
2082 IMEngineFactoryPointer sf = _backend->get_next_factory ("", "UTF-8", ic->impl->si->get_factory_uuid ()); 2081 IMEngineFactoryPointer sf = _backend->get_next_factory("", "UTF-8", ic->impl->si->get_factory_uuid());
2083 2082
2084 if (!sf.null ()) 2083 if (!sf.null())
2085 { 2084 {
2086 turn_off_ic (ic); 2085 turn_off_ic(ic);
2087 ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); 2086 ic->impl->si = sf->create_instance("UTF-8", ic->impl->si->get_id());
2088 ic->impl->si->set_frontend_data (static_cast <void*> (ic)); 2087 ic->impl->si->set_frontend_data(static_cast <void*>(ic));
2089 ic->impl->preedit_string = WideString (); 2088 ic->impl->preedit_string = WideString();
2090 ic->impl->preedit_caret = 0; 2089 ic->impl->preedit_caret = 0;
2091 attach_instance (ic->impl->si); 2090 attach_instance(ic->impl->si);
2092 _backend->set_default_factory (_language, sf->get_uuid ()); 2091 _backend->set_default_factory(_language, sf->get_uuid());
2093 _panel_client.register_input_context (ic->id, sf->get_uuid ()); 2092 _panel_client.register_input_context(ic->id, sf->get_uuid());
2094 set_ic_capabilities (ic); 2093 set_ic_capabilities(ic);
2095 turn_on_ic (ic); 2094 turn_on_ic(ic);
2096 2095
2097 if (_shared_input_method) 2096 if (_shared_input_method)
2098 { 2097 {
@@ -2103,26 +2102,26 @@ open_next_factory (EcoreIMFContextISF *ic)
2103} 2102}
2104 2103
2105static void 2104static void
2106open_previous_factory (EcoreIMFContextISF *ic) 2105open_previous_factory(EcoreIMFContextISF *ic)
2107{ 2106{
2108 if (ic == NULL) 2107 if (ic == NULL)
2109 return; 2108 return;
2110 2109
2111 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; 2110 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n";
2112 IMEngineFactoryPointer sf = _backend->get_previous_factory ("", "UTF-8", ic->impl->si->get_factory_uuid ()); 2111 IMEngineFactoryPointer sf = _backend->get_previous_factory("", "UTF-8", ic->impl->si->get_factory_uuid());
2113 2112
2114 if (!sf.null ()) 2113 if (!sf.null())
2115 { 2114 {
2116 turn_off_ic (ic); 2115 turn_off_ic(ic);
2117 ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); 2116 ic->impl->si = sf->create_instance("UTF-8", ic->impl->si->get_id());
2118 ic->impl->si->set_frontend_data (static_cast <void*> (ic)); 2117 ic->impl->si->set_frontend_data(static_cast <void*>(ic));
2119 ic->impl->preedit_string = WideString (); 2118 ic->impl->preedit_string = WideString();
2120 ic->impl->preedit_caret = 0; 2119 ic->impl->preedit_caret = 0;
2121 attach_instance (ic->impl->si); 2120 attach_instance(ic->impl->si);
2122 _backend->set_default_factory (_language, sf->get_uuid ()); 2121 _backend->set_default_factory(_language, sf->get_uuid());
2123 _panel_client.register_input_context (ic->id, sf->get_uuid ()); 2122 _panel_client.register_input_context(ic->id, sf->get_uuid());
2124 set_ic_capabilities (ic); 2123 set_ic_capabilities(ic);
2125 turn_on_ic (ic); 2124 turn_on_ic(ic);
2126 2125
2127 if (_shared_input_method) 2126 if (_shared_input_method)
2128 { 2127 {
@@ -2133,7 +2132,7 @@ open_previous_factory (EcoreIMFContextISF *ic)
2133} 2132}
2134 2133
2135static void 2134static void
2136open_specific_factory (EcoreIMFContextISF *ic, 2135open_specific_factory(EcoreIMFContextISF *ic,
2137 const String &uuid) 2136 const String &uuid)
2138{ 2137{
2139 if (ic == NULL) 2138 if (ic == NULL)
@@ -2142,26 +2141,26 @@ open_specific_factory (EcoreIMFContextISF *ic,
2142 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; 2141 SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n";
2143 2142
2144 // The same input method is selected, just turn on the IC. 2143 // The same input method is selected, just turn on the IC.
2145 if (ic->impl->si->get_factory_uuid () == uuid) 2144 if (ic->impl->si->get_factory_uuid() == uuid)
2146 { 2145 {
2147 turn_on_ic (ic); 2146 turn_on_ic(ic);
2148 return; 2147 return;
2149 } 2148 }
2150 2149
2151 IMEngineFactoryPointer sf = _backend->get_factory (uuid); 2150 IMEngineFactoryPointer sf = _backend->get_factory(uuid);
2152 2151
2153 if (uuid.length () && !sf.null ()) 2152 if (uuid.length() && !sf.null())
2154 { 2153 {
2155 turn_off_ic (ic); 2154 turn_off_ic(ic);
2156 ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); 2155 ic->impl->si = sf->create_instance("UTF-8", ic->impl->si->get_id());
2157 ic->impl->si->set_frontend_data (static_cast <void*> (ic)); 2156 ic->impl->si->set_frontend_data(static_cast <void*>(ic));
2158 ic->impl->preedit_string = WideString (); 2157 ic->impl->preedit_string = WideString();
2159 ic->impl->preedit_caret = 0; 2158 ic->impl->preedit_caret = 0;
2160 attach_instance (ic->impl->si); 2159 attach_instance(ic->impl->si);
2161 _backend->set_default_factory (_language, sf->get_uuid ()); 2160 _backend->set_default_factory(_language, sf->get_uuid());
2162 _panel_client.register_input_context (ic->id, sf->get_uuid ()); 2161 _panel_client.register_input_context(ic->id, sf->get_uuid());
2163 set_ic_capabilities (ic); 2162 set_ic_capabilities(ic);
2164 turn_on_ic (ic); 2163 turn_on_ic(ic);
2165 2164
2166 if (_shared_input_method) 2165 if (_shared_input_method)
2167 { 2166 {
@@ -2171,29 +2170,29 @@ open_specific_factory (EcoreIMFContextISF *ic,
2171 } 2170 }
2172 else 2171 else
2173 { 2172 {
2174 // turn_off_ic comment out panel_req_update_factory_info () 2173 // turn_off_ic comment out panel_req_update_factory_info()
2175 turn_off_ic (ic); 2174 turn_off_ic(ic);
2176 if (ic && ic->impl->is_on) 2175 if (ic && ic->impl->is_on)
2177 { 2176 {
2178 ic->impl->is_on = false; 2177 ic->impl->is_on = false;
2179 2178
2180 if (ic == _focused_ic) 2179 if (ic == _focused_ic)
2181 { 2180 {
2182 ic->impl->si->focus_out (); 2181 ic->impl->si->focus_out();
2183 2182
2184 panel_req_update_factory_info (ic); 2183 panel_req_update_factory_info(ic);
2185 _panel_client.turn_off (ic->id); 2184 _panel_client.turn_off(ic->id);
2186 } 2185 }
2187 2186
2188 //Record the IC on/off status 2187 //Record the IC on/off status
2189 if (_shared_input_method) 2188 if (_shared_input_method)
2190 _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false); 2189 _config->write(String(SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false);
2191 2190
2192 if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) 2191 if (ic->impl->use_preedit && ic->impl->preedit_string.length())
2193 { 2192 {
2194 ecore_imf_context_preedit_changed_event_add (ic->ctx); 2193 ecore_imf_context_preedit_changed_event_add(ic->ctx);
2195 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 2194 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
2196 ecore_imf_context_preedit_end_event_add (ic->ctx); 2195 ecore_imf_context_preedit_end_event_add(ic->ctx);
2197 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); 2196 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL);
2198 ic->impl->preedit_started = false; 2197 ic->impl->preedit_started = false;
2199 } 2198 }
@@ -2201,7 +2200,7 @@ open_specific_factory (EcoreIMFContextISF *ic,
2201 } 2200 }
2202} 2201}
2203 2202
2204static void initialize_modifier_bits (Display *display) 2203static void initialize_modifier_bits(Display *display)
2205{ 2204{
2206 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2205 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2207 2206
@@ -2222,21 +2221,21 @@ static void initialize_modifier_bits (Display *display)
2222 2221
2223 XModifierKeymap *mods = NULL; 2222 XModifierKeymap *mods = NULL;
2224 2223
2225 ::KeyCode ctrl_l = XKeysymToKeycode (display, XK_Control_L); 2224 ::KeyCode ctrl_l = XKeysymToKeycode(display, XK_Control_L);
2226 ::KeyCode ctrl_r = XKeysymToKeycode (display, XK_Control_R); 2225 ::KeyCode ctrl_r = XKeysymToKeycode(display, XK_Control_R);
2227 ::KeyCode meta_l = XKeysymToKeycode (display, XK_Meta_L); 2226 ::KeyCode meta_l = XKeysymToKeycode(display, XK_Meta_L);
2228 ::KeyCode meta_r = XKeysymToKeycode (display, XK_Meta_R); 2227 ::KeyCode meta_r = XKeysymToKeycode(display, XK_Meta_R);
2229 ::KeyCode alt_l = XKeysymToKeycode (display, XK_Alt_L); 2228 ::KeyCode alt_l = XKeysymToKeycode(display, XK_Alt_L);
2230 ::KeyCode alt_r = XKeysymToKeycode (display, XK_Alt_R); 2229 ::KeyCode alt_r = XKeysymToKeycode(display, XK_Alt_R);
2231 ::KeyCode super_l = XKeysymToKeycode (display, XK_Super_L); 2230 ::KeyCode super_l = XKeysymToKeycode(display, XK_Super_L);
2232 ::KeyCode super_r = XKeysymToKeycode (display, XK_Super_R); 2231 ::KeyCode super_r = XKeysymToKeycode(display, XK_Super_R);
2233 ::KeyCode hyper_l = XKeysymToKeycode (display, XK_Hyper_L); 2232 ::KeyCode hyper_l = XKeysymToKeycode(display, XK_Hyper_L);
2234 ::KeyCode hyper_r = XKeysymToKeycode (display, XK_Hyper_R); 2233 ::KeyCode hyper_r = XKeysymToKeycode(display, XK_Hyper_R);
2235 ::KeyCode numlock = XKeysymToKeycode (display, XK_Num_Lock); 2234 ::KeyCode numlock = XKeysymToKeycode(display, XK_Num_Lock);
2236 2235
2237 int i, j; 2236 int i, j;
2238 2237
2239 mods = XGetModifierMapping (display); 2238 mods = XGetModifierMapping(display);
2240 if (mods == NULL) 2239 if (mods == NULL)
2241 return; 2240 return;
2242 2241
@@ -2283,13 +2282,13 @@ static void initialize_modifier_bits (Display *display)
2283 xkey.same_screen = False; 2282 xkey.same_screen = False;
2284 xkey.subwindow = None; 2283 xkey.subwindow = None;
2285 xkey.window = None; 2284 xkey.window = None;
2286 xkey.root = DefaultRootWindow (display); 2285 xkey.root = DefaultRootWindow(display);
2287 xkey.state = ShiftMask; 2286 xkey.state = ShiftMask;
2288 2287
2289 xkey.keycode = meta_l; 2288 xkey.keycode = meta_l;
2290 XLookupString (&xkey, buf, 32, &keysym_l, 0); 2289 XLookupString(&xkey, buf, 32, &keysym_l, 0);
2291 xkey.keycode = meta_r; 2290 xkey.keycode = meta_r;
2292 XLookupString (&xkey, buf, 32, &keysym_r, 0); 2291 XLookupString(&xkey, buf, 32, &keysym_r, 0);
2293 2292
2294 if ((meta_l == alt_l && keysym_l == XK_Meta_L) || (meta_r == alt_r && keysym_r == XK_Meta_R)) 2293 if ((meta_l == alt_l && keysym_l == XK_Meta_L) || (meta_r == alt_r && keysym_r == XK_Meta_R))
2295 __current_meta_mask = ShiftMask + __current_alt_mask; 2294 __current_meta_mask = ShiftMask + __current_alt_mask;
@@ -2297,16 +2296,16 @@ static void initialize_modifier_bits (Display *display)
2297 __current_meta_mask = ShiftMask + ControlMask; 2296 __current_meta_mask = ShiftMask + ControlMask;
2298 } 2297 }
2299 2298
2300 XFreeModifiermap (mods); 2299 XFreeModifiermap(mods);
2301} 2300}
2302 2301
2303static unsigned int scim_x11_keymask_scim_to_x11 (Display *display, uint16 scimkeymask) 2302static unsigned int scim_x11_keymask_scim_to_x11(Display *display, uint16 scimkeymask)
2304{ 2303{
2305 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2304 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2306 2305
2307 unsigned int state = 0; 2306 unsigned int state = 0;
2308 2307
2309 initialize_modifier_bits (display); 2308 initialize_modifier_bits(display);
2310 2309
2311 if (scimkeymask & SCIM_KEY_ShiftMask) state |= ShiftMask; 2310 if (scimkeymask & SCIM_KEY_ShiftMask) state |= ShiftMask;
2312 if (scimkeymask & SCIM_KEY_CapsLockMask) state |= LockMask; 2311 if (scimkeymask & SCIM_KEY_CapsLockMask) state |= LockMask;
@@ -2320,9 +2319,9 @@ static unsigned int scim_x11_keymask_scim_to_x11 (Display *display, uint16 scimk
2320 return state; 2319 return state;
2321} 2320}
2322 2321
2323static XKeyEvent createKeyEvent (Display *display, Window &win, 2322static XKeyEvent createKeyEvent(Display *display, Window &win,
2324 Window &winRoot, bool press, 2323 Window &winRoot, bool press,
2325 int keycode, int modifiers) 2324 int keycode, int modifiers)
2326{ 2325{
2327 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2326 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2328 2327
@@ -2339,7 +2338,7 @@ static XKeyEvent createKeyEvent (Display *display, Window &win,
2339 event.y_root = 1; 2338 event.y_root = 1;
2340 event.same_screen = EINA_TRUE; 2339 event.same_screen = EINA_TRUE;
2341 event.state = modifiers; 2340 event.state = modifiers;
2342 event.keycode = XKeysymToKeycode (display, keycode); 2341 event.keycode = XKeysymToKeycode(display, keycode);
2343 if (press) 2342 if (press)
2344 event.type = KeyPress; 2343 event.type = KeyPress;
2345 else 2344 else
@@ -2350,12 +2349,12 @@ static XKeyEvent createKeyEvent (Display *display, Window &win,
2350 return event; 2349 return event;
2351} 2350}
2352 2351
2353static void _x_send_key_event (const KeyEvent &key) 2352static void _x_send_key_event(const KeyEvent &key)
2354{ 2353{
2355 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2354 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2356 2355
2357 // Obtain the X11 display. 2356 // Obtain the X11 display.
2358 Display *display = XOpenDisplay (NULL); 2357 Display *display = XOpenDisplay(NULL);
2359 if (display == NULL) 2358 if (display == NULL)
2360 { 2359 {
2361 std::cerr << "XOpenDisplay failed\n"; 2360 std::cerr << "XOpenDisplay failed\n";
@@ -2363,98 +2362,98 @@ static void _x_send_key_event (const KeyEvent &key)
2363 } 2362 }
2364 2363
2365 // Get the root window for the current display. 2364 // Get the root window for the current display.
2366 Window winRoot = 0;// = XRootWindow (display, 1); 2365 Window winRoot = 0;
2367 2366
2368 // Find the window which has the current keyboard focus. 2367 // Find the window which has the current keyboard focus.
2369 Window winFocus = 0; 2368 Window winFocus = 0;
2370 int revert = RevertToParent; 2369 int revert = RevertToParent;
2371 2370
2372 XGetInputFocus (display, &winFocus, &revert); 2371 XGetInputFocus(display, &winFocus, &revert);
2373 2372
2374 // Send a fake key press event to the window. 2373 // Send a fake key press event to the window.
2375 XSelectInput (display, winFocus, FocusChangeMask|KeyPressMask|KeyReleaseMask); 2374 XSelectInput(display, winFocus, FocusChangeMask|KeyPressMask|KeyReleaseMask);
2376 XMapWindow (display, winFocus); 2375 XMapWindow(display, winFocus);
2377 2376
2378 unsigned int modifier = scim_x11_keymask_scim_to_x11 (display, key.mask); 2377 unsigned int modifier = scim_x11_keymask_scim_to_x11(display, key.mask);
2379 XKeyEvent event; 2378 XKeyEvent event;
2380 if (key.is_key_press ()) 2379 if (key.is_key_press())
2381 { 2380 {
2382 event = createKeyEvent (display, winFocus, winRoot, true, key.code, modifier); 2381 event = createKeyEvent(display, winFocus, winRoot, true, key.code, modifier);
2383 XSendEvent (event.display, event.window, True, KeyPressMask, (XEvent *)&event); 2382 XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
2384 } 2383 }
2385 else 2384 else
2386 { 2385 {
2387 event = createKeyEvent (display, winFocus, winRoot, false, key.code, modifier); 2386 event = createKeyEvent(display, winFocus, winRoot, false, key.code, modifier);
2388 XSendEvent (event.display, event.window, True, KeyReleaseMask, (XEvent *)&event); 2387 XSendEvent(event.display, event.window, True, KeyReleaseMask, (XEvent *)&event);
2389 } 2388 }
2390 2389
2391 XCloseDisplay (display); 2390 XCloseDisplay(display);
2392} 2391}
2393 2392
2394static void 2393static void
2395attach_instance (const IMEngineInstancePointer &si) 2394attach_instance(const IMEngineInstancePointer &si)
2396{ 2395{
2397 si->signal_connect_show_preedit_string ( 2396 si->signal_connect_show_preedit_string(
2398 slot (slot_show_preedit_string)); 2397 slot(slot_show_preedit_string));
2399 si->signal_connect_show_aux_string ( 2398 si->signal_connect_show_aux_string(
2400 slot (slot_show_aux_string)); 2399 slot(slot_show_aux_string));
2401 si->signal_connect_show_lookup_table ( 2400 si->signal_connect_show_lookup_table(
2402 slot (slot_show_lookup_table)); 2401 slot(slot_show_lookup_table));
2403 2402
2404 si->signal_connect_hide_preedit_string ( 2403 si->signal_connect_hide_preedit_string(
2405 slot (slot_hide_preedit_string)); 2404 slot(slot_hide_preedit_string));
2406 si->signal_connect_hide_aux_string ( 2405 si->signal_connect_hide_aux_string(
2407 slot (slot_hide_aux_string)); 2406 slot(slot_hide_aux_string));
2408 si->signal_connect_hide_lookup_table ( 2407 si->signal_connect_hide_lookup_table(
2409 slot (slot_hide_lookup_table)); 2408 slot(slot_hide_lookup_table));
2410 2409
2411 si->signal_connect_update_preedit_caret ( 2410 si->signal_connect_update_preedit_caret(
2412 slot (slot_update_preedit_caret)); 2411 slot(slot_update_preedit_caret));
2413 si->signal_connect_update_preedit_string ( 2412 si->signal_connect_update_preedit_string(
2414 slot (slot_update_preedit_string)); 2413 slot(slot_update_preedit_string));
2415 si->signal_connect_update_aux_string ( 2414 si->signal_connect_update_aux_string(
2416 slot (slot_update_aux_string)); 2415 slot(slot_update_aux_string));
2417 si->signal_connect_update_lookup_table ( 2416 si->signal_connect_update_lookup_table(
2418 slot (slot_update_lookup_table)); 2417 slot(slot_update_lookup_table));
2419 2418
2420 si->signal_connect_commit_string ( 2419 si->signal_connect_commit_string(
2421 slot (slot_commit_string)); 2420 slot(slot_commit_string));
2422 2421
2423 si->signal_connect_forward_key_event ( 2422 si->signal_connect_forward_key_event(
2424 slot (slot_forward_key_event)); 2423 slot(slot_forward_key_event));
2425 2424
2426 si->signal_connect_register_properties ( 2425 si->signal_connect_register_properties(
2427 slot (slot_register_properties)); 2426 slot(slot_register_properties));
2428 2427
2429 si->signal_connect_update_property ( 2428 si->signal_connect_update_property(
2430 slot (slot_update_property)); 2429 slot(slot_update_property));
2431 2430
2432 si->signal_connect_beep ( 2431 si->signal_connect_beep(
2433 slot (slot_beep)); 2432 slot(slot_beep));
2434 2433
2435 si->signal_connect_start_helper ( 2434 si->signal_connect_start_helper(
2436 slot (slot_start_helper)); 2435 slot(slot_start_helper));
2437 2436
2438 si->signal_connect_stop_helper ( 2437 si->signal_connect_stop_helper(
2439 slot (slot_stop_helper)); 2438 slot(slot_stop_helper));
2440 2439
2441 si->signal_connect_send_helper_event ( 2440 si->signal_connect_send_helper_event(
2442 slot (slot_send_helper_event)); 2441 slot(slot_send_helper_event));
2443 2442
2444 si->signal_connect_get_surrounding_text ( 2443 si->signal_connect_get_surrounding_text(
2445 slot (slot_get_surrounding_text)); 2444 slot(slot_get_surrounding_text));
2446 2445
2447 si->signal_connect_delete_surrounding_text ( 2446 si->signal_connect_delete_surrounding_text(
2448 slot (slot_delete_surrounding_text)); 2447 slot(slot_delete_surrounding_text));
2449} 2448}
2450 2449
2451// Implementation of slot functions 2450// Implementation of slot functions
2452static void 2451static void
2453slot_show_preedit_string (IMEngineInstanceBase *si) 2452slot_show_preedit_string(IMEngineInstanceBase *si)
2454{ 2453{
2455 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2454 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2456 2455
2457 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2456 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2458 2457
2459 if (ic && ic->impl && _focused_ic == ic) 2458 if (ic && ic->impl && _focused_ic == ic)
2460 { 2459 {
@@ -2462,102 +2461,102 @@ slot_show_preedit_string (IMEngineInstanceBase *si)
2462 { 2461 {
2463 if (!ic->impl->preedit_started) 2462 if (!ic->impl->preedit_started)
2464 { 2463 {
2465 ecore_imf_context_preedit_start_event_add (_focused_ic->ctx); 2464 ecore_imf_context_preedit_start_event_add(_focused_ic->ctx);
2466 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); 2465 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL);
2467 ic->impl->preedit_started = true; 2466 ic->impl->preedit_started = true;
2468 } 2467 }
2469 } 2468 }
2470 else 2469 else
2471 _panel_client.show_preedit_string (ic->id); 2470 _panel_client.show_preedit_string(ic->id);
2472 } 2471 }
2473} 2472}
2474 2473
2475static void 2474static void
2476slot_show_aux_string (IMEngineInstanceBase *si) 2475slot_show_aux_string(IMEngineInstanceBase *si)
2477{ 2476{
2478 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2477 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2479 2478
2480 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2479 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2481 2480
2482 if (ic && ic->impl && _focused_ic == ic) 2481 if (ic && ic->impl && _focused_ic == ic)
2483 _panel_client.show_aux_string (ic->id); 2482 _panel_client.show_aux_string(ic->id);
2484} 2483}
2485 2484
2486static void 2485static void
2487slot_show_lookup_table (IMEngineInstanceBase *si) 2486slot_show_lookup_table(IMEngineInstanceBase *si)
2488{ 2487{
2489 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2488 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2490 2489
2491 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2490 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2492 2491
2493 if (ic && ic->impl && _focused_ic == ic) 2492 if (ic && ic->impl && _focused_ic == ic)
2494 _panel_client.show_lookup_table (ic->id); 2493 _panel_client.show_lookup_table(ic->id);
2495} 2494}
2496 2495
2497static void 2496static void
2498slot_hide_preedit_string (IMEngineInstanceBase *si) 2497slot_hide_preedit_string(IMEngineInstanceBase *si)
2499{ 2498{
2500 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2499 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2501 2500
2502 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2501 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2503 2502
2504 if (ic && ic->impl && _focused_ic == ic) 2503 if (ic && ic->impl && _focused_ic == ic)
2505 { 2504 {
2506 bool emit = false; 2505 bool emit = false;
2507 if (ic->impl->preedit_string.length ()) 2506 if (ic->impl->preedit_string.length())
2508 { 2507 {
2509 ic->impl->preedit_string = WideString (); 2508 ic->impl->preedit_string = WideString();
2510 ic->impl->preedit_caret = 0; 2509 ic->impl->preedit_caret = 0;
2511 ic->impl->preedit_attrlist.clear (); 2510 ic->impl->preedit_attrlist.clear();
2512 emit = true; 2511 emit = true;
2513 } 2512 }
2514 if (ic->impl->use_preedit) 2513 if (ic->impl->use_preedit)
2515 { 2514 {
2516 if (emit) 2515 if (emit)
2517 { 2516 {
2518 ecore_imf_context_preedit_changed_event_add (ic->ctx); 2517 ecore_imf_context_preedit_changed_event_add(ic->ctx);
2519 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 2518 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
2520 } 2519 }
2521 if (ic->impl->preedit_started) 2520 if (ic->impl->preedit_started)
2522 { 2521 {
2523 ecore_imf_context_preedit_end_event_add (ic->ctx); 2522 ecore_imf_context_preedit_end_event_add(ic->ctx);
2524 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); 2523 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL);
2525 ic->impl->preedit_started = false; 2524 ic->impl->preedit_started = false;
2526 } 2525 }
2527 } 2526 }
2528 else 2527 else
2529 _panel_client.hide_preedit_string (ic->id); 2528 _panel_client.hide_preedit_string(ic->id);
2530 } 2529 }
2531} 2530}
2532 2531
2533static void 2532static void
2534slot_hide_aux_string (IMEngineInstanceBase *si) 2533slot_hide_aux_string(IMEngineInstanceBase *si)
2535{ 2534{
2536 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2535 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2537 2536
2538 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2537 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2539 2538
2540 if (ic && ic->impl && _focused_ic == ic) 2539 if (ic && ic->impl && _focused_ic == ic)
2541 _panel_client.hide_aux_string (ic->id); 2540 _panel_client.hide_aux_string(ic->id);
2542} 2541}
2543 2542
2544static void 2543static void
2545slot_hide_lookup_table (IMEngineInstanceBase *si) 2544slot_hide_lookup_table(IMEngineInstanceBase *si)
2546{ 2545{
2547 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2546 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2548 2547
2549 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2548 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2550 2549
2551 if (ic && ic->impl && _focused_ic == ic) 2550 if (ic && ic->impl && _focused_ic == ic)
2552 _panel_client.hide_lookup_table (ic->id); 2551 _panel_client.hide_lookup_table(ic->id);
2553} 2552}
2554 2553
2555static void 2554static void
2556slot_update_preedit_caret (IMEngineInstanceBase *si, int caret) 2555slot_update_preedit_caret(IMEngineInstanceBase *si, int caret)
2557{ 2556{
2558 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2557 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2559 2558
2560 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2559 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2561 2560
2562 if (ic && ic->impl && _focused_ic == ic && ic->impl->preedit_caret != caret) 2561 if (ic && ic->impl && _focused_ic == ic && ic->impl->preedit_caret != caret)
2563 { 2562 {
@@ -2566,28 +2565,28 @@ slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
2566 { 2565 {
2567 if (!ic->impl->preedit_started) 2566 if (!ic->impl->preedit_started)
2568 { 2567 {
2569 ecore_imf_context_preedit_start_event_add (ic->ctx); 2568 ecore_imf_context_preedit_start_event_add(ic->ctx);
2570 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); 2569 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL);
2571 ic->impl->preedit_started = true; 2570 ic->impl->preedit_started = true;
2572 } 2571 }
2573 ecore_imf_context_preedit_changed_event_add (ic->ctx); 2572 ecore_imf_context_preedit_changed_event_add(ic->ctx);
2574 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 2573 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
2575 } 2574 }
2576 else 2575 else
2577 _panel_client.update_preedit_caret (ic->id, caret); 2576 _panel_client.update_preedit_caret(ic->id, caret);
2578 } 2577 }
2579} 2578}
2580 2579
2581static void 2580static void
2582slot_update_preedit_string (IMEngineInstanceBase *si, 2581slot_update_preedit_string(IMEngineInstanceBase *si,
2583 const WideString & str, 2582 const WideString & str,
2584 const AttributeList & attrs) 2583 const AttributeList & attrs)
2585{ 2584{
2586 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2585 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2587 2586
2588 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2587 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2589 2588
2590 if (ic && ic->impl && _focused_ic == ic && (ic->impl->preedit_string != str || str.length ())) 2589 if (ic && ic->impl && _focused_ic == ic && (ic->impl->preedit_string != str || str.length()))
2591 { 2590 {
2592 ic->impl->preedit_string = str; 2591 ic->impl->preedit_string = str;
2593 ic->impl->preedit_attrlist = attrs; 2592 ic->impl->preedit_attrlist = attrs;
@@ -2595,178 +2594,178 @@ slot_update_preedit_string (IMEngineInstanceBase *si,
2595 { 2594 {
2596 if (!ic->impl->preedit_started) 2595 if (!ic->impl->preedit_started)
2597 { 2596 {
2598 ecore_imf_context_preedit_start_event_add (_focused_ic->ctx); 2597 ecore_imf_context_preedit_start_event_add(_focused_ic->ctx);
2599 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); 2598 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL);
2600 ic->impl->preedit_started = true; 2599 ic->impl->preedit_started = true;
2601 } 2600 }
2602 ic->impl->preedit_caret = str.length (); 2601 ic->impl->preedit_caret = str.length();
2603 ic->impl->preedit_updating = true; 2602 ic->impl->preedit_updating = true;
2604 ecore_imf_context_preedit_changed_event_add (ic->ctx); 2603 ecore_imf_context_preedit_changed_event_add(ic->ctx);
2605 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); 2604 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
2606 ic->impl->preedit_updating = false; 2605 ic->impl->preedit_updating = false;
2607 } 2606 }
2608 else 2607 else
2609 { 2608 {
2610 _panel_client.update_preedit_string (ic->id, str, attrs); 2609 _panel_client.update_preedit_string(ic->id, str, attrs);
2611 } 2610 }
2612 } 2611 }
2613} 2612}
2614 2613
2615static void 2614static void
2616slot_update_aux_string (IMEngineInstanceBase *si, 2615slot_update_aux_string(IMEngineInstanceBase *si,
2617 const WideString & str, 2616 const WideString & str,
2618 const AttributeList & attrs) 2617 const AttributeList & attrs)
2619{ 2618{
2620 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2619 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2621 2620
2622 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2621 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2623 2622
2624 if (ic && ic->impl && _focused_ic == ic) 2623 if (ic && ic->impl && _focused_ic == ic)
2625 _panel_client.update_aux_string (ic->id, str, attrs); 2624 _panel_client.update_aux_string(ic->id, str, attrs);
2626} 2625}
2627 2626
2628static void 2627static void
2629slot_commit_string (IMEngineInstanceBase *si, 2628slot_commit_string(IMEngineInstanceBase *si,
2630 const WideString & str) 2629 const WideString & str)
2631{ 2630{
2632 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2631 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2633 2632
2634 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2633 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2635 2634
2636 if (ic && ic->ctx) 2635 if (ic && ic->ctx)
2637 { 2636 {
2638 ecore_imf_context_commit_event_add (ic->ctx, utf8_wcstombs (str).c_str ()); 2637 ecore_imf_context_commit_event_add(ic->ctx, utf8_wcstombs(str).c_str());
2639 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(str).c_str()); 2638 ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(str).c_str());
2640 } 2639 }
2641} 2640}
2642 2641
2643static void 2642static void
2644slot_forward_key_event (IMEngineInstanceBase *si, 2643slot_forward_key_event(IMEngineInstanceBase *si,
2645 const KeyEvent & key) 2644 const KeyEvent & key)
2646{ 2645{
2647 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2646 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2648 2647
2649 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2648 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2650 2649
2651 if (ic && _focused_ic == ic) 2650 if (ic && _focused_ic == ic)
2652 { 2651 {
2653 if (!_fallback_instance->process_key_event (key)) 2652 if (!_fallback_instance->process_key_event(key))
2654 _x_send_key_event(key); 2653 _x_send_key_event(key);
2655 } 2654 }
2656} 2655}
2657 2656
2658static void 2657static void
2659slot_update_lookup_table (IMEngineInstanceBase *si, 2658slot_update_lookup_table(IMEngineInstanceBase *si,
2660 const LookupTable & table) 2659 const LookupTable & table)
2661{ 2660{
2662 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2661 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2663 2662
2664 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2663 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2665 2664
2666 if (ic && ic->impl && _focused_ic == ic) 2665 if (ic && ic->impl && _focused_ic == ic)
2667 _panel_client.update_lookup_table (ic->id, table); 2666 _panel_client.update_lookup_table(ic->id, table);
2668} 2667}
2669 2668
2670static void 2669static void
2671slot_register_properties (IMEngineInstanceBase *si, 2670slot_register_properties(IMEngineInstanceBase *si,
2672 const PropertyList & properties) 2671 const PropertyList & properties)
2673{ 2672{
2674 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2673 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2675 2674
2676 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2675 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2677 2676
2678 if (ic && ic->impl && _focused_ic == ic) 2677 if (ic && ic->impl && _focused_ic == ic)
2679 _panel_client.register_properties (ic->id, properties); 2678 _panel_client.register_properties(ic->id, properties);
2680} 2679}
2681 2680
2682static void 2681static void
2683slot_update_property (IMEngineInstanceBase *si, 2682slot_update_property(IMEngineInstanceBase *si,
2684 const Property & property) 2683 const Property & property)
2685{ 2684{
2686 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2685 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2687 2686
2688 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2687 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2689 2688
2690 if (ic && ic->impl && _focused_ic == ic) 2689 if (ic && ic->impl && _focused_ic == ic)
2691 _panel_client.update_property (ic->id, property); 2690 _panel_client.update_property(ic->id, property);
2692} 2691}
2693 2692
2694static void 2693static void
2695slot_beep (IMEngineInstanceBase *si __UNUSED__) 2694slot_beep(IMEngineInstanceBase *si __UNUSED__)
2696{ 2695{
2697 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2696 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2698} 2697}
2699 2698
2700static void 2699static void
2701slot_start_helper (IMEngineInstanceBase *si, 2700slot_start_helper(IMEngineInstanceBase *si,
2702 const String &helper_uuid) 2701 const String &helper_uuid)
2703{ 2702{
2704 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2703 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2705 2704
2706 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" 2705 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context="
2707 << (ic ? ic->id : -1) << " ic=" << ic 2706 << (ic ? ic->id : -1) << " ic=" << ic
2708 << " ic-uuid=" << ((ic ) ? ic->impl->si->get_factory_uuid () : "") << "...\n"; 2707 << " ic-uuid=" << ((ic ) ? ic->impl->si->get_factory_uuid() : "") << "...\n";
2709 2708
2710 if (ic && ic->impl) 2709 if (ic && ic->impl)
2711 _panel_client.start_helper (ic->id, helper_uuid); 2710 _panel_client.start_helper(ic->id, helper_uuid);
2712} 2711}
2713 2712
2714static void 2713static void
2715slot_stop_helper (IMEngineInstanceBase *si, 2714slot_stop_helper(IMEngineInstanceBase *si,
2716 const String &helper_uuid) 2715 const String &helper_uuid)
2717{ 2716{
2718 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2717 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2719 2718
2720 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" << (ic ? ic->id : -1) << " ic=" << ic << "...\n"; 2719 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" << (ic ? ic->id : -1) << " ic=" << ic << "...\n";
2721 2720
2722 if (ic && ic->impl) 2721 if (ic && ic->impl)
2723 _panel_client.stop_helper (ic->id, helper_uuid); 2722 _panel_client.stop_helper(ic->id, helper_uuid);
2724} 2723}
2725 2724
2726static void 2725static void
2727slot_send_helper_event (IMEngineInstanceBase *si, 2726slot_send_helper_event(IMEngineInstanceBase *si,
2728 const String &helper_uuid, 2727 const String &helper_uuid,
2729 const Transaction &trans) 2728 const Transaction &trans)
2730{ 2729{
2731 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2730 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2732 2731
2733 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" 2732 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context="
2734 << (ic ? ic->id : -1) << " ic=" << ic 2733 << (ic ? ic->id : -1) << " ic=" << ic
2735 << " ic-uuid=" << ((ic) ? ic->impl->si->get_factory_uuid () : "") << "...\n"; 2734 << " ic-uuid=" << ((ic) ? ic->impl->si->get_factory_uuid() : "") << "...\n";
2736 2735
2737 if (ic && ic->impl) 2736 if (ic && ic->impl)
2738 _panel_client.send_helper_event (ic->id, helper_uuid, trans); 2737 _panel_client.send_helper_event(ic->id, helper_uuid, trans);
2739} 2738}
2740 2739
2741static bool 2740static bool
2742slot_get_surrounding_text (IMEngineInstanceBase *si, 2741slot_get_surrounding_text(IMEngineInstanceBase *si,
2743 WideString &text, 2742 WideString &text,
2744 int &cursor, 2743 int &cursor,
2745 int maxlen_before, 2744 int maxlen_before,
2746 int maxlen_after) 2745 int maxlen_after)
2747{ 2746{
2748 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2747 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2749 2748
2750 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2749 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2751 2750
2752 if (ic && ic->impl && _focused_ic == ic) 2751 if (ic && ic->impl && _focused_ic == ic)
2753 { 2752 {
2754 char *surrounding = NULL; 2753 char *surrounding = NULL;
2755 int cursor_index; 2754 int cursor_index;
2756 if (ecore_imf_context_surrounding_get (_focused_ic->ctx, &surrounding, &cursor_index)) 2755 if (ecore_imf_context_surrounding_get(_focused_ic->ctx, &surrounding, &cursor_index))
2757 { 2756 {
2758 SCIM_DEBUG_FRONTEND(2) << "Surrounding text: " << surrounding <<"\n"; 2757 SCIM_DEBUG_FRONTEND(2) << "Surrounding text: " << surrounding <<"\n";
2759 SCIM_DEBUG_FRONTEND(2) << "Cursor Index : " << cursor_index <<"\n"; 2758 SCIM_DEBUG_FRONTEND(2) << "Cursor Index : " << cursor_index <<"\n";
2760 WideString before (utf8_mbstowcs (String (surrounding, surrounding + cursor_index))); 2759 WideString before(utf8_mbstowcs(String(surrounding, surrounding + cursor_index)));
2761 WideString after (utf8_mbstowcs (String (surrounding + cursor_index))); 2760 WideString after(utf8_mbstowcs(String(surrounding + cursor_index)));
2762 if (maxlen_before > 0 && ((unsigned int)maxlen_before) < before.length ()) 2761 if (maxlen_before > 0 && ((unsigned int)maxlen_before) < before.length())
2763 before = WideString (before.begin () + (before.length () - maxlen_before), before.end ()); 2762 before = WideString(before.begin() + (before.length() - maxlen_before), before.end());
2764 else if (maxlen_before == 0) before = WideString (); 2763 else if (maxlen_before == 0) before = WideString();
2765 if (maxlen_after > 0 && ((unsigned int)maxlen_after) < after.length ()) 2764 if (maxlen_after > 0 && ((unsigned int)maxlen_after) < after.length())
2766 after = WideString (after.begin (), after.begin () + maxlen_after); 2765 after = WideString(after.begin(), after.begin() + maxlen_after);
2767 else if (maxlen_after == 0) after = WideString (); 2766 else if (maxlen_after == 0) after = WideString();
2768 text = before + after; 2767 text = before + after;
2769 cursor = before.length (); 2768 cursor = before.length();
2770 return true; 2769 return true;
2771 } 2770 }
2772 } 2771 }
@@ -2774,13 +2773,13 @@ slot_get_surrounding_text (IMEngineInstanceBase *si,
2774} 2773}
2775 2774
2776static bool 2775static bool
2777slot_delete_surrounding_text (IMEngineInstanceBase *si, 2776slot_delete_surrounding_text(IMEngineInstanceBase *si,
2778 int offset, 2777 int offset,
2779 int len) 2778 int len)
2780{ 2779{
2781 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2780 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2782 2781
2783 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *> (si->get_frontend_data ()); 2782 EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
2784 2783
2785 if (ic && ic->impl && _focused_ic == ic) 2784 if (ic && ic->impl && _focused_ic == ic)
2786 { 2785 {
@@ -2788,7 +2787,7 @@ slot_delete_surrounding_text (IMEngineInstanceBase *si,
2788 ev.ctx = _focused_ic->ctx; 2787 ev.ctx = _focused_ic->ctx;
2789 ev.n_chars = len; 2788 ev.n_chars = len;
2790 ev.offset = offset; 2789 ev.offset = offset;
2791 ecore_imf_context_delete_surrounding_event_add (_focused_ic->ctx, offset, len); 2790 ecore_imf_context_delete_surrounding_event_add(_focused_ic->ctx, offset, len);
2792 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev); 2791 ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev);
2793 return true; 2792 return true;
2794 } 2793 }
@@ -2796,43 +2795,43 @@ slot_delete_surrounding_text (IMEngineInstanceBase *si,
2796} 2795}
2797 2796
2798static void 2797static void
2799reload_config_callback (const ConfigPointer &config) 2798reload_config_callback(const ConfigPointer &config)
2800{ 2799{
2801 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2800 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2802 2801
2803 _frontend_hotkey_matcher.load_hotkeys (config); 2802 _frontend_hotkey_matcher.load_hotkeys(config);
2804 _imengine_hotkey_matcher.load_hotkeys (config); 2803 _imengine_hotkey_matcher.load_hotkeys(config);
2805 2804
2806 KeyEvent key; 2805 KeyEvent key;
2807 2806
2808 scim_string_to_key (key, 2807 scim_string_to_key(key,
2809 config->read (String (SCIM_CONFIG_HOTKEYS_FRONTEND_VALID_KEY_MASK), 2808 config->read(String(SCIM_CONFIG_HOTKEYS_FRONTEND_VALID_KEY_MASK),
2810 String ("Shift+Control+Alt+Lock"))); 2809 String("Shift+Control+Alt+Lock")));
2811 2810
2812 _valid_key_mask = (key.mask > 0)?(key.mask):0xFFFF; 2811 _valid_key_mask = (key.mask > 0)?(key.mask):0xFFFF;
2813 _valid_key_mask |= SCIM_KEY_ReleaseMask; 2812 _valid_key_mask |= SCIM_KEY_ReleaseMask;
2814 // Special treatment for two backslash keys on jp106 keyboard. 2813 // Special treatment for two backslash keys on jp106 keyboard.
2815 _valid_key_mask |= SCIM_KEY_QuirkKanaRoMask; 2814 _valid_key_mask |= SCIM_KEY_QuirkKanaRoMask;
2816 2815
2817 _on_the_spot = config->read (String (SCIM_CONFIG_FRONTEND_ON_THE_SPOT), _on_the_spot); 2816 _on_the_spot = config->read(String(SCIM_CONFIG_FRONTEND_ON_THE_SPOT), _on_the_spot);
2818 _shared_input_method = config->read (String (SCIM_CONFIG_FRONTEND_SHARED_INPUT_METHOD), _shared_input_method); 2817 _shared_input_method = config->read(String(SCIM_CONFIG_FRONTEND_SHARED_INPUT_METHOD), _shared_input_method);
2819 2818
2820 // Get keyboard layout setting 2819 // Get keyboard layout setting
2821 // Flush the global config first, in order to load the new configs from disk. 2820 // Flush the global config first, in order to load the new configs from disk.
2822 scim_global_config_flush (); 2821 scim_global_config_flush();
2823 2822
2824 _keyboard_layout = scim_get_default_keyboard_layout (); 2823 _keyboard_layout = scim_get_default_keyboard_layout();
2825} 2824}
2826 2825
2827static void 2826static void
2828fallback_commit_string_cb (IMEngineInstanceBase *si __UNUSED__, 2827fallback_commit_string_cb(IMEngineInstanceBase *si __UNUSED__,
2829 const WideString &str) 2828 const WideString &str)
2830{ 2829{
2831 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; 2830 SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
2832