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 2662 - A few small issues with the Ibus IME code
Summary: A few small issues with the Ibus IME code
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.1
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-27 15:48 UTC by Alex Baines
Modified: 2014-08-20 05:01 UTC (History)
1 user (show)

See Also:


Attachments
[Patch 1/2] Fix shadowing + Send event when candidate list closes. (1.90 KB, patch)
2014-07-27 15:48 UTC, Alex Baines
Details | Diff
[Patch 2/2] Position the candidate list correctly. (2.53 KB, patch)
2014-07-27 15:48 UTC, Alex Baines
Details | Diff
[Patch 2/2] Position the candidate list correctly. (2.57 KB, patch)
2014-07-27 18:13 UTC, Alex Baines
Details | Diff
Extra patch: Add a hint so that IBus works better with apps that don't handle TEXTEDITING events. (6.03 KB, patch)
2014-07-30 00:02 UTC, Alex Baines
Details | Diff
Extra patch: Add a hint to allow IMs to work better with apps that don't handle TEXTEDITING events. (6.07 KB, patch)
2014-07-30 02:01 UTC, Alex Baines
Details | Diff
[Patch 1/2] Position the candidate list correctly. (1.77 KB, patch)
2014-08-19 22:40 UTC, Alex Baines
Details | Diff
[Patch 2/2] Handle HidePreeditText IBus signal, clean up other IBus stuff as listed in the patch header. (6.08 KB, patch)
2014-08-19 22:42 UTC, Alex Baines
Details | Diff
Optional Extra patch: Add SDL_IM_INTERNAL_EDITING hint to let IBus handle showing the preedit text. (4.27 KB, patch)
2014-08-19 22:44 UTC, Alex Baines
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Baines 2014-07-27 15:48:10 UTC
Created attachment 1789 [details]
[Patch 1/2] Fix shadowing + Send event when candidate list closes.

Here are a couple of patches that fix a few issues with the current ibus IME code:

+ Fix variable name shadowing in SDL_ibus.c
+ Send a blank SDL_TextEditingEvent when the candidate list closes due to pressing backspace.
+ Take the window border size into account when positioning the candidate list.
Comment 1 Alex Baines 2014-07-27 15:48:45 UTC
Created attachment 1790 [details]
[Patch 2/2] Position the candidate list correctly.
Comment 2 Sik 2014-07-27 17:25:22 UTC
Just tested it, I can confirm this patch works.
Comment 3 Alex Baines 2014-07-27 18:13:54 UTC
Created attachment 1791 [details]
[Patch 2/2] Position the candidate list correctly.

Better version of patch 2/2 that will compile even with --disable-video-x11.
Comment 4 Alex Baines 2014-07-30 00:02:09 UTC
Created attachment 1795 [details]
Extra patch: Add a hint so that IBus works better with apps that don't handle TEXTEDITING events.

I just made a new patch that adds some more IBus functionality and I thought I should put it here so that I don't spam the bug tracker with new IBus related things.

It adds a SDL_IBUS_EDITING_EVENTS hint which lets SDL know that you want to render the editing text yourself. 

With this patch, IBus does the editing stuff in its own UI by default. This works a lot better with applications that only look at the TEXTINPUT events and not the TEXTEDITING ones as well.

If you want to get the TEXTEDITING events and do the rendering of text as it is being editing then you can set this hint to 1 with SDL_SetHint(SDL_HINT_IBUS_EDITING_EVENTS, "1");

If this should be put in a separate bug then let me know.
Comment 5 Sik 2014-07-30 01:03:16 UTC
But doesn't calling SDL_StartTextInput basically imply that you will handle the SDL_TEXTEDITING events? Also this issue isn't specific to iBus as far as I know, all systems that support IME-style input suffer from it.

So I see two issues from this patch:

1) It breaks compatibility with programs written before it, since they won't explicitly set the hint even though they already handle the situation.

2) It's iBus-specific, when it's trying to solve a problem that happens on all platforms.

Probably there's a better solution.
Comment 6 Alex Baines 2014-07-30 01:16:37 UTC
(In reply to Sik from comment #5)
> But doesn't calling SDL_StartTextInput basically imply that you will handle
> the SDL_TEXTEDITING events? 

Well, you also have to call it to get the TEXTINPUT events, and for a lot of programs that's all they bother to handle.

> Also this issue isn't specific to iBus as far as
> I know, all systems that support IME-style input suffer from it.

Maybe, I'm not that familiar with how other IMEs work with SDL. I think the ibus internal editing is very useful though, for programs already out there that don't handle the editing events, ibus will "just work" with the new SDL lib swapped in.

> So I see two issues from this patch:
> 
> 1) It breaks compatibility with programs written before it, since they won't
> explicitly set the hint even though they already handle the situation.

True, but since IBus support has only recently been added I don't see this being a huge deal. (It's only available in HG currently). You can also override it by setting the SDL_IBUS_EDITING_EVENTS environment variable to 1.

> 2) It's iBus-specific, when it's trying to solve a problem that happens on
> all platforms.

Since iBus includes the functionality to do the editing itself I don't see why we shouldn't expose it in SDL somehow, even if other IMEs don't.

> Probably there's a better solution.

Maybe, this is something that works without adding any new APIs though. Perhaps reversing the default, so that you have to set the hint to get iBus to do the work would be better.
Comment 7 Sik 2014-07-30 01:29:31 UTC
(completely forgot about the reply button)

(In reply to Alex Baines from comment #6)
> True, but since IBus support has only recently been added I don't see this
> being a huge deal. (It's only available in HG currently). You can also
> override it by setting the SDL_IBUS_EDITING_EVENTS environment variable to 1.

Programs that had already added IME support for the systems where it worked, they would automatically start using iBus if rebuilt even with the same source code (just updating SDL). This patch would require changing the program source code to have the same behavior as normal.

> Maybe, this is something that works without adding any new APIs though.
> Perhaps reversing the default, so that you have to set the hint to get iBus
> to do the work would be better.

Probably, though changing the name to not be iBus specific would be nice too (in case this is implemented for other IMEs, or even emulated).
Comment 8 Alex Baines 2014-07-30 02:01:39 UTC
Created attachment 1796 [details]
Extra patch: Add a hint to allow IMs to work better with apps that don't handle TEXTEDITING events.

> Programs that had already added IME support for the systems where it worked,
> they would automatically start using iBus if rebuilt even with the same
> source code (just updating SDL). This patch would require changing the
> program source code to have the same behavior as normal.

Ok, that's a good point. What about changing the default then? That way it should work fine with those programs.

Also users could set the hint themselves as an environment variable for alredy-compiled programs that don't look at the editing events.

> Probably, though changing the name to not be iBus specific would be nice too
> (in case this is implemented for other IMEs, or even emulated).

I suppose changing the name is a good idea too, in case other IMEs want to do the same thing.

Here's a new version of the patch that swaps the default, and renames the hint.
Comment 9 Sik 2014-07-30 02:53:09 UTC
Yeah, this seems better regarding those issues. Nothing else I can think of at the moment, so this should be fine I believe.
Comment 10 Alex Baines 2014-08-19 22:40:50 UTC
Created attachment 1832 [details]
[Patch 1/2] Position the candidate list correctly.

Updating the patches to apply with the latest hg revision. 

The shadowing has been fixed by someone else, so I've put the HidePreeditText signal handling that was originally in the shadowing-fix patch along with a few more minor changes in a new patch.

Also I swapped the ordering of the patches by mistake, so the candidate list position fix should be applied first now.
Comment 11 Alex Baines 2014-08-19 22:42:17 UTC
Created attachment 1833 [details]
[Patch 2/2] Handle HidePreeditText IBus signal, clean up other IBus stuff as listed in the patch header.
Comment 12 Alex Baines 2014-08-19 22:44:39 UTC
Created attachment 1834 [details]
Optional Extra patch: Add SDL_IM_INTERNAL_EDITING hint to let IBus handle showing the preedit text.
Comment 13 Sam Lantinga 2014-08-20 05:01:37 UTC
These patches look great, thanks!
https://hg.libsdl.org/SDL/rev/ed277c1c9e7f
https://hg.libsdl.org/SDL/rev/6454f71d6f15
https://hg.libsdl.org/SDL/rev/56d712662a82

I changed the name of the hint to match SDL IME naming convention:
https://hg.libsdl.org/SDL/rev/064ea0b1275c