On Tuesday 04 February 2003 1:25 pm, [EMAIL PROTECTED] wrote:
> With this "work_area->form", I now have a working XIC for the WorkArea
> events. Precomposition of CJK-characters on the lyx main window is
> perfect. However putting these precomposed characters on the screen with
> your function, "fl_get_composed_string",is not perfect yet. For example,
> suppose I have already put CJK-characters on the lyx main window as,
>
> "XY ZW" (here "X,Y,Z,W" are all CJK-xharacters). Now after these letters
> if I precompose another CJK-character, "P", and then hit "space-bar", I
> get on the screen,
>
> "XY ZW PW"
>
> That is, I get extra "W" on the screen, which shouldn't be there.

First, let me say "Well done!"

> This happens with the xforms library with your bif xforms.diff patched. to
> debug the situation, I removed all of your patch from the library, except
> the part which contains the fl_get-composed-string,

Seems reasonable, as you had CJK input in the XWorkArea working before.

> But with this part alone, I could'nt import the kbuflen and the keybuf
> from the xforms to WorkArea. This means I need another part in your
> patch, right?  But which part?  I need to know...

Does this pseudo patch (below) fix your problem. It means that the global vars 
will be filled by fl_XLookupString rather than the local ones.

Incidentally, I would be very careful 'fixing' things this way because you are 
going to be receiving many many more calls to XWorkArea's handler because the 
widgets will now be called like so:

        for (ch = keybuf; ch < (keybuf + kbuflen) && keyform; ch++)
                fl_handle_form(keyform, formevent, *ch, xev);

rather than like so:

        /* Dispatch the key event */
        fl_handle_form(keyform, formevent, keysym, xev);

Personally, I would leave my patch in and try and see what is going wrong. Add 
some print statements in the XWorkArea handler! Here's a couple of questions 
I think you should be able to answer:
1. When you precompose another CJK-character, "P", and then hit "space-bar", 
how many XEvents are passed to the XWorkArea handler? Do you get just one or 
do you get two as you described to me the other day. Or do you get even more?
If I remember your description from the other day correctly, the first of 
these two XEvents had 
        keysym=0, keybuf="CJK char"
and the second had
        keysym=XK_space, keybuf=0.
Does this still happen and, if so, do you handle the second event correctly 
now?

2. Can you decipher the keybuf="CJK char" that you obtain? Do you obtain a 
string for 'P' or a string for 'PW'? If the latter, do you need to simply 
ensure that the precomposition buffer is empty when you enter precomposition 
mode?

Anyway, you're the one doing all the hard work. I'll leave it to you to decide 
how best to proceed ;-)

Regards,
Angus

 static void
 do_keyboard(XEvent * xev, int formevent)
 {
        Window win;
-       int kbuflen;

        ...
        if ( keyform ) {
                KeySym keysym = 0;
-               unsigned char keybuf[227];

                kbuflen = fl_XLookupString((XKeyEvent *) xev, (char *) keybuf,
                                                           sizeof(keybuf), &keysym);
                ...

Reply via email to