Fix for those not running IBus, where the IBus workaround caused broken keys in other keymaps set with non-IBus tools

(New dependancy added (python-psutil) for detecting the IBus process)
This commit is contained in:
Stephen Boddy 2015-09-16 00:05:30 +02:00
parent c24eb103bd
commit 4953117023
5 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,11 @@
terminator trunk:
* Features
* Enhancements
* Bug fixes
* Fix for those not running IBus, where the IBus workaround caused
broken keys in other keymaps set with non-IBus tools (Steve
Boddy, LP#1494606)
terminator 0.98: terminator 0.98:
* Features * Features
* Layout launcher with option or shortcut (Steve Boddy) * Layout launcher with option or shortcut (Steve Boddy)

2
debian/control vendored
View File

@ -14,7 +14,7 @@ Homepage: http://www.tenshu.net/terminator/
Package: terminator Package: terminator
Architecture: all Architecture: all
Depends: ${python:Depends}, ${misc:Depends}, python-vte, python-gobject, python-gtk2 (>= 2.14.0), gconf2, libgtk2.0-bin, hicolor-icon-theme Depends: ${python:Depends}, ${misc:Depends}, python-vte, python-gobject, python-gtk2 (>= 2.14.0), python-psutil, gconf2, libgtk2.0-bin, hicolor-icon-theme
XB-Python-Version: ${python:Versions} XB-Python-Version: ${python:Versions}
Provides: x-terminal-emulator Provides: x-terminal-emulator
Recommends: xdg-utils, python-gnome2, python-keybinder Recommends: xdg-utils, python-gnome2, python-keybinder

View File

@ -20,6 +20,8 @@
import sys import sys
import os import os
import psutil
import pwd
try: try:
ORIGCWD = os.getcwd() ORIGCWD = os.getcwd()
except OSError: except OSError:
@ -57,7 +59,11 @@ if __name__ == '__main__':
# Workaround for IBus intefering with broadcast when using dead keys # Workaround for IBus intefering with broadcast when using dead keys
# Environment also needs IBUS_DISABLE_SNOOPER=1, or double chars appear # Environment also needs IBUS_DISABLE_SNOOPER=1, or double chars appear
# in the receivers. # in the receivers.
os.environ['IBUS_DISABLE_SNOOPER']='1' username = pwd.getpwuid(os.getuid()).pw_name
ibus_running = [p for p in psutil.process_iter() if p.name == 'ibus-daemon' and p.username == username]
ibus_running = len(ibus_running) > 0
if ibus_running:
os.environ['IBUS_DISABLE_SNOOPER']='1'
dbus_service = None dbus_service = None
@ -69,7 +75,6 @@ if __name__ == '__main__':
# launch gui, return selection # launch gui, return selection
LAYOUTLAUNCHER=LayoutLauncher() LAYOUTLAUNCHER=LayoutLauncher()
else: else:
# Attempt to import our dbus server. If one exists already we will just # Attempt to import our dbus server. If one exists already we will just
# connect to that and ask for a new window. If not, we will create one and # connect to that and ask for a new window. If not, we will create one and
# continue. Failure to import dbus, or the global config option "dbus" # continue. Failure to import dbus, or the global config option "dbus"
@ -112,6 +117,7 @@ if __name__ == '__main__':
TERMINATOR.set_origcwd(ORIGCWD) TERMINATOR.set_origcwd(ORIGCWD)
TERMINATOR.set_dbus_data(dbus_service) TERMINATOR.set_dbus_data(dbus_service)
TERMINATOR.reconfigure() TERMINATOR.reconfigure()
TERMINATOR.ibus_running = ibus_running
try: try:
dbg('Creating a terminal with layout: %s' % OPTIONS.layout) dbg('Creating a terminal with layout: %s' % OPTIONS.layout)

View File

@ -844,12 +844,13 @@ class Terminal(gtk.VBox):
dbg('Terminal::on_keypress: Called on %s with no event' % widget) dbg('Terminal::on_keypress: Called on %s with no event' % widget)
return(False) return(False)
# Workaround for IBus intefering with broadcast when using dead keys # Workaround for IBus interfering with broadcast when using dead keys
# Environment also needs IBUS_DISABLE_SNOOPER=1, or double chars appear # Environment also needs IBUS_DISABLE_SNOOPER=1, or double chars appear
# in the receivers. # in the receivers.
if (event.state | gtk.gdk.MODIFIER_MASK ) ^ gtk.gdk.MODIFIER_MASK != 0: if self.terminator.ibus_running:
dbg('Terminal::on_keypress: Ingore processed event with event.state %d' % event.state) if (event.state | gtk.gdk.MODIFIER_MASK ) ^ gtk.gdk.MODIFIER_MASK != 0:
return(False) dbg('Terminal::on_keypress: Ignore processed event with event.state %d' % event.state)
return(False)
# FIXME: Does keybindings really want to live in Terminator()? # FIXME: Does keybindings really want to live in Terminator()?
mapping = self.terminator.keybindings.lookup(event) mapping = self.terminator.keybindings.lookup(event)

View File

@ -32,6 +32,7 @@ class Terminator(Borg):
pid_cwd = None pid_cwd = None
gnome_client = None gnome_client = None
debug_address = None debug_address = None
ibus_running = None
doing_layout = None doing_layout = None
layoutname = None layoutname = None