Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using ibus IME to input Japanese text into GVim. I have the following Vim script that I source when GVim starts up:

autocmd InsertLeave * :call bug#onInsertLeave()
function! bug#onInsertLeave()
  python << EOT
import vim
import ibus
bus = ibus.Bus()
ic = ibus.InputContext(bus, bus.current_input_contxt())
ic.disable()
print "bug#onInsertLeave(): exiting"
EOT
endfunction

The line that constructs the InputContext raises the exception:

dbus.exception.DBusException: org.freedesktop.DBus.Error.Failed: no focused input context

This happens under the following conditions:

  1. I enter insert mode
  2. I insert some Japanese text
  3. I exit insert mode

If I don't enter any Japanese text through the IME, then the exception is not raised.

I've also noticed that if I exit insert mode after entering some Japanese text while the IME is still enabled, then IME input is disabled (I can see the icon change in the taskbar). If I exit insert mode without entering any Japanese text, but while the IME is still enabled, then the IME stays enabled (the icon does not change). It seems like GVim is disabling the IME (or the IME is switching off) in some conditions. Could it be related to the exception?

EDIT I've noticed that this does not happen with the command-line Vim, only GVim. The IME is still disabled, but the above exception is not thrown.

My questions are:

  1. Is this a bug? If it is, then whose bug is it? Vim, Ibus, or something else?
  2. Are there any ways to work around the exception?

EDIT

My system info:

> misha@misha-lmd:~/git/iwait2013/lagos$ apt-cache policy ibus ibus:  
> Installed: 1.4.1-3ubuntu1   Candidate: 1.4.1-3ubuntu1   Version table:
> *** 1.4.1-3ubuntu1 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
>         100 /var/lib/dpkg/status misha@misha-lmd:~/git/iwait2013/lagos$ apt-cache policy vim vim:  
> Installed: 2:7.3.429-2ubuntu2.1   Candidate: 2:7.3.429-2ubuntu2.1  
> Version table:  *** 2:7.3.429-2ubuntu2.1 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
>         100 /var/lib/dpkg/status
>      2:7.3.429-2ubuntu2 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

Ubuntu 12.04, Fluxbox.

EDIT

Confirmed behaviour on Unity as well.

share|improve this question

1 Answer 1

This seems to be mostly expected behaviour. When ibus is active and one, say, moves up to the menu or exits input mode, ibus switches to input method off since it no longer sees a gui element with focus and where entering text is possible. The error message you saw ("no focused input context") is consistent with this. Ibus stays on when you go back to the text window without having performed a command because the ibus context is still alive. The bug is that the ibus context is killed when you do perform an action and follow that with a click in the text window. You're still in insert mode, but the ibus context is dead, you need to turn ibus on again. This doesn't happen in programs like LibreOffice.

I imagine the bug comes from the way vim uses a special insert mode rather than a standard gui event model. Clicking in a text window would normally set the focus on the text area, but here it doesn't. To make it work we need an add-on like ibus-el for emacs. I'm not sure where you should file a bug for this.

For a work around, I think the best thing to do is set a shortcut to enable ibus in the ibus preferences. From the ibus menu > preferences > General tab > enable box. A good one seems to be Ctrl-p since that is right next to the i for enabling input mode and the [ you may be using to exit input mode. I keeps you fingers in the same area. When you're back in the text area, a quick flick with you fingers is much easier than moving the mouse up and clicking twice.

share|improve this answer
    
What is your opinion on this bug? bugs.launchpad.net/bugs/1073839 Do you know of any workarounds? –  misha Mar 20 '13 at 7:15
    
@misha I set up an install with the same versions of everything you list in the bug report, and I cannot recreate the problem you are having. Everything works fine. –  chaskes Mar 21 '13 at 4:25
    
Wow, that's really odd. Thank you for trying to help, anyway. –  misha Mar 21 '13 at 7:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.