[ibus/f16] Fixed Bug 750484 - support reloading Xmodmap

Takao Fujiwara fujiwara at fedoraproject.org
Fri Nov 18 10:56:46 UTC 2011


commit 481f2eee5940f2de0ab81cab48c2c8aefaae9f8b
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date:   Fri Nov 18 19:55:48 2011 +0900

    Fixed Bug 750484 - support reloading Xmodmap
    
    Fixed Bug 753781 - ibus-x11 needs async for hangul ibus_commit_text.

 .gitignore            |    2 +
 ibus-541492-xkb.patch |  166 +++++++++++++++++++++++++++++++++++++++++++----
 ibus-HEAD.patch       |  173 +++++++++++++++++++++++++++++++++++++++++++++++++
 ibus.spec             |   14 +++-
 sources               |    4 +-
 5 files changed, 340 insertions(+), 19 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ee667cc..a161180 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,5 @@ ibus-1.3.6.tar.gz
 /ibus-gjs-3.2.1.20111028.tar.gz
 /ibus-gjs-3.0.2.20111104.tar.gz
 /ibus-gjs-3.2.1.20111104.tar.gz
+/ibus-gjs-3.0.2.20111118.tar.gz
+/ibus-gjs-3.2.1.20111118.tar.gz
diff --git a/ibus-541492-xkb.patch b/ibus-541492-xkb.patch
index d035ee7..8f7cf00 100644
--- a/ibus-541492-xkb.patch
+++ b/ibus-541492-xkb.patch
@@ -1,18 +1,18 @@
-From 10bff3bb3c4ea8ec1316beb47b6d8fcbdfd357bf Mon Sep 17 00:00:00 2001
+From a8f02d4be33f87cf97039736407cd13e795b992b Mon Sep 17 00:00:00 2001
 From: fujiwarat <takao.fujiwara1 at gmail.com>
-Date: Fri, 4 Nov 2011 18:17:29 +0900
+Date: Fri, 18 Nov 2011 18:05:42 +0900
 Subject: [PATCH] Add XKB layouts
 
 ---
  Makefile.am                  |    7 +
  configure.ac                 |   56 +
- data/ibus.schemas.in         |   36 +
+ data/ibus.schemas.in         |   47 +
  ibus-1.0.pc.in               |    2 +
  ibus/Makefile.am             |   26 +
  ibus/__init__.py             |    2 +
  ibus/bus.py                  |    3 +
  ibus/interface/iibus.py      |    3 +
- ibus/xkblayout.py.in         |  231 +++
+ ibus/xkblayout.py.in         |  360 ++++
  ibus/xkbxml.py.in            |  419 ++++
  setup/Makefile.am            |    1 +
  setup/enginecombobox.py      |    7 +-
@@ -38,7 +38,7 @@ Subject: [PATCH] Add XKB layouts
  xkb/xkblib.h                 |   41 +
  xkb/xkbxml.c                 |  345 ++++
  xkb/xkbxml.h                 |  113 ++
- 34 files changed, 9524 insertions(+), 4 deletions(-)
+ 34 files changed, 9664 insertions(+), 4 deletions(-)
  create mode 100644 ibus/xkblayout.py.in
  create mode 100644 ibus/xkbxml.py.in
  create mode 100644 setup/xkbsetup.py
@@ -166,10 +166,10 @@ index f452666..227e28e 100644
    Build gconf modules       $enable_gconf
    Build memconf modules     $enable_memconf
 diff --git a/data/ibus.schemas.in b/data/ibus.schemas.in
-index 663358c..8979515 100644
+index 663358c..e0a6a37 100644
 --- a/data/ibus.schemas.in
 +++ b/data/ibus.schemas.in
-@@ -191,6 +191,42 @@
+@@ -191,6 +191,53 @@
        </locale>
      </schema>
      <schema>
@@ -197,6 +197,17 @@ index 663358c..8979515 100644
 +      </locale>
 +    </schema>
 +    <schema>
++      <key>/schemas/desktop/ibus/general/use_xmodmap</key>
++      <applyto>/desktop/ibus/general/use_xmodmap</applyto>
++      <owner>ibus</owner>
++      <type>bool</type>
++      <default>true</default>
++      <locale name="C">
++        <short>Use xmodmap</short>
++           <long>Run xmodmap if .xmodmap/.Xmodmap exists.</long>
++      </locale>
++    </schema>
++    <schema>
 +      <key>/schemas/desktop/ibus/general/xkb_latin_layouts</key>
 +      <applyto>/desktop/ibus/general/xkb_latin_layouts</applyto>
 +      <owner>ibus</owner>
@@ -309,10 +320,10 @@ index 678d517..7de56fc 100644
  
 diff --git a/ibus/xkblayout.py.in b/ibus/xkblayout.py.in
 new file mode 100644
-index 0000000..9d7468f
+index 0000000..c0c95ce
 --- /dev/null
 +++ b/ibus/xkblayout.py.in
-@@ -0,0 +1,231 @@
+@@ -0,0 +1,360 @@
 +# vim:set et sts=4 sw=4:
 +#
 +# ibus - The Input Bus
@@ -341,15 +352,21 @@ index 0000000..9d7468f
 +    )
 +
 +import os, sys, time
++import glib
 +
 +XKB_COMMAND = @XKB_COMMAND@
 +XKB_SESSION_TIME_OUT = 30.0
++XMODMAP_CMD = 'xmodmap'
++XMODMAP_KNOWN_FILES = ['.xmodmap', '.xmodmaprc', '.Xmodmap', '.Xmodmaprc']
 +
 +class XKBLayout():
 +    def __init__(self, config = None, command=XKB_COMMAND):
 +        self.__config = config
 +        self.__command = command
 +        self.__use_xkb = True
++        self.__xkb_pid = None
++        self.__xmodmap_pid = None
++        self.__use_xmodmap = True
 +        if self.__command == None:
 +            self.__use_xkb = False
 +        self.__default_layout = self.get_layout()
@@ -363,6 +380,9 @@ index 0000000..9d7468f
 +            self.__xkb_latin_layouts = list(self.__config.get_value('general',
 +                                                                    'xkb_latin_layouts',
 +                                                                    []))
++            self.__use_xmodmap = bool(self.__config.get_value('general',
++                                                              'use_xmodmap',
++                                                              True))
 +
 +
 +    def __get_model_from_layout(self, layout):
@@ -391,6 +411,44 @@ index 0000000..9d7468f
 +                break
 +        return retval
 +
++    def __get_userhome(self):
++        if 'HOME' not in os.environ:
++            import pwd
++            userhome = pwd.getpwuid(os.getuid()).pw_dir
++        else:
++            userhome = os.environ['HOME']
++        userhome = userhome.rstrip('/')
++        return userhome
++
++    def __get_fullpath(self, command):
++        if 'PATH' in os.environ:
++            envpath = os.environ['PATH']
++        else:
++            envpath = os.defpath
++        PATH = envpath.split(os.pathsep)
++        for dir in PATH:
++            filepath = os.path.join(dir, command)
++            if os.path.exists(filepath):
++                return filepath
++        return None
++
++    def __set_layout_cb(self, pid, status):
++        if self.__xkb_pid != pid:
++            print >> sys.stderr, \
++                'ibus.xkblayout: set_layout_cb has another pid'
++            return
++        self.__xkb_pid.close()
++        self.__xkb_pid = None
++        self.set_xmodmap()
++
++    def __set_xmodmap_cb(self, pid, status):
++        if self.__xmodmap_pid != pid:
++            print >> sys.stderr, \
++                'ibus.xkblayout: set_xmodmap_cb has another pid'
++            return
++        self.__xmodmap_pid.close()
++        self.__xmodmap_pid = None
++
 +    def use_xkb(self, enable):
 +        if self.__command == None:
 +            return
@@ -486,7 +544,6 @@ index 0000000..9d7468f
 +            return
 +        args = []
 +        args.append(self.__command)
-+        args.append(os.path.basename(self.__command))
 +        args.append('--layout')
 +        args.append(layout)
 +        if model != None:
@@ -495,8 +552,10 @@ index 0000000..9d7468f
 +        if option != None:
 +            args.append('--option')
 +            args.append(option)
-+        pid = os.spawnl(os.P_NOWAIT, *args)
-+        os.waitpid(pid, 0)
++        pid = glib.spawn_async(argv=args,
++                               flags=glib.SPAWN_DO_NOT_REAP_CHILD)[0]
++        self.__xkb_pid = pid
++        glib.child_watch_add(self.__xkb_pid, self.__set_layout_cb)
 +
 +    def set_default_layout(self, layout='default', model='default'):
 +        if not self.__use_xkb:
@@ -544,6 +603,87 @@ index 0000000..9d7468f
 +        self.__default_layout = self.get_layout()
 +        self.__default_model = self.get_model()
 +        self.__default_option = self.get_option()
++
++    def set_xmodmap(self):
++        if not self.__use_xmodmap:
++            return
++        if self.__xmodmap_pid != None:
++            return
++        xmodmap_cmdpath = self.__get_fullpath(XMODMAP_CMD)
++        if xmodmap_cmdpath == None:
++            xmodmap_cmdpath = XMODMAP_CMD
++        for xmodmap_file in XMODMAP_KNOWN_FILES:
++            xmodmap_filepath = os.path.join(self.__get_userhome(), xmodmap_file)
++            if not os.path.exists(xmodmap_filepath):
++                continue
++            pid = glib.spawn_async(argv=[xmodmap_cmdpath, xmodmap_filepath],
++                                   flags=glib.SPAWN_DO_NOT_REAP_CHILD)[0]
++            self.__xmodmap_pid = pid
++            glib.child_watch_add(self.__xmodmap_pid, self.__set_xmodmap_cb)
++            break
++
++
++def test():
++    import gtk
++    import ibus
++
++    window = None
++    config = None
++    xkblayout = None
++
++    def __destroy(*args):
++        window.hide()
++        gtk.main_quit()
++
++    def __test_set_session_xkb(button):
++        xkblayout.set_layout('default')
++        print 'Reset the default keymap'
++        print 'Layout:', xkblayout.get_default_layout()
++        print 'Option:', xkblayout.get_default_option()
++
++    def __test_set_user_xkb(button):
++        layout = 'us'
++        model = 'default'
++        option = 'default'
++        if len(sys.argv) > 1:
++            layout = sys.argv[1]
++        if len(sys.argv) > 2:
++            model = sys.argv[2]
++            if model == 'None':
++                model = None
++        if len(sys.argv) > 3:
++            option = sys.argv[3]
++            if option == 'None':
++                optoin = None
++        xkblayout.set_layout(layout, model, option)
++        print 'Test set_layout:', layout, model, option
++
++    if ibus.get_address() != None:
++        bus = ibus.Bus()
++        config = bus.get_config()
++    else:
++        print 'no ibus'
++    xkblayout = XKBLayout(config)
++    print 'Layout:', xkblayout.get_default_layout()
++    print 'Option:', xkblayout.get_default_option()
++    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
++    window.connect('destroy', __destroy)
++    vb = gtk.VBox()
++    window.add(vb)
++    b = gtk.Button('Test xkb')
++    b.connect('clicked', __test_set_user_xkb)
++    vb.add(b)
++    b = gtk.Button('Reset the default xkb')
++    b.connect('clicked', __test_set_session_xkb)
++    vb.add(b)
++    window.show_all()
++    if config != None:
++        ibus.main()
++    else:
++        gtk.main()
++
++if __name__ == '__main__':
++    test()
 diff --git a/ibus/xkbxml.py.in b/ibus/xkbxml.py.in
 new file mode 100644
 index 0000000..9407c13
@@ -2803,7 +2943,7 @@ index 0000000..6986b5c
 +G_END_DECLS
 +#endif
 diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py
-index 90be1d5..8804634 100644
+index f71a36d..a202d13 100644
 --- a/ui/gtk/panel.py
 +++ b/ui/gtk/panel.py
 @@ -132,6 +132,22 @@ class Panel(ibus.PanelBase):
diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch
index 83f0a41..7d3816e 100644
--- a/ibus-HEAD.patch
+++ b/ibus-HEAD.patch
@@ -323,3 +323,176 @@ index 0a4f3fb..059d660 100644
 -- 
 1.7.6.4
 
+From a8c21dd867f4a9e1c37cae4f6509af1491c5fc96 Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1 at gmail.com>
+Date: Thu, 17 Nov 2011 15:10:05 +0900
+Subject: [PATCH] Use ibus_input_context_process_key_event_async in ibus-x11
+
+---
+ client/x11/main.c |  115 ++++++++++++++++++++++++++++++++++++++++++++---------
+ 1 files changed, 96 insertions(+), 19 deletions(-)
+
+diff --git a/client/x11/main.c b/client/x11/main.c
+index 0ba826c..8611bfc 100644
+--- a/client/x11/main.c
++++ b/client/x11/main.c
+@@ -116,6 +116,8 @@ static gint     g_debug_level = 0;
+ 
+ static IBusBus *_bus = NULL;
+ 
++static gboolean _use_sync_mode = FALSE;
++
+ static void
+ _xim_preedit_start (XIMS xims, const X11IC *x11ic)
+ {
+@@ -443,6 +445,31 @@ xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
+ 
+ }
+ 
++static void
++_process_key_event_done (GObject      *object,
++                         GAsyncResult *res,
++                         gpointer      user_data)
++{
++    IBusInputContext *context = (IBusInputContext *)object;
++    IMForwardEventStruct *pfe = (IMForwardEventStruct*) user_data;
++
++    GError *error = NULL;
++    gboolean retval = ibus_input_context_process_key_event_async_finish (
++            context,
++            res,
++            &error);
++
++    if (error != NULL) {
++        g_warning ("Process Key Event failed: %s.", error->message);
++        g_error_free (error);
++    }
++
++    if (retval == FALSE) {
++        IMForwardEvent (_xims, (XPointer) pfe);
++    }
++    g_free (pfe);
++}
++
+ static int
+ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
+ {
+@@ -469,32 +496,61 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
+     if (event.type == GDK_KEY_RELEASE) {
+         event.state |= IBUS_RELEASE_MASK;
+     }
+-    retval = ibus_input_context_process_key_event (x11ic->context,
+-                                                   event.keyval,
+-                                                   event.hardware_keycode - 8,
+-                                                   event.state);
+-    if (retval) {
+-        if (! x11ic->has_preedit_area) {
+-            _xim_set_cursor_location (x11ic);
++
++    if (_use_sync_mode) {
++        retval = ibus_input_context_process_key_event (
++                                      x11ic->context,
++                                      event.keyval,
++                                      event.hardware_keycode - 8,
++                                      event.state);
++        if (retval) {
++            if (! x11ic->has_preedit_area) {
++                _xim_set_cursor_location (x11ic);
++            }
++            return 1;
+         }
+-        return 1;
+-    }
+ 
+-    IMForwardEventStruct fe;
+-    memset (&fe, 0, sizeof (fe));
++        IMForwardEventStruct fe;
++        memset (&fe, 0, sizeof (fe));
+ 
+-    fe.major_code = XIM_FORWARD_EVENT;
+-    fe.icid = x11ic->icid;
+-    fe.connect_id = x11ic->connect_id;
+-    fe.sync_bit = 0;
+-    fe.serial_number = 0L;
+-    fe.event = call_data->event;
++        fe.major_code = XIM_FORWARD_EVENT;
++        fe.icid = x11ic->icid;
++        fe.connect_id = x11ic->connect_id;
++        fe.sync_bit = 0;
++        fe.serial_number = 0L;
++        fe.event = call_data->event;
+ 
+-    IMForwardEvent (_xims, (XPointer) &fe);
++        IMForwardEvent (_xims, (XPointer) &fe);
+ 
+-    return 1;
++        retval = 1;
++    }
++    else {
++        IMForwardEventStruct *pfe;
++
++        pfe = g_new0 (IMForwardEventStruct, 1);
++        pfe->major_code = XIM_FORWARD_EVENT;
++        pfe->icid = x11ic->icid;
++        pfe->connect_id = x11ic->connect_id;
++        pfe->sync_bit = 0;
++        pfe->serial_number = 0L;
++        memcpy (&pfe->event, xevent, sizeof (XKeyEvent));
++
++        ibus_input_context_process_key_event_async (
++                                      x11ic->context,
++                                      event.keyval,
++                                      event.hardware_keycode - 8,
++                                      event.state,
++                                      -1,
++                                      NULL,
++                                      _process_key_event_done,
++                                      pfe);
++        retval = 1;
++    }
++    return retval;
+ }
+ 
++#undef _XIM_COPY_XKEYEVENT
++
+ 
+ static int
+ xim_open (XIMS xims, IMOpenStruct *call_data)
+@@ -897,6 +953,25 @@ _context_disabled_cb (IBusInputContext *context,
+     _xim_preedit_end (_xims, x11ic);
+ }
+ 
++static gboolean
++_get_boolean_env(const gchar *name,
++                 gboolean     defval)
++{
++    const gchar *value = g_getenv (name);
++
++    if (value == NULL)
++      return defval;
++
++    if (g_strcmp0 (value, "") == 0 ||
++        g_strcmp0 (value, "0") == 0 ||
++        g_strcmp0 (value, "false") == 0 ||
++        g_strcmp0 (value, "False") == 0 ||
++        g_strcmp0 (value, "FALSE") == 0)
++      return FALSE;
++
++    return TRUE;
++}
++
+ static void
+ _init_ibus (void)
+ {
+@@ -909,6 +984,8 @@ _init_ibus (void)
+ 
+     g_signal_connect (_bus, "disconnected",
+                         G_CALLBACK (_bus_disconnected_cb), NULL);
++
++    _use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", FALSE);
+ }
+ 
+ static void
+-- 
+1.7.6.4
+
diff --git a/ibus.spec b/ibus.spec
index 464552d..c235fab 100644
--- a/ibus.spec
+++ b/ibus.spec
@@ -7,16 +7,16 @@
 
 %if 0%{?fedora} > 16
 %define have_bridge_hotkey 1
-%define ibus_gjs_version 3.2.1.20111104
+%define ibus_gjs_version 3.2.1.20111118
 %define ibus_gjs_build_failure 1
 %else
 %if 0%{?fedora} > 15
 %define have_bridge_hotkey 1
-%define ibus_gjs_version 3.2.1.20111104
+%define ibus_gjs_version 3.2.1.20111118
 %define ibus_gjs_build_failure 0
 %else
 %define have_bridge_hotkey 0
-%define ibus_gjs_version 3.0.2.20111104
+%define ibus_gjs_version 3.0.2.20111118
 %define ibus_gjs_build_failure 0
 %endif
 %endif
@@ -30,7 +30,7 @@
 
 Name:       ibus
 Version:    1.4.0
-Release:    10%{?dist}
+Release:    11%{?dist}
 Summary:    Intelligent Input Bus for Linux OS
 License:    LGPLv2+
 Group:      System Environment/Libraries
@@ -406,6 +406,12 @@ fi
 %{_datadir}/gtk-doc/html/*
 
 %changelog
+* Fri Nov 18 2011 Takao Fujiwara <tfujiwar at redhat.com> - 1.4.0-11
+- Updated ibus-541492-xkb.patch
+  Fixed Bug 750484 - support reloading Xmodmap
+- Updated ibus-HEAD.patch
+  Fixed Bug 753781 - ibus-x11 needs async for hangul ibus_commit_text.
+
 * Fri Nov 04 2011 Takao Fujiwara <tfujiwar at redhat.com> - 1.4.0-10
 - Updated ibus-xx-bridge-hotkey.patch for f16
   Fixed no XKB languages from layout only. e.g. in(eng).
diff --git a/sources b/sources
index e9cadd9..03f0ac7 100644
--- a/sources
+++ b/sources
@@ -1,3 +1,3 @@
 b4f063794e89c71eb1f8cb543210da30  ibus-1.4.0.tar.gz
-da885c3a62f509327859d1ed65544693  ibus-gjs-3.0.2.20111104.tar.gz
-d49a93c05a69bcdd65a839381d9fbaa1  ibus-gjs-3.2.1.20111104.tar.gz
+4257048de65ea404389bb941a51db667  ibus-gjs-3.0.2.20111118.tar.gz
+ff5fdd8df5c64f3253ec37db135f336a  ibus-gjs-3.2.1.20111118.tar.gz


More information about the scm-commits mailing list