Hi, Naruto.

As I told you last Friday on IRC, I guess there are some bugs in your xim
immodule.
For example, in case that I'd like to input '私の' (watasino), the preedit
string was got from your immodule like below
'私のしの'.

In addition, there are some sequence issue to send preedit changed event and
commit event.
I've tried to fix this problem and send you the patch.

(I've tested on elementary_test > entry)

If you don't mind uploading this patch to svn, I'll request Maintainers to
upload this patch.

Thanks.

On Sun, Jul 10, 2011 at 2:51 AM, Naruto TAKAHASHI <tnar...@gmail.com> wrote:

> Hi Mike.
>
> Thanks, feedback. I merged it to xim/Makefile.am.
>
> I attach a source code for using XIM module debug.
> This program can check a below behaviors.
>
>  - toggle enable and disable XIM
>  - commit string from XIM
>
> Another test, by using Desktop Entry Editor's text field.
> (Enlightenment Main->Settings->Settings Panel->New Application)
>
> When executing test program, set ECORE_IMF_MODULE=xim.
>
> Thanks.
>
> 2011/7/8 Mike McCormack <mj.mccorm...@samsung.com>:
> > On 07/08/2011 03:15 PM, Naruto TAKAHASHI wrote:
> >> Hi, All.
> >>
> >> I attached some patches of XIM module of ecore_imf.
> >>
> >> As far as I know, EFL has not having official ecore_imf module in E
> >> repository. And ecore_x has XIM code but is unavailable condition.
> >> So I moved XIM code of ecore_x as ecore_imf module.
> >>
> >> please review this patches.
> >
> > Hello Naruto,
> >
> > Looks like nice work.
> >
> > I applied your patches to my ecore and built, but there was a build error
> (fix below):
> >
> > make[5]: Entering directory
> `/home/mike/git/e/ecore/src/modules/immodules/xim'
> >  CC     xim_la-ecore_imf_xim.lo
> > ecore_imf_xim.c:5:18: error: Evas.h: No such file or directory
> > ecore_imf_xim.c: In function ‘_ecore_x_event_reverse_locks’:
> > ecore_imf_xim.c:359: warning: suggest braces around empty body in an ‘if’
> statement
> > ecore_imf_xim.c: In function ‘preedit_start_callback’:
> > ecore_imf_xim.c:662: warning: unused parameter ‘xic’
> > ecore_imf_xim.c:664: warning: unused parameter ‘call_data’
> >
> > How can I test it?
> >
> > thanks,
> >
> > Mike
> >
> >
> >
> > diff --git a/ecore/src/modules/immodules/xim/Makefile.am
> b/ecore/src/modules/immodules/xim/Makefile.am
> > index 006035c..cc0682d 100644
> > --- a/ecore/src/modules/immodules/xim/Makefile.am
> > +++ b/ecore/src/modules/immodules/xim/Makefile.am
> > @@ -12,6 +12,7 @@ AM_CPPFLAGS = \
> >  -I$(top_builddir)/src/lib/ecore_imf \
> >  -DPACKAGE_LIB_DIR=\"$(libdir)\" \
> >  -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
> > +@EVAS_CFLAGS@ \
> >  @EINA_CFLAGS@
> >
> >  pkgdir = $(libdir)/ecore/immodules
> >
> >
> >
> ------------------------------------------------------------------------------
> > All of the data generated in your IT infrastructure is seriously
> valuable.
> > Why? It contains a definitive record of application performance, security
> > threats, fraudulent activity, and more. Splunk takes this data and makes
> > sense of it. IT sense. And common sense.
> > http://p.sf.net/sfu/splunk-d2d-c2
> > _______________________________________________
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
>
>
>
> --
> Naruto TAKAHASHI
> tnar...@gmail.com
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
>
Index: ecore_imf_xim.c
===================================================================
--- ecore_imf_xim.c     (리비전 61433)
+++ ecore_imf_xim.c     (작업 사본)
@@ -282,6 +282,12 @@ _ecore_imf_context_xim_reset(Ecore_IMF_Context *ct
 
    XFree(preedit_attr);
 
+   if(imf_context_data->preedit_length)
+     {
+        imf_context_data->preedit_length = 0;
+        ecore_imf_context_preedit_changed_event_add(ctx);
+     }
+
    if(result)
      {
          char *result_utf8 = strdup(result);
@@ -292,12 +298,6 @@ _ecore_imf_context_xim_reset(Ecore_IMF_Context *ct
            }
      }
 
-   if(imf_context_data->preedit_length)
-     {
-        imf_context_data->preedit_length = 0;
-        ecore_imf_context_preedit_changed_event_add(ctx);
-     }
-
    XFree (result);
 #endif
 }
@@ -671,9 +671,9 @@ imf_context_data_destroy(Ecore_IMF_Context_Data *i
 }
 
 static int
-preedit_start_callback(XIC      xic,
+preedit_start_callback(XIC      xic __UNUSED__,
                        XPointer client_data,
-                       XPointer call_data)
+                       XPointer call_data __UNUSED__)
 {
    EINA_LOG_DBG("in");
    Ecore_IMF_Context *ctx = (Ecore_IMF_Context *)client_data;
@@ -687,9 +687,9 @@ static int
 }
 
 static void
-preedit_done_callback(XIC      xic,
+preedit_done_callback(XIC      xic __UNUSED__,
                       XPointer client_data,
-                      XPointer call_data)
+                      XPointer call_data __UNUSED__)
 {
    EINA_LOG_DBG("in");
    Ecore_IMF_Context *ctx = (Ecore_IMF_Context *)client_data;
@@ -708,7 +708,7 @@ static void
 
 /* FIXME */
 static int
-xim_text_to_utf8(Ecore_IMF_Context *ctx,
+xim_text_to_utf8(Ecore_IMF_Context *ctx __UNUSED__,
                  XIMText           *xim_text,
                  char             **text)
 {
@@ -750,7 +750,7 @@ static int
 }
 
 static void
-preedit_draw_callback(XIC                           xic,
+preedit_draw_callback(XIC                           xic __UNUSED__,
                       XPointer                      client_data,
                       XIMPreeditDrawCallbackStruct *call_data)
 {
@@ -759,77 +759,23 @@ static void
    Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx);
    XIMText *t = call_data->text;
    char *tmp;
-   Eina_Unicode *new_text = NULL;
-   int new_length;
-   int new_text_length;
-   int diff;
-   int chg_first;
-   int chg_length;
-   int i;
+   
+   imf_context_data->preedit_length = xim_text_to_utf8(ctx, t, &tmp);
+   if (!tmp)
+     tmp = strdup("");
 
-   /* XXX */
-   chg_first = CLAMP(call_data->chg_first, 0, 
imf_context_data->preedit_length);
-   chg_length = CLAMP(call_data->chg_length, 0,
-                      imf_context_data->preedit_length - chg_first);
+   if (imf_context_data->preedit_chars) 
+     free(imf_context_data->preedit_chars);
 
-   new_text_length = xim_text_to_utf8(ctx, t, &tmp);
-   if(tmp)
-     {
-        int tmp_len;
-        new_text = eina_unicode_utf8_to_unicode((const char *)tmp, &tmp_len);
-        free(tmp);
-     }
+   imf_context_data->preedit_chars = eina_unicode_utf8_to_unicode((const char 
*)tmp, NULL);
+   free(tmp);
 
-   diff = new_text_length - chg_length;
-   new_length = imf_context_data->preedit_length + diff;
-   if(new_length > imf_context_data->preedit_size)
-     {
-        Eina_Unicode *tmp_chars = NULL;
-        imf_context_data->preedit_size = new_length;
-
-        if(imf_context_data->preedit_chars)
-          {
-             tmp_chars = eina_unicode_strdup(imf_context_data->preedit_chars);
-             free(imf_context_data->preedit_chars);
-             imf_context_data->preedit_chars = calloc(new_length + 1,
-                                                      sizeof(Eina_Unicode));
-             eina_unicode_strcpy(imf_context_data->preedit_chars, tmp_chars);
-             free(tmp_chars);
-          }
-        else {
-             imf_context_data->preedit_chars = calloc(new_length + 1,
-                                                      sizeof(Eina_Unicode));
-          }
-        // XXX feedback?
-     }
-
-   if(diff < 0)
-     {
-        for(i = chg_first + chg_length; i < imf_context_data->preedit_length; 
i++) {
-             imf_context_data->preedit_chars[i + diff] =
-               imf_context_data->preedit_chars[i];
-          }
-     }
-   else {
-        for(i = imf_context_data->preedit_length - 1; i >= chg_first + 
chg_length; i--) {
-             imf_context_data->preedit_chars[i + diff] =
-               imf_context_data->preedit_chars[i];
-          }
-     }
-
-   for(i = 0; i < new_text_length; i++) {
-        imf_context_data->preedit_chars[chg_first + i] = new_text[i];
-     }
-
-   imf_context_data->preedit_length += diff;
-   free(new_text);
-
    if(imf_context_data->finalizing == EINA_FALSE)
      ecore_imf_context_preedit_changed_event_add(ctx);
 }
 
 static void
-preedit_caret_callback(XIC                            xic,
+preedit_caret_callback(XIC                            xic __UNUSED__,
                        XPointer                       client_data,
                        XIMPreeditCaretCallbackStruct *call_data)
 {
@@ -1053,8 +999,8 @@ xim_info_try_im(XIM_Im_Info *info)
 }
 
 static void
-xim_info_display_closed(Ecore_X_Display *display,
-                        int              is_error,
+xim_info_display_closed(Ecore_X_Display *display __UNUSED__,
+                        int              is_error __UNUSED__,
                         XIM_Im_Info     *info)
 {
    Eina_List *ics, *tmp_list;
@@ -1085,7 +1031,7 @@ static void
 static void
 xim_instantiate_callback(Display *display,
                          XPointer client_data,
-                         XPointer call_data)
+                         XPointer call_data __UNUSED__)
 {
    XIM_Im_Info *info = (XIM_Im_Info *)client_data;
    XIM im = NULL;
@@ -1146,9 +1092,9 @@ setup_im(XIM_Im_Info *info)
 }
 
 static void
-xim_destroy_callback(XIM      xim,
+xim_destroy_callback(XIM      xim __UNUSED__,
                      XPointer client_data,
-                     XPointer call_data)
+                     XPointer call_data __UNUSED__)
 {
    XIM_Im_Info *info = (XIM_Im_Info *)client_data;
    info->im = NULL;
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to