How to get cursor position of McCLIM

176 views Asked by At

I'm trying to add Input Method supportto McCLIM so that it can input CJK in McCLIM, using input method client like fcitx.

To draw fcitx better, I want to get the cursor position of text editing area when it changed.

looks like this: enter image description here

I found something called cursor-position/stream-cursor-position, but I don't know how to get the cursor/stream currently focus on. I have tried *standard-output*, but it failed.

How could I do this?

1

There are 1 answers

2
csslayer On BEST ANSWER

I know you're not using libx11, but I'd like just show you how libX11 do this.

Basically this is done by XIM_SET_IC_VALUES in the protocol. The values the spot location within a nested value of preedit attributes.

The spot is simply a X point (x, y). Despite of that, the point is a relative coordinates to the focus window. The focus window is also a part of ic vlaues, with property name XNFocusWindow.

If you don't set focus window, the client window that passed through XCreateIC will be used as the focus window.

    XVaNestedList preedit_attr;
    preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &nspot, NULL);
    XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL);
    XFree(preedit_attr);