Bug 164428 - inputMethodQuery (Qt::ImMicroFocus) can not get the correct cursor pos
Summary: inputMethodQuery (Qt::ImMicroFocus) can not get the correct cursor pos
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-19 02:21 UTC by Huang Peng
Modified: 2012-11-01 16:11 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
screenshot (48.78 KB, image/png)
2008-06-19 02:27 UTC, Huang Peng
Details
screenshot, the cursor pos is correct in file open dialog of kwrite (191.48 KB, image/png)
2008-06-19 02:30 UTC, Huang Peng
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Huang Peng 2008-06-19 02:21:51 UTC
Version:           4.0.5 (using KDE 4.0.5)
Installed from:    Fedora RPMs
OS:                Linux

I am developing a new QInputContext. I use widget::inputMethodQuery (Qt::ImMicroFocus) to get current cursor pos.  If there is not any preedit string, the returned cursor pos will be OK. If I set preedit string & cursor pos in preedit string via QInputContext::sendEvent, the returned cursor pos will be wrong, the cursor pos will point to the begin of the preedit string, it should be the cursor pos in preedit string. Please check it.
Comment 1 Huang Peng 2008-06-19 02:27:29 UTC
Created attachment 25449 [details]
screenshot
Comment 2 Huang Peng 2008-06-19 02:30:30 UTC
Created attachment 25450 [details]
screenshot, the cursor pos is correct in file open dialog of kwrite

screenshot, the cursor pos is correct in file open dialog of kwrite
Comment 3 Hamish Rodda 2008-06-23 05:20:58 UTC
SVN commit 823329 by rodda:

We're supposed to return the start position of the preedit, not the text cursor

Please test, and if it's correct I'll backport it.

BUG:164428


 M  +4 -1      kateviewinternal.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=823329
Comment 4 Huang Peng 2008-06-23 06:02:16 UTC
I just reviewed the commit 823329. You did not modified Qt::ImMicroFocus's return value.
I tested dolphin and edit field in open dialog, I found:
Qt::ImMicroFocus : return the cursor's position in widget.
like: QVariant(QRect, QRect(133,2 10x16) ), It is cursor's coordinate in widget.
Qt::Qt::ImCursorPosition : Return the logical position (or index) of the cursor within the text surrounding the input area.
like: QVariant(int, 20), It's an int value. And the current preedit is QVariant(QString, "/home/phuangaaaaaaaa").
Comment 6 Huang Peng 2008-08-18 08:37:21 UTC
I found KateViewInternal (http://websvn.kde.org/?view=rev&revision=823329) has a problem with IM.  In inputMethodQuery method, Kate returns a point for Qt::ImCursorPosition. But I think it should return an integer value ( the index of current edit cursor in SurroundingText). Please below reference from Qt document.

{{{
Qt::ImMicroFocus 0 The rectangle covering the area of the input cursor in widget coordinates.
Qt::ImFont 1 The currently used font for text input.
Qt::ImCursorPosition 2 The logical position of the cursor within the text surrounding the input area (see ImSurroundingText).
Qt::ImSurroundingText 3 The plain text around the input area, for example the current paragraph.
Qt::ImCurrentSelection 4 The currently selected text.
}}}
Comment 7 Christoph Cullmann 2012-11-01 16:11:23 UTC
Seems to be fixed in kate.git master:

    case Qt::ImCursorPosition:
      return m_imPreeditRange ? m_imPreeditRange->start().column() : 0;

And otherwise the code looks ok, too, given your above statement what it should do from the Qt docs.