tdawson / rpms / ibus

Forked from rpms/ibus 3 years ago
Clone
3aca75d
From f33e19bec6ab7d1a6133894c86fdeb5a81ce11f1 Mon Sep 17 00:00:00 2001
3aca75d
From: fujiwarat <takao.fujiwara1@gmail.com>
3aca75d
Date: Wed, 1 Oct 2014 16:21:02 +0900
3aca75d
Subject: [PATCH] Fix to lose a focus when move the focus from the delayed
3aca75d
 focus-in/out.
3aca75d
3aca75d
Some applications likes google-chrome URL entry could have the delayed
3aca75d
focus-in and focus-out events and ibus fails to get the new focus.
3aca75d
3aca75d
BUG=rhbz#919863, rhbz#1136623
3aca75d
3aca75d
Review URL: https://codereview.appspot.com/7725045
3aca75d
---
3aca75d
 bus/inputcontext.c | 28 ++++++++++++++++++++++++++++
3aca75d
 1 file changed, 28 insertions(+)
3aca75d
3aca75d
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
3aca75d
index b7e1ff8..d9924a1 100644
3aca75d
--- a/bus/inputcontext.c
3aca75d
+++ b/bus/inputcontext.c
3aca75d
@@ -773,6 +773,34 @@ _ic_process_key_event  (BusInputContext       *context,
3aca75d
         }
3aca75d
     }
3aca75d
 
3aca75d
+    /* If I move the focus from the URL entry box of google-chrome
3aca75d
+     * to the text buffer of gnome-terminal,
3aca75d
+     * focus-in/focus-out of google-chrome is caused after
3aca75d
+     * focus-in of gonme-terminal and gnome-terminal loses the focus.
3aca75d
+     * The following focus events are received in ibusimcontext:
3aca75d
+     * 1) (gnome-terminal:445): IBUS-WARNING **: 15:32:36:717  focus_in
3aca75d
+     * 2) (google-chrome:495): IBUS-WARNING **: 15:32:36:866  focus_out
3aca75d
+     * 3) (google-chrome:495): IBUS-WARNING **: 15:32:36:875  focus_in
3aca75d
+     * 4) (google-chrome:495): IBUS-WARNING **: 15:32:36:890  focus_out
3aca75d
+     * In 2), Just return because focused_context is not google-chrome.
3aca75d
+     * In 3), focused_context is changed from gnome-terminal to google-chrome
3aca75d
+     * In 4), focused_context is changed from google-chrome to faked_context.
3aca75d
+     *
3aca75d
+     * It seems google-chrome has a popup window of the prediction of URL
3aca75d
+     * and async focus-in/focus-out.
3aca75d
+     */
3aca75d
+    if (context->has_focus && context->engine == NULL &&
3aca75d
+        context->fake == FALSE) {
3aca75d
+        BusInputContext *focused_context =
3aca75d
+                bus_ibus_impl_get_focused_input_context (BUS_DEFAULT_IBUS);
3aca75d
+
3aca75d
+        if (focused_context != NULL && context != focused_context &&
3aca75d
+            (context->capabilities & IBUS_CAP_FOCUS) != 0) {
3aca75d
+            context->has_focus = FALSE;
3aca75d
+            bus_input_context_focus_in (context);
3aca75d
+        }
3aca75d
+    }
3aca75d
+
3aca75d
     /* ignore key events, if it is a fake input context */
3aca75d
     if (context->has_focus && context->engine && context->fake == FALSE) {
3aca75d
         bus_engine_proxy_process_key_event (context->engine,
3aca75d
-- 
3aca75d
1.8.5.3
e08ec45
c019d13
From bb818e438599f080a0cffb0b7573d9a646cf3b1a Mon Sep 17 00:00:00 2001
c019d13
From: fujiwarat <takao.fujiwara1@gmail.com>
c019d13
Date: Tue, 28 Oct 2014 11:28:46 +0900
c019d13
Subject: [PATCH] Fix not to SEGV ibus-ui-gtk3 with wrong 'preload-engines'
c019d13
 value.
c019d13
c019d13
Fedora internal patch could save engines from the result of
c019d13
'setxkbmap -query' but they do not exist in simple.xml likes
c019d13
'xkb:cn::chi' while now the current implementation converts
c019d13
those engines to 'xkb:us::eng'.
c019d13
c019d13
BUG=https://code.google.com/p/ibus/issues/detail?id=1744
c019d13
TEST=ui/gtk3
c019d13
c019d13
Review URL: https://codereview.appspot.com/158640043
c019d13
---
c019d13
 ui/gtk3/panel.vala | 9 +++++++++
c019d13
 1 file changed, 9 insertions(+)
c019d13
c019d13
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
c019d13
index 76cea23..7b99fdf 100644
c019d13
--- a/ui/gtk3/panel.vala
c019d13
+++ b/ui/gtk3/panel.vala
c019d13
@@ -790,6 +790,15 @@ class Panel : IBus.PanelService {
c019d13
 
c019d13
         var engines = m_bus.get_engines_by_names(names);
c019d13
 
c019d13
+        /* Fedora internal patch could save engines not in simple.xml
c019d13
+         * likes 'xkb:cn::chi'.
c019d13
+         */
c019d13
+        if (engines.length == 0) {
c019d13
+            names =  {"xkb:us::eng"};
c019d13
+            m_settings_general.set_strv("preload-engines", names);
c019d13
+            engines = m_bus.get_engines_by_names(names);
c019d13
+	}
c019d13
+
c019d13
         if (m_engines.length == 0) {
c019d13
             m_engines = engines;
c019d13
             switch_engine(0, true);
c019d13
-- 
c019d13
1.8.5.3
c019d13
727f941
From e2507263817926ceb97511da3d617934d4b73443 Mon Sep 17 00:00:00 2001
727f941
From: Osamu Aoki <osamu@debian.org>
727f941
Date: Thu, 13 Nov 2014 11:23:38 +0900
727f941
Subject: [PATCH] ibus-setup tries C since en_US.UTF-8 is not installed in
727f941
 Debian by default.
727f941
727f941
BUG=https://code.google.com/p/ibus/issues/detail?id=1747
727f941
TEST=setup
727f941
727f941
Review URL: https://codereview.appspot.com/166420043
727f941
Patch from Osamu Aoki <osamu@debian.org>.
727f941
---
727f941
 setup/enginecombobox.py |  2 +-
727f941
 setup/enginedialog.py   | 13 +++++++++----
727f941
 2 files changed, 10 insertions(+), 5 deletions(-)
727f941
727f941
diff --git a/setup/enginecombobox.py b/setup/enginecombobox.py
727f941
index 2a2a677..199ed96 100644
727f941
--- a/setup/enginecombobox.py
727f941
+++ b/setup/enginecombobox.py
727f941
@@ -78,7 +78,7 @@ class EngineComboBox(Gtk.ComboBox):
727f941
         keys.sort(key=functools.cmp_to_key(locale.strcoll))
727f941
         loc = locale.getlocale()[0]
727f941
         # None on C locale
727f941
-        if loc == None:
727f941
+        if loc == None or loc == 'C':
727f941
             loc = 'en_US'
727f941
         current_lang = IBus.get_language_name(loc)
727f941
         # move current language to the first place
727f941
diff --git a/setup/enginedialog.py b/setup/enginedialog.py
727f941
index 8a56901..2b179ad 100644
727f941
--- a/setup/enginedialog.py
727f941
+++ b/setup/enginedialog.py
727f941
@@ -325,21 +325,26 @@ class EngineDialog(Gtk.Dialog):
727f941
 
727f941
             # Retrieve Untranslated language names.
727f941
             backup_locale = locale.setlocale(locale.LC_ALL, None)
727f941
-            try:
727f941
-                locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
727f941
+            def __set_untrans_with_locale(en_locale):
727f941
+                locale.setlocale(locale.LC_ALL, en_locale)
727f941
                 untrans = IBus.get_language_name(e.get_language())
727f941
                 if untrans == None:
727f941
                     untrans = ''
727f941
                 self.__untrans_for_lang[l] = untrans
727f941
+            try:
727f941
+                __set_untrans_with_locale('en_US.UTF-8')
727f941
             except locale.Error:
727f941
-                pass
727f941
+                try:
727f941
+                    __set_untrans_with_locale('C')
727f941
+                except locale.Error:
727f941
+                    pass
727f941
             locale.setlocale(locale.LC_ALL, backup_locale)
727f941
 
727f941
         keys = list(self.__engines_for_lang.keys())
727f941
         keys.sort(key=functools.cmp_to_key(locale.strcoll))
727f941
         loc = locale.getlocale()[0]
727f941
         # None on C locale
727f941
-        if loc == None:
727f941
+        if loc == None or loc == 'C':
727f941
             loc = 'en_US'
727f941
         current_lang = IBus.get_language_name(loc)
727f941
         # move current language to the first place
727f941
-- 
727f941
1.8.5.3
727f941
727f941
From de3541d2a26c673f27c068559f6d363064e03760 Mon Sep 17 00:00:00 2001
727f941
From: fujiwarat <takao.fujiwara1@gmail.com>
727f941
Date: Thu, 13 Nov 2014 11:28:43 +0900
727f941
Subject: [PATCH] Remove "Release" modifiers key on ibus-setup.
727f941
727f941
BUG=https://code.google.com/p/ibus/issues/detail?id=1748
727f941
TEST=setup
727f941
727f941
Review URL: https://codereview.appspot.com/167570043
727f941
---
727f941
 setup/keyboardshortcut.py | 12 ++++--------
727f941
 1 file changed, 4 insertions(+), 8 deletions(-)
727f941
727f941
diff --git a/setup/keyboardshortcut.py b/setup/keyboardshortcut.py
727f941
index 91595f7..86463cb 100644
727f941
--- a/setup/keyboardshortcut.py
727f941
+++ b/setup/keyboardshortcut.py
727f941
@@ -105,20 +105,16 @@ class KeyboardShortcutSelection(Gtk.Box):
727f941
                                         Gtk.CheckButton.new_with_mnemonic("_Hyper"),
727f941
                                         Gdk.ModifierType.HYPER_MASK))
727f941
         # <CapsLock> is not parsed by gtk_accelerator_parse()
727f941
-        # FIXME: Need to check if ibus gtk panel can enable <Release>.
727f941
-        self.__modifier_buttons.append(("Release",
727f941
-                                        Gtk.CheckButton.new_with_mnemonic("_Release"),
727f941
-                                        Gdk.ModifierType.RELEASE_MASK))
727f941
+        # <Release> is not supported by XIGrabKeycode()
727f941
         for name, button, mask in self.__modifier_buttons:
727f941
             button.connect("toggled", self.__modifier_button_toggled_cb, name)
727f941
 
727f941
         table.attach(self.__modifier_buttons[0][1], 0, 1, 0, 1)
727f941
         table.attach(self.__modifier_buttons[1][1], 1, 2, 0, 1)
727f941
         table.attach(self.__modifier_buttons[2][1], 2, 3, 0, 1)
727f941
-        table.attach(self.__modifier_buttons[3][1], 3, 4, 0, 1)
727f941
-        table.attach(self.__modifier_buttons[4][1], 0, 1, 1, 2)
727f941
-        table.attach(self.__modifier_buttons[5][1], 1, 2, 1, 2)
727f941
-        table.attach(self.__modifier_buttons[6][1], 2, 3, 1, 2)
727f941
+        table.attach(self.__modifier_buttons[3][1], 0, 1, 1, 2)
727f941
+        table.attach(self.__modifier_buttons[4][1], 1, 2, 1, 2)
727f941
+        table.attach(self.__modifier_buttons[5][1], 2, 3, 1, 2)
727f941
         hbox.pack_start(table, True, True, 4)
727f941
         self.pack_start(hbox, False, True, 4)
727f941
 
727f941
-- 
727f941
1.8.5.3
727f941
727f941
From a7abce698f40e60275c46f05967e8cc369769e4b Mon Sep 17 00:00:00 2001
727f941
From: Peng Wu <alexepico@gmail.com>
727f941
Date: Wed, 19 Nov 2014 18:10:05 +0900
727f941
Subject: [PATCH] Fixes ibus_engine_update_lookup_table_fast method
727f941
727f941
gnome shell needs the previous page and next page
727f941
to correctly show the page up/down arrows,
727f941
send three pages instead of one page.
727f941
727f941
URL: https://bugzilla.gnome.org/show_bug.cgi?id=703020
727f941
727f941
BUG=
727f941
727f941
Review URL: https://codereview.appspot.com/164540045
727f941
Patch from Peng Wu <alexepico@gmail.com>.
727f941
---
727f941
 src/ibusengine.c | 27 ++++++++++++++++++++++-----
727f941
 1 file changed, 22 insertions(+), 5 deletions(-)
727f941
727f941
diff --git a/src/ibusengine.c b/src/ibusengine.c
727f941
index 53d57df..4758f82 100644
727f941
--- a/src/ibusengine.c
727f941
+++ b/src/ibusengine.c
727f941
@@ -1422,12 +1422,17 @@ ibus_engine_update_lookup_table_fast (IBusEngine        *engine,
727f941
                                       IBusLookupTable   *table,
727f941
                                       gboolean           visible)
727f941
 {
727f941
+    /* Note: gnome shell needs the previous page and next page
727f941
+       to correctly show the page up/down arrows,
727f941
+       send three pages instead of one page. */
727f941
+
727f941
     g_return_if_fail (IBUS_IS_ENGINE (engine));
727f941
     g_return_if_fail (IBUS_IS_LOOKUP_TABLE (table));
727f941
 
727f941
     IBusLookupTable *new_table;
727f941
     IBusText *text;
727f941
     gint page_begin;
727f941
+    gint cursor_pos;
727f941
     gint i;
727f941
 
727f941
     if (table->candidates->len < table->page_size << 2) {
727f941
@@ -1436,19 +1441,31 @@ ibus_engine_update_lookup_table_fast (IBusEngine        *engine,
727f941
     }
727f941
 
727f941
     page_begin = (table->cursor_pos / table->page_size) * table->page_size;
727f941
+    cursor_pos = ibus_lookup_table_get_cursor_in_page (table);
727f941
+
727f941
+    if (table->cursor_pos >= table->page_size) {
727f941
+        /* has previous page, adjust the value. */
727f941
+        page_begin -= table->page_size;
727f941
+        cursor_pos += table->page_size;
727f941
+    }
727f941
 
727f941
-    new_table = ibus_lookup_table_new (table->page_size, 0, table->cursor_visible, table->round);
727f941
+    new_table = ibus_lookup_table_new
727f941
+        (table->page_size, 0, table->cursor_visible, table->round);
727f941
 
727f941
-    for (i = page_begin; i < page_begin + table->page_size && i < table->candidates->len; i++) {
727f941
-        ibus_lookup_table_append_candidate (new_table, ibus_lookup_table_get_candidate (table, i));
727f941
+    /* '3' means the previous page, current page and next page. */
727f941
+    for (i = page_begin; i < page_begin + 3 * table->page_size &&
727f941
+             i < table->candidates->len; i++) {
727f941
+        ibus_lookup_table_append_candidate
727f941
+            (new_table, ibus_lookup_table_get_candidate (table, i));
727f941
     }
727f941
 
727f941
     for (i = 0; (text = ibus_lookup_table_get_label (table, i)) != NULL; i++) {
727f941
         ibus_lookup_table_append_label (new_table, text);
727f941
     }
727f941
 
727f941
-    ibus_lookup_table_set_cursor_pos (new_table, ibus_lookup_table_get_cursor_in_page (table));
727f941
-    ibus_lookup_table_set_orientation (new_table, ibus_lookup_table_get_orientation (table));
727f941
+    ibus_lookup_table_set_cursor_pos (new_table, cursor_pos);
727f941
+    ibus_lookup_table_set_orientation
727f941
+        (new_table, ibus_lookup_table_get_orientation (table));
727f941
 
727f941
     ibus_engine_update_lookup_table (engine, new_table, visible);
727f941
 
727f941
-- 
727f941
1.8.5.3
727f941
727f941
From f69ddc3952971c5599c92aee3dc1de6017d07f3c Mon Sep 17 00:00:00 2001
727f941
From: Peng Wu <alexepico@gmail.com>
727f941
Date: Fri, 5 Dec 2014 11:41:08 +0900
727f941
Subject: [PATCH] Fixes ibus_keyval_name method in c++ binding
727f941
727f941
Add G_BEGIN_DECLS and G_END_DECLS macros in src/ibuskeys.h
727f941
727f941
BUG=
727f941
727f941
Review URL: https://codereview.appspot.com/185850043
727f941
Patch from Peng Wu <alexepico@gmail.com>.
727f941
---
727f941
 src/ibuskeys.h | 2 ++
727f941
 1 file changed, 2 insertions(+)
727f941
727f941
diff --git a/src/ibuskeys.h b/src/ibuskeys.h
727f941
index 6acb0d6..7969929 100644
727f941
--- a/src/ibuskeys.h
727f941
+++ b/src/ibuskeys.h
727f941
@@ -29,6 +29,7 @@
727f941
 
727f941
 #include <glib.h>
727f941
 
727f941
+G_BEGIN_DECLS
727f941
 /**
727f941
  * ibus_keyval_name:
727f941
  * @keyval: Key symbol.
727f941
@@ -73,4 +74,5 @@ guint            ibus_unicode_to_keyval (gunichar        wc);
727f941
  **/
727f941
 gunichar         ibus_keyval_to_unicode (guint           keyval);
727f941
 
727f941
+G_END_DECLS
727f941
 #endif // __IBUS_KEYS_H_
727f941
-- 
727f941
1.8.5.3
727f941
727f941
From 097715746da0f56b8b8c3ddae2da3442032bff0c Mon Sep 17 00:00:00 2001
727f941
From: Rui Matos <tiagomatos@gmail.com>
727f941
Date: Fri, 5 Dec 2014 20:25:44 +0900
727f941
Subject: [PATCH] Carry current context content type into fake context when
727f941
 switching
727f941
727f941
When focus moves out of a context to the fake context we should keep
727f941
the content type properties as they were in the focused out context.
727f941
727f941
This allows panel implementations to show the proper UI while input
727f941
focus moves away temporarily from a text entry.
727f941
727f941
E.g. a password entry is focused and the user clicks on the panel
727f941
UI. At this point ibus switches the currently focused context to the
727f941
fake context and emits set-content-type with the fake context
727f941
properties which are empty and thus the panel reacts to it. This isn't
727f941
the intended behavior though since, from a user POV, the password
727f941
entry is still the context that will be getting text input when the
727f941
panel UI gets dismissed.
727f941
727f941
R=shawn.p.huang@gmail.com
727f941
BUG=https://bugzilla.gnome.org/show_bug.cgi?id=730628
727f941
727f941
Review URL: https://codereview.appspot.com/176260043
727f941
Patch from Rui Matos <tiagomatos@gmail.com>.
727f941
---
727f941
 bus/ibusimpl.c     |  6 ++++
727f941
 bus/inputcontext.c | 91 +++++++++++++++++++++++++++++++++---------------------
727f941
 bus/inputcontext.h | 10 ++++++
727f941
 3 files changed, 72 insertions(+), 35 deletions(-)
727f941
727f941
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
727f941
index dd254e2..61f6649 100644
727f941
--- a/bus/ibusimpl.c
727f941
+++ b/bus/ibusimpl.c
727f941
@@ -620,6 +620,8 @@ bus_ibus_impl_set_focused_context (BusIBusImpl     *ibus,
727f941
     }
727f941
 
727f941
     BusEngineProxy *engine = NULL;
727f941
+    guint purpose = 0;
727f941
+    guint hints = 0;
727f941
 
727f941
     if (ibus->focused_context) {
727f941
         if (ibus->use_global_engine) {
727f941
@@ -634,12 +636,16 @@ bus_ibus_impl_set_focused_context (BusIBusImpl     *ibus,
727f941
         if (ibus->panel != NULL)
727f941
             bus_panel_proxy_focus_out (ibus->panel, ibus->focused_context);
727f941
 
727f941
+        bus_input_context_get_content_type (ibus->focused_context,
727f941
+                                            &purpose, &hints);
727f941
         g_object_unref (ibus->focused_context);
727f941
         ibus->focused_context = NULL;
727f941
     }
727f941
 
727f941
     if (context == NULL && ibus->use_global_engine) {
727f941
         context = ibus->fake_context;
727f941
+        if (context)
727f941
+            bus_input_context_set_content_type (context, purpose, hints);
727f941
     }
727f941
 
727f941
     if (context) {
727f941
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
727f941
index d9924a1..ea77102 100644
727f941
--- a/bus/inputcontext.c
727f941
+++ b/bus/inputcontext.c
727f941
@@ -1151,6 +1151,47 @@ bus_input_context_service_method_call (IBusService            *service,
727f941
     g_return_if_reached ();
727f941
 }
727f941
 
727f941
+static void
727f941
+_ic_set_content_type (BusInputContext *context,
727f941
+                      GVariant        *value)
727f941
+{
727f941
+    guint purpose = 0;
727f941
+    guint hints = 0;
727f941
+
727f941
+    g_variant_get (value, "(uu)", &purpose, &hints);
727f941
+    if (purpose != context->purpose || hints != context->hints) {
727f941
+        GError *error;
727f941
+        gboolean retval;
727f941
+
727f941
+        context->purpose = purpose;
727f941
+        context->hints = hints;
727f941
+
727f941
+        if (context->has_focus && context->engine)
727f941
+            bus_engine_proxy_set_content_type (context->engine,
727f941
+                                               purpose,
727f941
+                                               hints);
727f941
+
727f941
+        if (context->has_focus) {
727f941
+            g_signal_emit (context,
727f941
+                           context_signals[SET_CONTENT_TYPE],
727f941
+                           0,
727f941
+                           context->purpose,
727f941
+                           context->hints);
727f941
+        }
727f941
+
727f941
+        error = NULL;
727f941
+        retval = bus_input_context_property_changed (context,
727f941
+                                                     "ContentType",
727f941
+                                                     value,
727f941
+                                                     &error);
727f941
+        if (!retval) {
727f941
+            g_warning ("Failed to emit PropertiesChanged signal: %s",
727f941
+                       error->message);
727f941
+            g_error_free (error);
727f941
+        }
727f941
+    }
727f941
+}
727f941
+
727f941
 static gboolean
727f941
 bus_input_context_service_set_property (IBusService     *service,
727f941
                                         GDBusConnection *connection,
727f941
@@ -1175,41 +1216,7 @@ bus_input_context_service_set_property (IBusService     *service,
727f941
 
727f941
     if (g_strcmp0 (property_name, "ContentType") == 0) {
727f941
         BusInputContext *context = (BusInputContext *) service;
727f941
-        guint purpose = 0;
727f941
-        guint hints = 0;
727f941
-
727f941
-        g_variant_get (value, "(uu)", &purpose, &hints);
727f941
-        if (purpose != context->purpose || hints != context->hints) {
727f941
-            GError *error;
727f941
-            gboolean retval;
727f941
-
727f941
-            context->purpose = purpose;
727f941
-            context->hints = hints;
727f941
-
727f941
-            if (context->has_focus && context->engine)
727f941
-                bus_engine_proxy_set_content_type (context->engine,
727f941
-                                                   purpose,
727f941
-                                                   hints);
727f941
-
727f941
-            if (context->has_focus) {
727f941
-                g_signal_emit (context,
727f941
-                               context_signals[SET_CONTENT_TYPE],
727f941
-                               0,
727f941
-                               context->purpose,
727f941
-                               context->hints);
727f941
-            }
727f941
-
727f941
-            error = NULL;
727f941
-            retval = bus_input_context_property_changed (context,
727f941
-                                                         "ContentType",
727f941
-                                                         value,
727f941
-                                                         &error);
727f941
-            if (!retval) {
727f941
-                g_warning ("Failed to emit PropertiesChanged signal: %s",
727f941
-                           error->message);
727f941
-                g_error_free (error);
727f941
-            }
727f941
-        }
727f941
+        _ic_set_content_type (context, value);
727f941
         return TRUE;
727f941
     }
727f941
 
727f941
@@ -2521,3 +2528,17 @@ bus_input_context_get_content_type (BusInputContext *context,
727f941
     *purpose = context->purpose;
727f941
     *hints = context->hints;
727f941
 }
727f941
+
727f941
+void
727f941
+bus_input_context_set_content_type (BusInputContext *context,
727f941
+                                    guint            purpose,
727f941
+                                    guint            hints)
727f941
+{
727f941
+    GVariant *value;
727f941
+
727f941
+    g_assert (BUS_IS_INPUT_CONTEXT (context));
727f941
+
727f941
+    value = g_variant_ref_sink (g_variant_new ("(uu)", purpose, hints));
727f941
+    _ic_set_content_type (context, value);
727f941
+    g_variant_unref (value);
727f941
+}
727f941
diff --git a/bus/inputcontext.h b/bus/inputcontext.h
727f941
index f282fae..258f501 100644
727f941
--- a/bus/inputcontext.h
727f941
+++ b/bus/inputcontext.h
727f941
@@ -250,5 +250,15 @@ void                 bus_input_context_get_content_type
727f941
                                                  guint              *purpose,
727f941
                                                  guint              *hints);
727f941
 
727f941
+/**
727f941
+ * bus_input_context_set_content_type:
727f941
+ * @purpose: Input purpose.
727f941
+ * @hints: Input hints.
727f941
+ */
727f941
+void                 bus_input_context_set_content_type
727f941
+                                                (BusInputContext *context,
727f941
+                                                 guint            purpose,
727f941
+                                                 guint            hints);
727f941
+
727f941
 G_END_DECLS
727f941
 #endif
727f941
-- 
727f941
1.8.5.3
727f941
727f941
From 8f471ce138a9dc10ab5b1e0c716bb48ca36fe12a Mon Sep 17 00:00:00 2001
727f941
From: Doug Rintoul <doug_rintoul@sil.org>
727f941
Date: Mon, 8 Dec 2014 12:52:00 +0900
727f941
Subject: [PATCH] Show language rather than layout in xkb panel icon
727f941
727f941
BUG=https://code.google.com/p/ibus/issues/detail?id=1753
727f941
TEST=ui/gtk3/ibus-ui-gtk3
727f941
727f941
Review URL: https://codereview.appspot.com/184840043
727f941
Patch from Doug Rintoul <doug_rintoul@sil.org>.
727f941
---
727f941
 ui/gtk3/panel.vala    |  8 ++++----
727f941
 ui/gtk3/switcher.vala | 42 ++++++++++++++++++------------------------
727f941
 2 files changed, 22 insertions(+), 28 deletions(-)
727f941
727f941
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
727f941
index 7b99fdf..4e02140 100644
727f941
--- a/ui/gtk3/panel.vala
727f941
+++ b/ui/gtk3/panel.vala
727f941
@@ -1135,16 +1135,16 @@ class Panel : IBus.PanelService {
727f941
         if (icon_name[0] == '/')
727f941
             m_status_icon.set_from_file(icon_name);
727f941
         else {
727f941
-            string symbol = null;
727f941
+            string language = null;
727f941
 
727f941
             if (engine != null) {
727f941
                 var name = engine.get_name();
727f941
                 if (name.length >= 4 && name[0:4] == "xkb:")
727f941
-                    symbol = m_switcher.get_xkb_symbol(engine);
727f941
+                    language = m_switcher.get_xkb_language(engine);
727f941
             }
727f941
 
727f941
-            if (symbol != null) {
727f941
-                Gdk.Pixbuf pixbuf = create_icon_pixbuf_with_string(symbol);
727f941
+            if (language != null) {
727f941
+                Gdk.Pixbuf pixbuf = create_icon_pixbuf_with_string(language);
727f941
                 m_status_icon.set_from_pixbuf(pixbuf);
727f941
             } else {
727f941
                 var theme = Gtk.IconTheme.get_default();
727f941
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
727f941
index 7601d80..476b159 100644
727f941
--- a/ui/gtk3/switcher.vala
727f941
+++ b/ui/gtk3/switcher.vala
727f941
@@ -21,8 +21,6 @@
727f941
  */
727f941
 
727f941
 class Switcher : Gtk.Window {
727f941
-    private const int DESC_LABEL_MAX_LEN = 20;
727f941
-
727f941
     private class IBusEngineButton : Gtk.Button {
727f941
         public IBusEngineButton(IBus.EngineDesc engine, Switcher switcher) {
727f941
             GLib.Object();
727f941
@@ -38,14 +36,14 @@ class Switcher : Gtk.Window {
727f941
                 icon.set_valign(Gtk.Align.CENTER);
727f941
                 add(icon);
727f941
             } else {
727f941
-                var symbol = switcher.get_xkb_symbol(engine);
727f941
+                var language = switcher.get_xkb_language(engine);
727f941
 
727f941
-                Gtk.Label label = new Gtk.Label(symbol);
727f941
+                Gtk.Label label = new Gtk.Label(language);
727f941
                 label.set_halign(Gtk.Align.CENTER);
727f941
                 label.set_valign(Gtk.Align.CENTER);
727f941
-                string symbol_font = "Monospace Bold 16";
727f941
+                string language_font = "Monospace Bold 16";
727f941
                 string markup = "%s".
727f941
-                        printf(symbol_font, symbol);
727f941
+                        printf(language_font, language);
727f941
 
727f941
                 label.set_markup(markup);
727f941
 
727f941
@@ -89,7 +87,7 @@ class Switcher : Gtk.Window {
727f941
     private uint m_popup_delay_time_id = 0;
727f941
     private int m_root_x;
727f941
     private int m_root_y;
727f941
-    private GLib.HashTable<string, string> m_xkb_symbols =
727f941
+    private GLib.HashTable<string, string> m_xkb_languages =
727f941
             new GLib.HashTable<string, string>(GLib.str_hash,
727f941
                                                GLib.str_equal);
727f941
 
727f941
@@ -268,10 +266,6 @@ class Switcher : Gtk.Window {
727f941
                 return true;
727f941
             });
727f941
 
727f941
-            if (longname.length > DESC_LABEL_MAX_LEN) {
727f941
-                longname = longname[0:DESC_LABEL_MAX_LEN];
727f941
-            }
727f941
-
727f941
             button.longname = longname;
727f941
             m_label.set_label(longname);
727f941
 
727f941
@@ -429,37 +423,37 @@ class Switcher : Gtk.Window {
727f941
         m_popup_delay_time = popup_delay_time;
727f941
     }
727f941
 
727f941
-    public string get_xkb_symbol(IBus.EngineDesc engine) {
727f941
+    public string get_xkb_language(IBus.EngineDesc engine) {
727f941
         var name = engine.get_name();
727f941
 
727f941
         assert(name[0:4] == "xkb:");
727f941
 
727f941
-        var symbol = m_xkb_symbols[name];
727f941
+        var language = m_xkb_languages[name];
727f941
 
727f941
-        if (symbol != null)
727f941
-            return symbol;
727f941
+        if (language != null)
727f941
+            return language;
727f941
 
727f941
-        var layout = engine.get_layout();
727f941
+        language = engine.get_language();
727f941
 
727f941
         /* Maybe invalid layout */
727f941
-        if (layout.length < 2)
727f941
-            return layout;
727f941
+        if (language.length < 2)
727f941
+            return language;
727f941
 
727f941
-        symbol = layout[0:2].up();
727f941
+        language = language[0:2].up();
727f941
 
727f941
         int index = 0;
727f941
 
727f941
-        foreach (var saved_symbol in m_xkb_symbols.get_values()) {
727f941
-            if (symbol == saved_symbol[0:2])
727f941
+        foreach (var saved_language in m_xkb_languages.get_values()) {
727f941
+            if (language == saved_language[0:2])
727f941
                 index++;
727f941
         }
727f941
 
727f941
         if (index > 0) {
727f941
             unichar u = 0x2081 + index;
727f941
-            symbol = "%s%s".printf(symbol, u.to_string());
727f941
+            language = "%s%s".printf(language, u.to_string());
727f941
         }
727f941
 
727f941
-        m_xkb_symbols.insert(name, symbol);
727f941
-        return symbol;
727f941
+        m_xkb_languages.insert(name, language);
727f941
+        return language;
727f941
     }
727f941
 }
727f941
-- 
727f941
1.8.5.3
727f941
35f8a7c
From 576ebc3633aa1fb3076ffac031255c3da4e2cd09 Mon Sep 17 00:00:00 2001
35f8a7c
From: Klemens Baum <klemensbaum@gmail.com>
35f8a7c
Date: Thu, 18 Dec 2014 16:27:23 +0900
35f8a7c
Subject: [PATCH] IMdkit: Track window property offsets correctly
35f8a7c
35f8a7c
The XIM specification requires that XIM tranports over 20 bytes in size
35f8a7c
be transferred via window properties. The sender calls XChangeProperty
35f8a7c
with PropModeAppend, and instructs the recipient via ClientMessage to
35f8a7c
call XGetWindowProperty with delete set to True.
35f8a7c
35f8a7c
Naive implementations exhibit a race condition because the receiver
35f8a7c
could have written more data in the meantime, and XGetWindowProperty
35f8a7c
only deletes the property when bytes_after_return is zero. If
35f8a7c
bytes_after_return is non-zero, it is necessary to use an offset when
35f8a7c
reading from the property again.
35f8a7c
35f8a7c
To ensure that the property data does not grow indefinitely, Xlib
35f8a7c
recycles 21 Atoms in round-robin fashion. Because the XIM specification
35f8a7c
does not limit the number of Atom names of the form "_clientXXX" to be
35f8a7c
used for data transfer over window properties, an XIM server should be
35f8a7c
able to keep of track any number of Atoms, remembering the offset into
35f8a7c
each property.
35f8a7c
35f8a7c
This patch implements correct tracking of property offsets.
35f8a7c
35f8a7c
Signed-off-by: Klemens Baum <klemensbaum@gmail.com>
35f8a7c
Reviewed-by: Keith Packard <keithp@keithp.com>
35f8a7c
35f8a7c
rhbz#1175595
35f8a7c
BUG=https://code.google.com/p/ibus/issues/detail?id=1751
35f8a7c
TEST=client/x11/ibus-x11
35f8a7c
35f8a7c
Review URL: https://codereview.appspot.com/176190044
35f8a7c
Patch from Klemens Baum <klemensbaum@gmail.com>.
35f8a7c
---
35f8a7c
 util/IMdkit/Makefile.am       |  5 ++-
35f8a7c
 util/IMdkit/Xi18n.h           | 23 +++++++++--
35f8a7c
 util/IMdkit/i18nOffsetCache.c | 89 +++++++++++++++++++++++++++++++++++++++++++
35f8a7c
 util/IMdkit/i18nUtil.c        |  9 +++--
35f8a7c
 util/IMdkit/i18nX.c           | 73 ++++++++++++++++++-----------------
35f8a7c
 5 files changed, 154 insertions(+), 45 deletions(-)
35f8a7c
 create mode 100644 util/IMdkit/i18nOffsetCache.c
35f8a7c
35f8a7c
diff --git a/util/IMdkit/Makefile.am b/util/IMdkit/Makefile.am
35f8a7c
index e3946d7..6cbb908 100644
35f8a7c
--- a/util/IMdkit/Makefile.am
35f8a7c
+++ b/util/IMdkit/Makefile.am
35f8a7c
@@ -2,8 +2,8 @@
35f8a7c
 #
35f8a7c
 # ibus - The Input Bus
35f8a7c
 #
35f8a7c
-# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
-# Copyright (c) 2007-2010 Red Hat, Inc.
35f8a7c
+# Copyright (c) 2007-2014 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
+# Copyright (c) 2007-2014 Red Hat, Inc.
35f8a7c
 #
35f8a7c
 # This library is free software; you can redistribute it and/or
35f8a7c
 # modify it under the terms of the GNU Lesser General Public
35f8a7c
@@ -29,6 +29,7 @@ libIMdkit_la_SOURCES = \
35f8a7c
 	i18nIc.c \
35f8a7c
 	i18nIMProto.c \
35f8a7c
 	i18nMethod.c \
35f8a7c
+	i18nOffsetCache.c \
35f8a7c
 	i18nPtHdr.c \
35f8a7c
 	i18nUtil.c \
35f8a7c
 	i18nX.c \
35f8a7c
diff --git a/util/IMdkit/Xi18n.h b/util/IMdkit/Xi18n.h
35f8a7c
index 484cc62..e1d24d5 100644
35f8a7c
--- a/util/IMdkit/Xi18n.h
35f8a7c
+++ b/util/IMdkit/Xi18n.h
35f8a7c
@@ -1,7 +1,9 @@
35f8a7c
 /******************************************************************
35f8a7c
  
35f8a7c
-         Copyright 1994, 1995 by Sun Microsystems, Inc.
35f8a7c
-         Copyright 1993, 1994 by Hewlett-Packard Company
35f8a7c
+         Copyright (C) 1994-1995 Sun Microsystems, Inc.
35f8a7c
+         Copyright (C) 1993-1994 Hewlett-Packard Company
35f8a7c
+         Copyright (C) 2014 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
+         Copyright (C) 2014 Red Hat, Inc.
35f8a7c
  
35f8a7c
 Permission to use, copy, modify, distribute, and sell this software
35f8a7c
 and its documentation for any purpose is hereby granted without fee,
35f8a7c
@@ -45,6 +47,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35f8a7c
 #define XIM_EXT_MOVE				(0x33)
35f8a7c
 #define COMMON_EXTENSIONS_NUM   		3
35f8a7c
 
35f8a7c
+#include <stddef.h>
35f8a7c
 #include <stdlib.h>
35f8a7c
 #include "IMdkit.h"
35f8a7c
 
35f8a7c
@@ -138,6 +141,19 @@ typedef struct
35f8a7c
     char	*name;
35f8a7c
 } XIMExt;
35f8a7c
 
35f8a7c
+typedef struct
35f8a7c
+{
35f8a7c
+    Atom key;
35f8a7c
+    unsigned long offset;
35f8a7c
+} Xi18nAtomOffsetPair;
35f8a7c
+
35f8a7c
+typedef struct
35f8a7c
+{
35f8a7c
+    size_t capacity;
35f8a7c
+    size_t size;
35f8a7c
+    Xi18nAtomOffsetPair *data;
35f8a7c
+} Xi18nOffsetCache;
35f8a7c
+
35f8a7c
 typedef struct _Xi18nClient
35f8a7c
 {
35f8a7c
     int		connect_id;
35f8a7c
@@ -149,8 +165,7 @@ typedef struct _Xi18nClient
35f8a7c
      */
35f8a7c
     int		sync;
35f8a7c
     XIMPending  *pending;
35f8a7c
-    /* property offset to read next data */
35f8a7c
-    long        property_offset;
35f8a7c
+    Xi18nOffsetCache offset_cache;
35f8a7c
     void *trans_rec;		/* contains transport specific data  */
35f8a7c
     struct _Xi18nClient *next;
35f8a7c
 } Xi18nClient;
35f8a7c
diff --git a/util/IMdkit/i18nOffsetCache.c b/util/IMdkit/i18nOffsetCache.c
35f8a7c
new file mode 100644
35f8a7c
index 0000000..c952d5b
35f8a7c
--- /dev/null
35f8a7c
+++ b/util/IMdkit/i18nOffsetCache.c
35f8a7c
@@ -0,0 +1,89 @@
35f8a7c
+/*
35f8a7c
+ * Copyright (C) 2014 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
+ * Copyright (C) 2014 Red Hat, Inc.
35f8a7c
+ *
35f8a7c
+ * Permission to use, copy, modify, distribute, and sell this
35f8a7c
+ * software and its documentation for any purpose is hereby granted
35f8a7c
+ * without fee, provided that the above copyright notice appear in
35f8a7c
+ * all copies and that both that copyright notice and this permission
35f8a7c
+ * notice appear in supporting documentation, and that the name of
35f8a7c
+ * the copyright holders not be used in advertising or publicity
35f8a7c
+ * pertaining to distribution of the software without specific,
35f8a7c
+ * written prior permission.  The copyright holders make no
35f8a7c
+ * representations about the suitability of this software for any
35f8a7c
+ * purpose.  It is provided "as is" without express or implied
35f8a7c
+ * warranty.
35f8a7c
+ *
35f8a7c
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
35f8a7c
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
35f8a7c
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
35f8a7c
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
35f8a7c
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
35f8a7c
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
35f8a7c
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
35f8a7c
+ * THIS SOFTWARE.
35f8a7c
+ *
35f8a7c
+ * Author: Klemens Baum <klemensbaum@gmail.com>
35f8a7c
+ */
35f8a7c
+
35f8a7c
+#include <X11/Xlib.h>
35f8a7c
+#include <stddef.h>
35f8a7c
+#include "IMdkit.h"
35f8a7c
+#include "Xi18n.h"
35f8a7c
+
35f8a7c
+/*
35f8a7c
+ * The XIM specification does not limit the number of window properties
35f8a7c
+ * that can be used to transfer data, but Xlib uses the atom strings
35f8a7c
+ * _client0 through _client20.
35f8a7c
+ *
35f8a7c
+ * So use that as a sensible initial size for the offset cache.
35f8a7c
+ */
35f8a7c
+#define INITIAL_OFFSET_CACHE_CAPACITY 21
35f8a7c
+#define OFFSET_CACHE_GROWTH_FACTOR 2
35f8a7c
+
35f8a7c
+void _Xi18nInitOffsetCache (Xi18nOffsetCache *offset_cache)
35f8a7c
+{
35f8a7c
+    offset_cache->size = 0;
35f8a7c
+    offset_cache->capacity = INITIAL_OFFSET_CACHE_CAPACITY;
35f8a7c
+    offset_cache->data = (Xi18nAtomOffsetPair *) malloc (
35f8a7c
+        INITIAL_OFFSET_CACHE_CAPACITY * sizeof (Xi18nAtomOffsetPair));
35f8a7c
+}
35f8a7c
+
35f8a7c
+unsigned long _Xi18nLookupPropertyOffset (Xi18nOffsetCache *offset_cache,
35f8a7c
+                                          Atom key)
35f8a7c
+{
35f8a7c
+    Xi18nAtomOffsetPair *data = offset_cache->data;
35f8a7c
+    size_t i;
35f8a7c
+
35f8a7c
+    for (i = 0; i < offset_cache->size; ++i) {
35f8a7c
+        if (data[i].key == key) {
35f8a7c
+            return data[i].offset;
35f8a7c
+        }
35f8a7c
+    }
35f8a7c
+
35f8a7c
+    return 0;
35f8a7c
+}
35f8a7c
+
35f8a7c
+void _Xi18nSetPropertyOffset (Xi18nOffsetCache *offset_cache, Atom key,
35f8a7c
+                              unsigned long offset)
35f8a7c
+{
35f8a7c
+    Xi18nAtomOffsetPair *data = offset_cache->data;
35f8a7c
+    size_t i;
35f8a7c
+
35f8a7c
+    for (i = 0; i < offset_cache->size; ++i) {
35f8a7c
+        if (data[i].key == key) {
35f8a7c
+            data[i].offset = offset;
35f8a7c
+            return;
35f8a7c
+        }
35f8a7c
+    }
35f8a7c
+
35f8a7c
+    if (++offset_cache->size > offset_cache->capacity) {
35f8a7c
+        offset_cache->capacity *= OFFSET_CACHE_GROWTH_FACTOR;
35f8a7c
+        offset_cache->data = data = (Xi18nAtomOffsetPair *) realloc (data,
35f8a7c
+                offset_cache->capacity * sizeof (Xi18nAtomOffsetPair));
35f8a7c
+    }
35f8a7c
+
35f8a7c
+    data[i].key = key;
35f8a7c
+    data[i].offset = offset;
35f8a7c
+}
35f8a7c
+
35f8a7c
diff --git a/util/IMdkit/i18nUtil.c b/util/IMdkit/i18nUtil.c
35f8a7c
index c07de48..6557bd1 100644
35f8a7c
--- a/util/IMdkit/i18nUtil.c
35f8a7c
+++ b/util/IMdkit/i18nUtil.c
35f8a7c
@@ -1,7 +1,9 @@
35f8a7c
 /******************************************************************
35f8a7c
  
35f8a7c
-         Copyright 1994, 1995 by Sun Microsystems, Inc.
35f8a7c
-         Copyright 1993, 1994 by Hewlett-Packard Company
35f8a7c
+         Copyright (C) 1994-1995 Sun Microsystems, Inc.
35f8a7c
+         Copyright (C) 1993-1994 Hewlett-Packard Company
35f8a7c
+         Copyright (C) 2014 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
+         Copyright (C) 2014 Red Hat, Inc.
35f8a7c
  
35f8a7c
 Permission to use, copy, modify, distribute, and sell this software
35f8a7c
 and its documentation for any purpose is hereby granted without fee,
35f8a7c
@@ -36,6 +38,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35f8a7c
 #include "XimFunc.h"
35f8a7c
 
35f8a7c
 Xi18nClient *_Xi18nFindClient (Xi18n, CARD16);
35f8a7c
+void _Xi18nInitOffsetCache (Xi18nOffsetCache *);
35f8a7c
 
35f8a7c
 int
35f8a7c
 _Xi18nNeedSwap (Xi18n i18n_core, CARD16 connect_id)
35f8a7c
@@ -70,7 +73,7 @@ Xi18nClient *_Xi18nNewClient(Xi18n i18n_core)
35f8a7c
     client->sync = False;
35f8a7c
     client->byte_order = '?'; 	/* initial value */
35f8a7c
     memset (&client->pending, 0, sizeof (XIMPending *));
35f8a7c
-    client->property_offset = 0;
35f8a7c
+    _Xi18nInitOffsetCache (&client->offset_cache);
35f8a7c
     client->next = i18n_core->address.clients;
35f8a7c
     i18n_core->address.clients = client;
35f8a7c
 
35f8a7c
diff --git a/util/IMdkit/i18nX.c b/util/IMdkit/i18nX.c
35f8a7c
index 0a54058..8385aba 100644
35f8a7c
--- a/util/IMdkit/i18nX.c
35f8a7c
+++ b/util/IMdkit/i18nX.c
35f8a7c
@@ -1,7 +1,9 @@
35f8a7c
 /******************************************************************
35f8a7c
  
35f8a7c
-         Copyright 1994, 1995 by Sun Microsystems, Inc.
35f8a7c
-         Copyright 1993, 1994 by Hewlett-Packard Company
35f8a7c
+         Copyright (C) 1994-1995 Sun Microsystems, Inc.
35f8a7c
+         Copyright (C) 1993-1994 Hewlett-Packard Company
35f8a7c
+         Copyright (C) 2014 Peng Huang <shawn.p.huang@gmail.com>
35f8a7c
+         Copyright (C) 2014 Red Hat, Inc.
35f8a7c
  
35f8a7c
 Permission to use, copy, modify, distribute, and sell this software
35f8a7c
 and its documentation for any purpose is hereby granted without fee,
35f8a7c
@@ -29,6 +31,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35f8a7c
  
35f8a7c
 ******************************************************************/
35f8a7c
 
35f8a7c
+#include <stddef.h>
35f8a7c
 #include <limits.h>
35f8a7c
 #include <X11/Xlib.h>
35f8a7c
 #include <X11/Xatom.h>
35f8a7c
@@ -38,12 +41,14 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35f8a7c
 #include "Xi18nX.h"
35f8a7c
 #include "XimFunc.h"
35f8a7c
 
35f8a7c
-extern Xi18nClient *_Xi18nFindClient(Xi18n, CARD16);
35f8a7c
-extern Xi18nClient *_Xi18nNewClient(Xi18n);
35f8a7c
-extern void _Xi18nDeleteClient(Xi18n, CARD16);
35f8a7c
-static Bool WaitXConnectMessage(Display*, Window,
35f8a7c
-                                XEvent*, XPointer);
35f8a7c
-static Bool WaitXIMProtocol(Display*, Window, XEvent*, XPointer);
35f8a7c
+extern Xi18nClient *_Xi18nFindClient (Xi18n, CARD16);
35f8a7c
+extern Xi18nClient *_Xi18nNewClient (Xi18n);
35f8a7c
+extern void _Xi18nDeleteClient (Xi18n, CARD16);
35f8a7c
+extern unsigned long _Xi18nLookupPropertyOffset (Xi18nOffsetCache *, Atom);
35f8a7c
+extern void _Xi18nSetPropertyOffset (Xi18nOffsetCache *, Atom, unsigned long);
35f8a7c
+static Bool WaitXConnectMessage (Display*, Window,
35f8a7c
+                                 XEvent*, XPointer);
35f8a7c
+static Bool WaitXIMProtocol (Display*, Window, XEvent*, XPointer);
35f8a7c
 
35f8a7c
 static XClient *NewXClient (Xi18n i18n_core, Window new_client)
35f8a7c
 {
35f8a7c
@@ -129,7 +134,6 @@ static unsigned char *ReadXIMMessage (XIMS ims,
35f8a7c
     else if (ev->format == 32) {
35f8a7c
         /* ClientMessage and WindowProperty */
35f8a7c
         unsigned long length = (unsigned long) ev->data.l[0];
35f8a7c
-        unsigned long get_length;
35f8a7c
         Atom atom = (Atom) ev->data.l[1];
35f8a7c
         int return_code;
35f8a7c
         Atom actual_type_ret;
35f8a7c
@@ -137,21 +141,28 @@ static unsigned char *ReadXIMMessage (XIMS ims,
35f8a7c
         unsigned long bytes_after_ret;
35f8a7c
         unsigned char *prop;
35f8a7c
         unsigned long nitems;
35f8a7c
-
35f8a7c
-        /* Round up length to next 4 byte value. */
35f8a7c
-        get_length = length + 3;
35f8a7c
-        if (get_length > LONG_MAX)
35f8a7c
-            get_length = LONG_MAX;
35f8a7c
-        get_length /= 4;
35f8a7c
-        if (get_length == 0) {
35f8a7c
-            fprintf(stderr, "%s: invalid length 0\n", __func__);
35f8a7c
+        Xi18nOffsetCache *offset_cache = &client->offset_cache;
35f8a7c
+        unsigned long offset;
35f8a7c
+        unsigned long end;
35f8a7c
+        unsigned long long_begin;
35f8a7c
+        unsigned long long_end;
35f8a7c
+
35f8a7c
+        if (length == 0) {
35f8a7c
+            fprintf (stderr, "%s: invalid length 0\n", __func__);
35f8a7c
             return NULL;
35f8a7c
         }
35f8a7c
+
35f8a7c
+        offset = _Xi18nLookupPropertyOffset (offset_cache, atom);
35f8a7c
+        end = offset + length;
35f8a7c
+
35f8a7c
+        /* The property data is retrieved in 32-bit chunks */
35f8a7c
+        long_begin = offset / 4;
35f8a7c
+        long_end = (end + 3) / 4;
35f8a7c
         return_code = XGetWindowProperty (i18n_core->address.dpy,
35f8a7c
                                           x_client->accept_win,
35f8a7c
                                           atom,
35f8a7c
-                                          client->property_offset / 4,
35f8a7c
-                                          get_length,
35f8a7c
+                                          long_begin,
35f8a7c
+                                          long_end - long_begin,
35f8a7c
                                           True,
35f8a7c
                                           AnyPropertyType,
35f8a7c
                                           &actual_type_ret,
35f8a7c
@@ -162,32 +173,22 @@ static unsigned char *ReadXIMMessage (XIMS ims,
35f8a7c
         if (return_code != Success || actual_format_ret == 0 || nitems == 0) {
35f8a7c
             if (return_code == Success)
35f8a7c
                 XFree (prop);
35f8a7c
-            client->property_offset = 0;
35f8a7c
+            fprintf (stderr,
35f8a7c
+                    "(XIM-IMdkit) ERROR: XGetWindowProperty failed.\n"
35f8a7c
+                    "Protocol data is likely to be inconsistent.\n");
35f8a7c
+            _Xi18nSetPropertyOffset (offset_cache, atom, 0);
35f8a7c
             return (unsigned char *) NULL;
35f8a7c
         }
35f8a7c
         /* Update the offset to read next time as needed */
35f8a7c
         if (bytes_after_ret > 0)
35f8a7c
-            client->property_offset += length;
35f8a7c
+            _Xi18nSetPropertyOffset (offset_cache, atom, offset + length);
35f8a7c
         else
35f8a7c
-            client->property_offset = 0;
35f8a7c
-        switch (actual_format_ret) {
35f8a7c
-        case 8:
35f8a7c
-        case 16:
35f8a7c
-        case 32:
35f8a7c
-            length = nitems * actual_format_ret / 8;
35f8a7c
-            break;
35f8a7c
-        default:
35f8a7c
-            fprintf(stderr, "%s: unknown property return format: %d\n",
35f8a7c
-                        __func__, actual_format_ret);
35f8a7c
-            XFree(prop);
35f8a7c
-            client->property_offset = 0;
35f8a7c
-            return NULL;
35f8a7c
-        }
35f8a7c
+            _Xi18nSetPropertyOffset (offset_cache, atom, 0);
35f8a7c
         /* if hit, it might be an error */
35f8a7c
         if ((p = (unsigned char *) malloc (length)) == NULL)
35f8a7c
             return (unsigned char *) NULL;
35f8a7c
 
35f8a7c
-        memmove (p, prop, length);
35f8a7c
+        memcpy (p, prop + (offset % 4), length);
35f8a7c
         XFree (prop);
35f8a7c
     }
35f8a7c
     return (unsigned char *) p;
35f8a7c
-- 
35f8a7c
2.1.0
35f8a7c
5863468
From bfa4d75bac29f77828e4ed38ebec6af2e6d96144 Mon Sep 17 00:00:00 2001
5863468
From: fujiwarat <takao.fujiwara1@gmail.com>
5863468
Date: Mon, 2 Feb 2015 16:15:37 +0900
5863468
Subject: [PATCH] Release registry observed_paths and components if they are 
5863468
 broken
5863468
5863468
Registry caches might be broken in a disk.
5863468
---
5863468
 src/ibusregistry.c | 20 +++++++++++++++++---
5863468
 1 file changed, 17 insertions(+), 3 deletions(-)
5863468
5863468
diff --git a/src/ibusregistry.c b/src/ibusregistry.c
5863468
index 2830a08..8e9ada9 100644
5863468
--- a/src/ibusregistry.c
5863468
+++ b/src/ibusregistry.c
5863468
@@ -1,9 +1,9 @@
5863468
 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
5863468
 /* vim:set et sts=4: */
5863468
 /* bus - The Input Bus
5863468
- * Copyright (C) 2013 Peng Huang <shawn.p.huang@gmail.com>
5863468
- * Copyright (C) 2013 Takao Fujiwara <takao.fujiwara1@gmail.com>
5863468
- * Copyright (C) 2013 Red Hat, Inc.
5863468
+ * Copyright (C) 2015 Peng Huang <shawn.p.huang@gmail.com>
5863468
+ * Copyright (C) 2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
5863468
+ * Copyright (C) 2015 Red Hat, Inc.
5863468
  *
5863468
  * This library is free software; you can redistribute it and/or
5863468
  * modify it under the terms of the GNU Lesser General Public
5863468
@@ -374,12 +374,26 @@ ibus_registry_check_modification (IBusRegistry *registry)
5863468
     g_assert (IBUS_IS_REGISTRY (registry));
5863468
 
5863468
     for (p = registry->priv->observed_paths; p != NULL; p = p->next) {
5863468
+        if (!IBUS_IS_OBSERVED_PATH (p->data)) {
5863468
+            g_warning ("The registry cache of observed_paths might be " \
5863468
+                       "broken and have to generate the cache again.");
5863468
+            g_list_free_full (registry->priv->observed_paths, g_object_unref);
5863468
+            registry->priv->observed_paths = NULL;
5863468
+            return TRUE;
5863468
+        }
5863468
         if (ibus_observed_path_check_modification (
5863468
                     (IBusObservedPath *) p->data))
5863468
             return TRUE;
5863468
     }
5863468
 
5863468
     for (p = registry->priv->components; p != NULL; p = p->next) {
5863468
+        if (!IBUS_IS_COMPONENT (p->data)) {
5863468
+            g_warning ("The registry cache of components might be " \
5863468
+                       "broken and have to generate the cache again.");
5863468
+            g_list_free_full (registry->priv->components, g_object_unref);
5863468
+            registry->priv->components = NULL;
5863468
+            return TRUE;
5863468
+        }
5863468
         if (ibus_component_check_modification ((IBusComponent *) p->data))
5863468
             return TRUE;
5863468
     }
5863468
-- 
5863468
2.1.0
5863468