We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4782 - IME_SendEditingEvent() always calls SDL_SendEditingText() with incorrect arguments
Summary: IME_SendEditingEvent() always calls SDL_SendEditingText() with incorrect argu...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: All Windows 10
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-01 19:32 UTC by tamo
Modified: 2019-09-02 07:42 UTC (History)
0 users

See Also:


Attachments
not "end" but "length", and fix "start" and "length" (1.16 KB, patch)
2019-09-01 20:24 UTC, tamo
Details | Diff
fix scope (1.87 KB, patch)
2019-09-01 20:30 UTC, tamo
Details | Diff
fix it with correct indent (1.88 KB, patch)
2019-09-01 20:32 UTC, tamo
Details | Diff
fix header and indent (1.89 KB, patch)
2019-09-02 07:31 UTC, tamo
Details | Diff
picture of IME composition (14.52 KB, image/jpeg)
2019-09-02 07:42 UTC, tamo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tamo 2019-09-01 19:32:58 UTC
First, see events/SDL_keyboard_c.h, line 56-57:

> /* Send editing text for selected range from start to end */
> extern int SDL_SendEditingText(const char *text, int start, int end);

But see video/windows/SDL_windowskeyboard.c, line 778:

>     SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0);

The line should be:

>     SDL_SendEditingText(s, videodata->ime_cursor, (int)SDL_wcslen(videodata->ime_readingstring));

or

>     SDL_SendEditingText(s, len, (int)SDL_wcslen(videodata->ime_readingstring));

Otherwise, "start" and "end" are always incorrect.

--
Background: https://github.com/kivy/kivy/pull/6498
Comment 1 tamo 2019-09-01 20:02:50 UTC
Oops, "end" should be "len+wcslen(reading)".

> SDL_SendEditingText(s, len, len + (int)SDL_wcslen(videodata->ime_readingstring));
Comment 2 tamo 2019-09-01 20:15:29 UTC
No, reading events/SDL_keyboard.c and others, the last arg is not "end" but "length."
So events/SDL_keyboard.c is incorrect, too.
Comment 3 tamo 2019-09-01 20:24:24 UTC
Created attachment 3940 [details]
not "end" but "length", and fix "start" and "length"

Fix both header and code
Comment 4 tamo 2019-09-01 20:30:22 UTC
Created attachment 3941 [details]
fix scope

the previous patch didn't build
Comment 5 tamo 2019-09-01 20:32:21 UTC
Created attachment 3942 [details]
fix it with correct indent

fix indent
Comment 6 tamo 2019-09-02 07:31:09 UTC
Created attachment 3943 [details]
fix header and indent

The header is incorrect.
"readingstring" is just a pronunciation, not selection.

In fact, Japanese IMEs hardly use readingstring. (I've never imagined that.)
Comment 7 tamo 2019-09-02 07:42:42 UTC
Created attachment 3944 [details]
picture of IME composition

What I really wanted are, things like GetCompositionTargetRange and GetImeTextSpans in https://github.com/chromium/chromium/blob/master/ui/base/ime/win/imm32_manager.cc code.

So, at least two numbers should be given to the event: target_start and target_end.

See the attached picure.
The red range is the "target" and the yellow spans are "clauses" in IME terms.
The target range is necessary for Japanese. (That's what I thought "readingstring" was.)

Anyway, that's another issue.