Blame SOURCES/ibus-HEAD.patch

359ab2
From 7edaefdc1d80aefdbbc2dc52526c20715759da83 Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Wed, 22 Aug 2018 17:20:53 +0900
359ab2
Subject: [PATCH] ui/gtk3: Do not clear unicode data when emoji annotation lang
359ab2
 is changed
359ab2
359ab2
---
359ab2
 ui/gtk3/emojier.vala | 8 ++++++--
359ab2
 1 file changed, 6 insertions(+), 2 deletions(-)
359ab2
359ab2
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
359ab2
index 85dcdceb..637ae049 100644
359ab2
--- a/ui/gtk3/emojier.vala
359ab2
+++ b/ui/gtk3/emojier.vala
359ab2
@@ -440,13 +440,17 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
         m_emoji_to_emoji_variants_dict =
359ab2
                 new GLib.HashTable<string, GLib.SList<string>>(GLib.str_hash,
359ab2
                                                                GLib.str_equal);
359ab2
-        m_unicode_to_data_dict =
359ab2
+        if (m_unicode_to_data_dict == null) {
359ab2
+            m_unicode_to_data_dict =
359ab2
                 new GLib.HashTable<unichar, IBus.UnicodeData>(
359ab2
                         GLib.direct_hash,
359ab2
                         GLib.direct_equal);
359ab2
-        m_name_to_unicodes_dict =
359ab2
+        }
359ab2
+        if (m_name_to_unicodes_dict == null) {
359ab2
+            m_name_to_unicodes_dict =
359ab2
                 new GLib.HashTable<string, GLib.SList<unichar>>(GLib.str_hash,
359ab2
                                                                 GLib.str_equal);
359ab2
+        }
359ab2
     }
359ab2
 
359ab2
 
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From 28d22176aee6be97d88dd6c60fa5395c79563ec0 Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Thu, 30 Aug 2018 12:57:33 +0900
359ab2
Subject: [PATCH] ui/gtk3: Fix SEGV when type ASCII on emojier
359ab2
359ab2
Emojier still included Gtk.Entry, accepted key events in Wayland,
359ab2
reset the lookup table and it caused SEGV because IBus.Text
359ab2
is NULL in the lookup table in Emojier.get_current_candidate().
359ab2
Now Gtk.Entry is deleted completely.
359ab2
359ab2
BUG=rhbz#1618682
359ab2
---
359ab2
 ui/gtk3/emojier.vala | 139 +------------------------------------------
359ab2
 1 file changed, 1 insertion(+), 138 deletions(-)
359ab2
359ab2
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
359ab2
index 637ae049..0f455800 100644
359ab2
--- a/ui/gtk3/emojier.vala
359ab2
+++ b/ui/gtk3/emojier.vala
359ab2
@@ -283,7 +283,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
 
359ab2
     private ThemedRGBA m_rgba;
359ab2
     private Gtk.Box m_vbox;
359ab2
-    private EEntry m_entry;
359ab2
     /* If emojier is emoji category list or Unicode category list,
359ab2
      * m_annotation is "" and preedit is also "".
359ab2
      * If emojier is candidate mode, m_annotation is an annotation and
359ab2
@@ -367,23 +366,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
         m_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
359ab2
         add(m_vbox);
359ab2
 
359ab2
-        m_entry = new EEntry();
359ab2
-        m_entry.set_placeholder_text(_("Type annotation or choose emoji"));
359ab2
-        //m_vbox.add(m_entry);
359ab2
-        m_entry.changed.connect(() => {
359ab2
-            update_candidate_window();
359ab2
-        });
359ab2
-        m_entry.icon_release.connect((icon_pos, event) => {
359ab2
-            hide_candidate_panel();
359ab2
-        });
359ab2
-
359ab2
-        /* Set the accessible role of the label to a status bar so it
359ab2
-         * will emit name changed events that can be used by screen
359ab2
-         * readers.
359ab2
-         */
359ab2
-        Atk.Object obj = m_entry.get_accessible();
359ab2
-        obj.set_role (Atk.Role.STATUSBAR);
359ab2
-
359ab2
         // The constructor of IBus.LookupTable does not support more than
359ab2
         // 16 pages.
359ab2
         m_lookup_table = new IBus.LookupTable(1, 0, true, true);
359ab2
@@ -1806,18 +1788,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
                 m_lookup_table.cursor_up();
359ab2
             else if (keyval == Gdk.Key.Right)
359ab2
                 m_lookup_table.cursor_down();
359ab2
-        } else if (m_entry.get_text().length > 0) {
359ab2
-            int step = 0;
359ab2
-            if (keyval == Gdk.Key.Left)
359ab2
-                step = -1;
359ab2
-            else if (keyval == Gdk.Key.Right)
359ab2
-                step = 1;
359ab2
-            GLib.Signal.emit_by_name(
359ab2
-                    m_entry, "move-cursor",
359ab2
-                    Gtk.MovementStep.VISUAL_POSITIONS,
359ab2
-                    step,
359ab2
-                    (modifiers & Gdk.ModifierType.SHIFT_MASK) != 0
359ab2
-                            ? true : false);
359ab2
         } else {
359ab2
             // For Gdk.Key.f and Gdk.Key.b
359ab2
             if (keyval == Gdk.Key.Left)
359ab2
@@ -1880,20 +1850,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             }
359ab2
             return true;
359ab2
         }
359ab2
-        if (m_entry.get_text().length > 0) {
359ab2
-            int step = 0;
359ab2
-            if (keyval == Gdk.Key.Home)
359ab2
-                step = -1;
359ab2
-            else if (keyval == Gdk.Key.End)
359ab2
-                step = 1;
359ab2
-            GLib.Signal.emit_by_name(
359ab2
-                    m_entry, "move-cursor",
359ab2
-                    Gtk.MovementStep.DISPLAY_LINE_ENDS,
359ab2
-                    step,
359ab2
-                    (modifiers & Gdk.ModifierType.SHIFT_MASK) != 0
359ab2
-                            ? true : false);
359ab2
-            return true;
359ab2
-        }
359ab2
         return category_list_cursor_move(keyval);
359ab2
     }
359ab2
 
359ab2
@@ -1941,28 +1897,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    private void entry_enter_keyval(uint keyval) {
359ab2
-        unichar ch = IBus.keyval_to_unicode(keyval);
359ab2
-        if (ch.iscntrl())
359ab2
-            return;
359ab2
-        string str = ch.to_string();
359ab2
-
359ab2
-        // what gtk_entry_commit_cb() do
359ab2
-        if (m_entry.get_selection_bounds(null, null)) {
359ab2
-            m_entry.delete_selection();
359ab2
-        } else {
359ab2
-            if (m_entry.get_overwrite_mode()) {
359ab2
-               uint text_length = m_entry.get_buffer().get_length();
359ab2
-               if (m_entry.cursor_position < text_length)
359ab2
-                   m_entry.delete_from_cursor(Gtk.DeleteType.CHARS, 1);
359ab2
-            }
359ab2
-        }
359ab2
-        int pos = m_entry.get_position();
359ab2
-        m_entry.insert_text(str, -1, ref pos);
359ab2
-        m_entry.set_position(pos);
359ab2
-    }
359ab2
-
359ab2
-
359ab2
     private Gdk.Rectangle get_monitor_geometry() {
359ab2
         Gdk.Rectangle monitor_area = { 0, };
359ab2
 
359ab2
@@ -2245,10 +2179,7 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
         /* Let gtk recalculate the window size. */
359ab2
         resize(1, 1);
359ab2
 
359ab2
-        m_entry.set_text("");
359ab2
-
359ab2
         show_category_list();
359ab2
-        m_entry.set_activates_default(true);
359ab2
         show_all();
359ab2
 
359ab2
         /* Some window managers, e.g. MATE, GNOME, Plasma desktops,
359ab2
@@ -2289,13 +2220,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
         m_loop.run();
359ab2
         m_loop = null;
359ab2
 
359ab2
-        // Need focus-out on Gtk.Entry to send the emoji to applications.
359ab2
-        Gdk.Event fevent = new Gdk.Event(Gdk.EventType.FOCUS_CHANGE);
359ab2
-        fevent.focus_change.in = 0;
359ab2
-        fevent.focus_change.window  = get_window();
359ab2
-        m_entry.send_focus_change(fevent);
359ab2
-        fevent.focus_change.window  = null;
359ab2
-
359ab2
         hide();
359ab2
         // Make sure the switcher is hidden before returning from this function.
359ab2
         while (Gtk.events_pending())
359ab2
@@ -2357,36 +2281,9 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
                 hide();
359ab2
             }
359ab2
             return true;
359ab2
-        case Gdk.Key.BackSpace:
359ab2
-            if (m_entry.get_text().length > 0) {
359ab2
-                if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
359ab2
-                                             Gtk.DeleteType.WORD_ENDS, -1);
359ab2
-                } else {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "backspace");
359ab2
-                }
359ab2
-                return true;
359ab2
-            }
359ab2
-            break;
359ab2
-        case Gdk.Key.Delete:
359ab2
-        case Gdk.Key.KP_Delete:
359ab2
-            if (m_entry.get_text().length > 0) {
359ab2
-                if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
359ab2
-                                             Gtk.DeleteType.WORD_ENDS, 1);
359ab2
-                } else {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
359ab2
-                                             Gtk.DeleteType.CHARS, 1);
359ab2
-                }
359ab2
-                return true;
359ab2
-            }
359ab2
-            break;
359ab2
         case Gdk.Key.space:
359ab2
         case Gdk.Key.KP_Space:
359ab2
-            if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
359ab2
-                if (m_entry.get_text().length > 0)
359ab2
-                    entry_enter_keyval(keyval);
359ab2
-            } else if (m_candidate_panel_is_visible) {
359ab2
+            if (m_candidate_panel_is_visible) {
359ab2
                 enter_notify_disable_with_timer();
359ab2
                 m_lookup_table.cursor_down();
359ab2
                 show_candidate_panel();
359ab2
@@ -2436,10 +2333,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             key_press_cursor_home_end(Gdk.Key.End, modifiers);
359ab2
             show_all();
359ab2
             return true;
359ab2
-        case Gdk.Key.Insert:
359ab2
-        case Gdk.Key.KP_Insert:
359ab2
-            GLib.Signal.emit_by_name(m_entry, "toggle-overwrite");
359ab2
-            return true;
359ab2
         }
359ab2
 
359ab2
         if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
359ab2
@@ -2470,27 +2363,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
                 key_press_cursor_home_end(Gdk.Key.End, modifiers);
359ab2
                 show_all();
359ab2
                 return true;
359ab2
-            case Gdk.Key.u:
359ab2
-                if (m_entry.get_text().length > 0) {
359ab2
-                    GLib.Signal.emit_by_name(m_entry,
359ab2
-                                             "delete-from-cursor",
359ab2
-                                             Gtk.DeleteType.PARAGRAPH_ENDS,
359ab2
-                                             -1);
359ab2
-                    return true;
359ab2
-                }
359ab2
-                break;
359ab2
-            case Gdk.Key.a:
359ab2
-                if (m_entry.get_text().length > 0) {
359ab2
-                    m_entry.select_region(0, -1);
359ab2
-                    return true;
359ab2
-                }
359ab2
-                break;
359ab2
-            case Gdk.Key.x:
359ab2
-                if (m_entry.get_text().length > 0) {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "cut-clipboard");
359ab2
-                    return true;
359ab2
-                }
359ab2
-                break;
359ab2
             case Gdk.Key.C:
359ab2
             case Gdk.Key.c:
359ab2
                 if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
359ab2
@@ -2503,19 +2375,11 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
                         clipboard.store();
359ab2
                         return true;
359ab2
                     }
359ab2
-                } else if (m_entry.get_text().length > 0) {
359ab2
-                    GLib.Signal.emit_by_name(m_entry, "copy-clipboard");
359ab2
-                    return true;
359ab2
                 }
359ab2
                 break;
359ab2
-            case Gdk.Key.v:
359ab2
-                GLib.Signal.emit_by_name(m_entry, "paste-clipboard");
359ab2
-                return true;
359ab2
             }
359ab2
             return false;
359ab2
         }
359ab2
-
359ab2
-        entry_enter_keyval(keyval);
359ab2
         return true;
359ab2
     }
359ab2
 
359ab2
@@ -2595,7 +2459,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
 
359ab2
         uint32 timestamp = event.get_time();
359ab2
         present_with_time(timestamp);
359ab2
-        m_entry.set_activates_default(true);
359ab2
     }
359ab2
 
359ab2
 
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From e6badb494e0a31b7aca3a5078a5dc5b27b83390d Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Thu, 30 Aug 2018 12:57:46 +0900
359ab2
Subject: [PATCH] ui/gtk3: Support Shift-Space to insert a Space on Emojier
359ab2
 preedit
359ab2
359ab2
Implemented Shift-Space on preedit since Shift-Space had worked on
359ab2
Emojier's GtkEntry in the previous release.
359ab2
---
359ab2
 ui/gtk3/panelbinding.vala | 27 ++++++++++++++++++++-------
359ab2
 1 file changed, 20 insertions(+), 7 deletions(-)
359ab2
359ab2
diff --git a/ui/gtk3/panelbinding.vala b/ui/gtk3/panelbinding.vala
359ab2
index 981b5509..4ebff8da 100644
359ab2
--- a/ui/gtk3/panelbinding.vala
359ab2
+++ b/ui/gtk3/panelbinding.vala
359ab2
@@ -548,6 +548,19 @@ class PanelBinding : IBus.PanelService {
359ab2
     }
359ab2
 
359ab2
 
359ab2
+    private bool key_press_keyval(uint keyval) {
359ab2
+        unichar ch = IBus.keyval_to_unicode(keyval);
359ab2
+        if (ch.iscntrl())
359ab2
+                return false;
359ab2
+        string str = ch.to_string();
359ab2
+        m_preedit.append_text(str);
359ab2
+        string annotation = m_preedit.get_text();
359ab2
+        m_emojier.set_annotation(annotation);
359ab2
+        m_preedit.set_emoji("");
359ab2
+        return true;
359ab2
+    }
359ab2
+
359ab2
+
359ab2
     private bool key_press_enter() {
359ab2
         if (m_extension_name != "unicode" && is_emoji_lookup_table()) {
359ab2
             // Check if variats exist
359ab2
@@ -899,6 +912,12 @@ class PanelBinding : IBus.PanelService {
359ab2
             break;
359ab2
         case Gdk.Key.space:
359ab2
         case Gdk.Key.KP_Space:
359ab2
+            if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
359ab2
+                if (!key_press_keyval(keyval))
359ab2
+                    return true;
359ab2
+                show_candidate = is_emoji_lookup_table();
359ab2
+                break;
359ab2
+            }
359ab2
             show_candidate = key_press_space();
359ab2
             if (m_extension_name == "unicode") {
359ab2
                 key_press_enter();
359ab2
@@ -979,14 +998,8 @@ class PanelBinding : IBus.PanelService {
359ab2
                 show_candidate = key_press_control_keyval(keyval, modifiers);
359ab2
                 break;
359ab2
             }
359ab2
-            unichar ch = IBus.keyval_to_unicode(keyval);
359ab2
-            if (ch.iscntrl())
359ab2
+            if (!key_press_keyval(keyval))
359ab2
                 return true;
359ab2
-            string str = ch.to_string();
359ab2
-            m_preedit.append_text(str);
359ab2
-            string annotation = m_preedit.get_text();
359ab2
-            m_emojier.set_annotation(annotation);
359ab2
-            m_preedit.set_emoji("");
359ab2
             show_candidate = is_emoji_lookup_table();
359ab2
             break;
359ab2
         }
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From 809d880337e75b7cee429292a238bf53899bef6a Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Thu, 30 Aug 2018 12:58:57 +0900
359ab2
Subject: [PATCH] ui/gtk3: Do not move Emojier popup with the active
359ab2
 candidate in Xorg
359ab2
359ab2
Probably I think it's not useful to change the popup position frequently.
359ab2
The popup size is always slightly changed with the emoji annotation length.
359ab2
---
359ab2
 ui/gtk3/emojier.vala | 10 +++++++++-
359ab2
 1 file changed, 9 insertions(+), 1 deletion(-)
359ab2
359ab2
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
359ab2
index 0f455800..9811fde5 100644
359ab2
--- a/ui/gtk3/emojier.vala
359ab2
+++ b/ui/gtk3/emojier.vala
359ab2
@@ -1944,7 +1944,15 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             x = 0;
359ab2
 
359ab2
         bool changed = false;
359ab2
-        if (window_right_bottom.y > monitor_bottom) {
359ab2
+        // Do not up side down frequently.
359ab2
+        // The first pos does not show the lookup table yet but the
359ab2
+        // preedit only and the second pos shows the lookup table.
359ab2
+        if (m_lookup_table.get_cursor_pos() != 1) {
359ab2
+            if (m_is_up_side_down)
359ab2
+                y = m_cursor_location.y - allocation.height;
359ab2
+            else
359ab2
+                y = cursor_right_bottom.y;
359ab2
+        } else if (window_right_bottom.y > monitor_bottom) {
359ab2
             y = m_cursor_location.y - allocation.height;
359ab2
             // Do not up side down in Wayland
359ab2
             if (m_input_context_path == "") {
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From 1c6565e205528a45e88a84ba2a328f9035875c8d Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Fri, 14 Sep 2018 16:15:41 +0900
359ab2
Subject: [PATCH] ui/gtk3: Fix SEGV when commit an emoji on Emojier in Wayland
359ab2
359ab2
Just pressing Space key without emoji annotations can launch Emojier
359ab2
popup and the popup takes a focus in Wayland and the chosen emoji is
359ab2
output when the original text application gets the focus after Emojier
359ab2
popup release the focus. Emojier disabled Ctrl-Shift-e after got the focus.
359ab2
But currently GNOME Wayland has a bug not to send focus-in until a
359ab2
key press or mouse click happens [1] and Emojier causes a SEGV.
359ab2
Now Emojier disables Ctrl-Shift-e immediately when an emoji is chosen
359ab2
whether focus-in comes or not and fixes the SEGV.
359ab2
359ab2
[1] https://gitlab.gnome.org/GNOME/gnome-shell/issues/573
359ab2
359ab2
BUG=rhbz#1625187
359ab2
---
359ab2
 ui/gtk3/emojier.vala      | 63 +++++++-------------------------------
359ab2
 ui/gtk3/emojierapp.vala   |  2 +-
359ab2
 ui/gtk3/panelbinding.vala | 64 ++++++++++++++++++++++++++-------------
359ab2
 3 files changed, 55 insertions(+), 74 deletions(-)
359ab2
359ab2
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
359ab2
index 9811fde5..e23ef889 100644
359ab2
--- a/ui/gtk3/emojier.vala
359ab2
+++ b/ui/gtk3/emojier.vala
359ab2
@@ -21,17 +21,6 @@
359ab2
  */
359ab2
 
359ab2
 public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
-    private class EEntry : Gtk.SearchEntry {
359ab2
-        public EEntry() {
359ab2
-            GLib.Object(
359ab2
-                name : "IBusEmojierEntry",
359ab2
-                margin_start : 6,
359ab2
-                margin_end : 6,
359ab2
-                margin_top : 6,
359ab2
-                margin_bottom : 6
359ab2
-            );
359ab2
-        }
359ab2
-    }
359ab2
     private class EListBox : Gtk.ListBox {
359ab2
         public EListBox() {
359ab2
             GLib.Object(
359ab2
@@ -330,6 +319,7 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
     private uint m_redraw_window_id;
359ab2
 
359ab2
     public signal void candidate_clicked(uint index, uint button, uint state);
359ab2
+    public signal void commit_text(string text);
359ab2
 
359ab2
     public IBusEmojier() {
359ab2
         GLib.Object(
359ab2
@@ -380,12 +370,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             adjust_window_position();
359ab2
         });
359ab2
 
359ab2
-        candidate_clicked.connect((i, b, s) => {
359ab2
-            if (m_input_context_path != "")
359ab2
-                candidate_panel_select_index(i, b);
359ab2
-        });
359ab2
-
359ab2
-
359ab2
         if (m_annotation_to_emojis_dict == null) {
359ab2
             reload_emoji_dict();
359ab2
         }
359ab2
@@ -1641,34 +1625,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    private void candidate_panel_select_index(uint index,
359ab2
-                                              uint button) {
359ab2
-        if (button == BUTTON_CLOSE_BUTTON) {
359ab2
-            hide();
359ab2
-            if (m_candidate_panel_mode &&
359ab2
-                m_lookup_table.get_number_of_candidates() > 0) {
359ab2
-                // Call remove_all_children() instead of show_category_list()
359ab2
-                // so that show_category_list do not remove children with
359ab2
-                // PageUp/PageDown.
359ab2
-                remove_all_children();
359ab2
-            }
359ab2
-            m_result = "";
359ab2
-            return;
359ab2
-        }
359ab2
-        string text = m_lookup_table.get_candidate(index).text;
359ab2
-        unowned GLib.SList<string>? emojis =
359ab2
-                m_emoji_to_emoji_variants_dict.lookup(text);
359ab2
-        if (m_show_emoji_variant && emojis != null &&
359ab2
-            m_backward_index < 0) {
359ab2
-            show_emoji_variants(emojis);
359ab2
-            show_all();
359ab2
-        } else {
359ab2
-            m_result = text;
359ab2
-            hide();
359ab2
-        }
359ab2
-    }
359ab2
-
359ab2
-
359ab2
     private void candidate_panel_cursor_down() {
359ab2
         enter_notify_disable_with_timer();
359ab2
         uint ncandidates = m_lookup_table.get_number_of_candidates();
359ab2
@@ -1762,7 +1718,8 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    public bool has_variants(uint index) {
359ab2
+    public bool has_variants(uint index,
359ab2
+                             bool need_commit_signal) {
359ab2
         if (index >= m_lookup_table.get_number_of_candidates())
359ab2
             return false;
359ab2
         string text = m_lookup_table.get_candidate(index).text;
359ab2
@@ -1773,6 +1730,10 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             show_emoji_variants(emojis);
359ab2
             return true;
359ab2
         }
359ab2
+        if (m_input_context_path != "")
359ab2
+            m_result = text;
359ab2
+        if (need_commit_signal)
359ab2
+            commit_text(text);
359ab2
         return false;
359ab2
     }
359ab2
 
359ab2
@@ -1881,10 +1842,10 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    public bool key_press_enter() {
359ab2
+    public bool key_press_enter(bool need_commit_signal) {
359ab2
         if (m_candidate_panel_is_visible) {
359ab2
             uint index = m_lookup_table.get_cursor_pos();
359ab2
-            return has_variants(index);
359ab2
+            return has_variants(index, need_commit_signal);
359ab2
         } else if (m_category_active_index >= 0) {
359ab2
             Gtk.ListBoxRow gtkrow = m_list_box.get_selected_row();
359ab2
             EBoxRow row = gtkrow as EBoxRow;
359ab2
@@ -2282,12 +2243,10 @@ public class IBusEmojier : Gtk.ApplicationWindow {
359ab2
             return true;
359ab2
         case Gdk.Key.Return:
359ab2
         case Gdk.Key.KP_Enter:
359ab2
-            if (key_press_enter()) {
359ab2
+            if (key_press_enter(true))
359ab2
                 show_all();
359ab2
-            } else {
359ab2
-                m_result = get_current_candidate();
359ab2
+            else
359ab2
                 hide();
359ab2
-            }
359ab2
             return true;
359ab2
         case Gdk.Key.space:
359ab2
         case Gdk.Key.KP_Space:
359ab2
diff --git a/ui/gtk3/emojierapp.vala b/ui/gtk3/emojierapp.vala
359ab2
index 787d448f..fab99d9e 100644
359ab2
--- a/ui/gtk3/emojierapp.vala
359ab2
+++ b/ui/gtk3/emojierapp.vala
359ab2
@@ -65,7 +65,7 @@ public class EmojiApplication : Gtk.Application {
359ab2
         uint ncandidates = m_emojier.get_number_of_candidates();
359ab2
         if (ncandidates > 0 && ncandidates >= index) {
359ab2
             m_emojier.set_cursor_pos(index);
359ab2
-            show_candidate = m_emojier.has_variants(index);
359ab2
+            show_candidate = m_emojier.has_variants(index, false);
359ab2
         } else {
359ab2
             return;
359ab2
         }
359ab2
diff --git a/ui/gtk3/panelbinding.vala b/ui/gtk3/panelbinding.vala
359ab2
index 4ebff8da..01c43b0d 100644
359ab2
--- a/ui/gtk3/panelbinding.vala
359ab2
+++ b/ui/gtk3/panelbinding.vala
359ab2
@@ -447,13 +447,19 @@ class PanelBinding : IBus.PanelService {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    private void commit_text_update_favorites(IBus.Text text) {
359ab2
+    private void commit_text_update_favorites(IBus.Text text,
359ab2
+                                              bool      disable_extension) {
359ab2
         commit_text(text);
359ab2
-        IBus.ExtensionEvent event = new IBus.ExtensionEvent(
359ab2
+
359ab2
+        // If disable_extension is false, the extension event is already
359ab2
+        // sent before the focus-in is received.
359ab2
+        if (disable_extension) {
359ab2
+            IBus.ExtensionEvent event = new IBus.ExtensionEvent(
359ab2
                     "name", m_extension_name,
359ab2
                     "is-enabled", false,
359ab2
                     "is-extension", true);
359ab2
-        panel_extension(event);
359ab2
+            panel_extension(event);
359ab2
+        }
359ab2
         string committed_string = text.text;
359ab2
         string preedit_string = m_preedit.get_text();
359ab2
         m_preedit.hide();
359ab2
@@ -482,7 +488,7 @@ class PanelBinding : IBus.PanelService {
359ab2
             prev_context_path != "" &&
359ab2
             prev_context_path == m_current_context_path) {
359ab2
             IBus.Text text = new IBus.Text.from_string(selected_string);
359ab2
-            commit_text_update_favorites(text);
359ab2
+            commit_text_update_favorites(text, false);
359ab2
             m_emojier.reset();
359ab2
             return true;
359ab2
         }
359ab2
@@ -564,13 +570,13 @@ class PanelBinding : IBus.PanelService {
359ab2
     private bool key_press_enter() {
359ab2
         if (m_extension_name != "unicode" && is_emoji_lookup_table()) {
359ab2
             // Check if variats exist
359ab2
-            if (m_emojier.key_press_enter()) {
359ab2
+            if (m_emojier.key_press_enter(false)) {
359ab2
                 convert_preedit_text();
359ab2
                 return true;
359ab2
             }
359ab2
         }
359ab2
         IBus.Text text = m_preedit.get_commit_text();
359ab2
-        commit_text_update_favorites(text);
359ab2
+        commit_text_update_favorites(text, true);
359ab2
         return false;
359ab2
     }
359ab2
 
359ab2
@@ -712,15 +718,10 @@ class PanelBinding : IBus.PanelService {
359ab2
     }
359ab2
 
359ab2
 
359ab2
-    private bool is_visible_wayland_lookup_table() {
359ab2
-        return m_wayland_lookup_table_is_visible;
359ab2
-    }
359ab2
-
359ab2
-
359ab2
     private void hide_emoji_lookup_table() {
359ab2
         if (m_emojier == null)
359ab2
             return;
359ab2
-        if (m_is_wayland)
359ab2
+        if (m_wayland_lookup_table_is_visible)
359ab2
             hide_wayland_lookup_table();
359ab2
         else
359ab2
             m_emojier.hide();
359ab2
@@ -747,7 +748,7 @@ class PanelBinding : IBus.PanelService {
359ab2
 
359ab2
     private bool is_emoji_lookup_table() {
359ab2
         if (m_is_wayland)
359ab2
-            return is_visible_wayland_lookup_table();
359ab2
+            return m_wayland_lookup_table_is_visible;
359ab2
         else
359ab2
             return m_emojier.get_visible();
359ab2
     }
359ab2
@@ -788,7 +789,8 @@ class PanelBinding : IBus.PanelService {
359ab2
          */
359ab2
         if (!input_context_path.has_suffix("InputContext_1")) {
359ab2
             m_real_current_context_path = m_current_context_path;
359ab2
-            this.emojier_focus_commit();
359ab2
+            if (m_is_wayland)
359ab2
+                this.emojier_focus_commit();
359ab2
         }
359ab2
     }
359ab2
 
359ab2
@@ -822,8 +824,18 @@ class PanelBinding : IBus.PanelService {
359ab2
             // For title handling in gnome-shell
359ab2
             m_application.add_window(m_emojier);
359ab2
             m_emojier.candidate_clicked.connect((i, b, s) => {
359ab2
+                candidate_clicked_lookup_table_real(i, b, s, true);
359ab2
+            });
359ab2
+            m_emojier.commit_text.connect((s) => {
359ab2
                 if (!m_is_wayland)
359ab2
-                    candidate_clicked_lookup_table(i, b, s);
359ab2
+                    return;
359ab2
+                // Currently emojier has a focus but the text input focus
359ab2
+                // does not and commit the text later.
359ab2
+                IBus.ExtensionEvent close_event = new IBus.ExtensionEvent(
359ab2
+                        "name", m_extension_name,
359ab2
+                        "is-enabled", false,
359ab2
+                        "is-extension", true);
359ab2
+                panel_extension(close_event);
359ab2
             });
359ab2
         }
359ab2
         m_emojier.reset();
359ab2
@@ -1041,9 +1053,10 @@ class PanelBinding : IBus.PanelService {
359ab2
         show_preedit_and_candidate(show_candidate);
359ab2
     }
359ab2
 
359ab2
-    public override void candidate_clicked_lookup_table(uint index,
359ab2
-                                                        uint button,
359ab2
-                                                        uint state) {
359ab2
+    private void candidate_clicked_lookup_table_real(uint index,
359ab2
+                                                     uint button,
359ab2
+                                                     uint state,
359ab2
+                                                     bool is_emojier) {
359ab2
         if (button == IBusEmojier.BUTTON_CLOSE_BUTTON) {
359ab2
             m_enable_extension = false;
359ab2
             hide_emoji_lookup_table();
359ab2
@@ -1061,17 +1074,26 @@ class PanelBinding : IBus.PanelService {
359ab2
         uint ncandidates = m_emojier.get_number_of_candidates();
359ab2
         if (ncandidates > 0 && ncandidates >= index) {
359ab2
             m_emojier.set_cursor_pos(index);
359ab2
-            show_candidate = m_emojier.has_variants(index);
359ab2
-            m_preedit.set_emoji(m_emojier.get_current_candidate());
359ab2
+            bool need_commit_signal = m_is_wayland && is_emojier;
359ab2
+            show_candidate = m_emojier.has_variants(index, need_commit_signal);
359ab2
+            if (!m_is_wayland)
359ab2
+                m_preedit.set_emoji(m_emojier.get_current_candidate());
359ab2
         } else {
359ab2
             return;
359ab2
         }
359ab2
         if (!show_candidate) {
359ab2
             IBus.Text text = m_preedit.get_commit_text();
359ab2
-            commit_text_update_favorites(text);
359ab2
             hide_emoji_lookup_table();
359ab2
+            if (!is_emojier || !m_is_wayland)
359ab2
+                commit_text_update_favorites(text, true);
359ab2
             return;
359ab2
         }
359ab2
         show_preedit_and_candidate(show_candidate);
359ab2
     }
359ab2
+
359ab2
+    public override void candidate_clicked_lookup_table(uint index,
359ab2
+                                                        uint button,
359ab2
+                                                        uint state) {
359ab2
+        candidate_clicked_lookup_table_real(index, button, state, false);
359ab2
+    }
359ab2
 }
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From c1b55431c076dfa3fc26a3a998bfcf729e9ba602 Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Fri, 26 Oct 2018 18:44:35 +0900
359ab2
Subject: [PATCH] src/tests: Fix make check in Fedora 29
359ab2
359ab2
ibus-bus and ibus-compose failed in Fedora 29.
359ab2
359ab2
1. In ibus-bus with runtest, ibus-daemon failed to restart in
359ab2
start_exit_async() because it seems to have conflicting IO with runtest
359ab2
and ibus-daemon failed to close a file descriptor in _restart_server().
359ab2
The solution is to add a sleep in start_exit_async().
359ab2
Also added ibus_get_address() in test_async_apis_finish() to check
359ab2
if ibus-daemon finished to restart.
359ab2
359ab2
2. In ibus-compose, the GTK application could not get the ibus module.
359ab2
The solution is to export GTK_IM_MODULE=ibus.
359ab2
359ab2
3. Added DISABLE_DAEMONIZE_IN_TESTS to get error messages in ibus-daemon.
359ab2
% make DISABLE_DAEMONIZE_IN_TESTS=1 check
359ab2
---
359ab2
 bus/Makefile.am       |  1 +
359ab2
 src/tests/Makefile.am |  1 +
359ab2
 src/tests/ibus-bus.c  | 15 ++++++++++++++-
359ab2
 src/tests/runtest     | 24 +++++++++++++++++-------
359ab2
 4 files changed, 33 insertions(+), 8 deletions(-)
359ab2
359ab2
diff --git a/bus/Makefile.am b/bus/Makefile.am
359ab2
index bdae5c92..4383a874 100644
359ab2
--- a/bus/Makefile.am
359ab2
+++ b/bus/Makefile.am
359ab2
@@ -124,6 +124,7 @@ TESTS_ENVIRONMENT = \
359ab2
     srcdir=$(srcdir) \
359ab2
     LD_LIBRARY_PATH="$(top_builddir)/src/.libs:$(top_builddir)/src" \
359ab2
     DISABLE_GUI_TESTS="$(DISABLE_GUI_TESTS)" \
359ab2
+    DISABLE_DAEMONIZE_IN_TESTS="$(DISABLE_DAEMONIZE_IN_TESTS)" \
359ab2
     $(NULL)
359ab2
 
359ab2
 LOG_COMPILER = $(top_srcdir)/src/tests/runtest
359ab2
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
359ab2
index c5fef3c8..e337a59b 100644
359ab2
--- a/src/tests/Makefile.am
359ab2
+++ b/src/tests/Makefile.am
359ab2
@@ -73,6 +73,7 @@ TESTS_ENVIRONMENT = \
359ab2
     srcdir=$(srcdir) \
359ab2
     LD_LIBRARY_PATH="$(top_builddir)/src/.libs:$(top_builddir)/src" \
359ab2
     DISABLE_GUI_TESTS="$(DISABLE_GUI_TESTS)" \
359ab2
+    DISABLE_DAEMONIZE_IN_TESTS="$(DISABLE_DAEMONIZE_IN_TESTS)" \
359ab2
     $(NULL)
359ab2
 
359ab2
 LOG_COMPILER = $(srcdir)/runtest
359ab2
diff --git a/src/tests/ibus-bus.c b/src/tests/ibus-bus.c
359ab2
index 7fa1bc4a..0bf9e612 100644
359ab2
--- a/src/tests/ibus-bus.c
359ab2
+++ b/src/tests/ibus-bus.c
359ab2
@@ -820,6 +820,14 @@ finish_exit_async (GObject *source_object,
359ab2
 static void
359ab2
 start_exit_async (void)
359ab2
 {
359ab2
+    /* When `./runtest ibus-bus` runs, ibus-daemon sometimes failed to
359ab2
+     * restart because closing a file descriptor was failed in
359ab2
+     * bus/server.c:_restart_server() with a following error:
359ab2
+     *     "inotify read(): Bad file descriptor"
359ab2
+     * Now g_usleep() is added here to write down the buffer and not to
359ab2
+     * fail to restart ibus-daemon.
359ab2
+     */
359ab2
+    g_usleep (G_USEC_PER_SEC);
359ab2
     ibus_bus_exit_async (bus,
359ab2
                          TRUE, /* restart */
359ab2
                          -1, /* timeout */
359ab2
@@ -831,6 +839,9 @@ start_exit_async (void)
359ab2
 static gboolean
359ab2
 test_async_apis_finish (gpointer user_data)
359ab2
 {
359ab2
+    /* INFO: g_warning() causes SEGV with runtest script */
359ab2
+    if (ibus_get_address () == NULL)
359ab2
+        g_warning ("ibus-daemon does not restart yet from start_exit_async().");
359ab2
     ibus_quit ();
359ab2
     return FALSE;
359ab2
 }
359ab2
@@ -906,7 +917,9 @@ call_next_async_function (void)
359ab2
     };
359ab2
     static guint index = 0;
359ab2
 
359ab2
-    // Use g_timeout_add to make sure test_async_apis finishes even if async_functions is empty.
359ab2
+    /* Use g_timeout_add to make sure test_async_apis finishes even if
359ab2
+     * async_functions is empty.
359ab2
+     */
359ab2
     if (index >= G_N_ELEMENTS (async_functions))
359ab2
         g_timeout_add (1, test_async_apis_finish, NULL);
359ab2
     else
359ab2
diff --git a/src/tests/runtest b/src/tests/runtest
359ab2
index d7f96ea3..ab39e9f2 100755
359ab2
--- a/src/tests/runtest
359ab2
+++ b/src/tests/runtest
359ab2
@@ -22,6 +22,7 @@
359ab2
 : ${builddir:=.}
359ab2
 : ${srcdir:=.}
359ab2
 : ${DISABLE_GUI_TESTS:=''}
359ab2
+: ${DISABLE_DAEMONIZE_IN_TESTS:=''}
359ab2
 
359ab2
 BUS_REQUIRED_TESTS="
359ab2
 ibus-bus
359ab2
@@ -162,16 +163,25 @@ run_test_case()
359ab2
         export GSETTINGS_SCHEMA_DIR=$PWD
359ab2
 
359ab2
         # Start ibus-daemon.
359ab2
-        ../$top_builddir/bus/ibus-daemon \
359ab2
-        --daemonize \
359ab2
-        --cache=none \
359ab2
-        --panel=disable \
359ab2
-        --emoji-extension=disable \
359ab2
-        --config=default \
359ab2
-        --verbose;
359ab2
+        DAEMON_ARGS='
359ab2
+            --cache=none
359ab2
+            --panel=disable
359ab2
+            --emoji-extension=disable
359ab2
+            --config=default
359ab2
+            --verbose
359ab2
+        '
359ab2
+        if test x"$DISABLE_DAEMONIZE_IN_TESTS" = x ; then
359ab2
+            ../$top_builddir/bus/ibus-daemon \
359ab2
+                $DAEMON_ARGS --daemonize;
359ab2
+        else
359ab2
+            ../$top_builddir/bus/ibus-daemon \
359ab2
+                $DAEMON_ARGS &
359ab2
+        fi
359ab2
 
359ab2
         # Wait until all necessary components are up.
359ab2
         sleep 1
359ab2
+
359ab2
+        export GTK_IM_MODULE=ibus
359ab2
     fi
359ab2
 
359ab2
     "../$tst" ${1+"$@"}
359ab2
-- 
359ab2
2.17.1
359ab2
359ab2
From 3172c3b23faefe76b3b7adfc75f9be34a0fb2e02 Mon Sep 17 00:00:00 2001
359ab2
From: fujiwarat <takao.fujiwara1@gmail.com>
359ab2
Date: Wed, 31 Oct 2018 17:42:38 +0900
359ab2
Subject: [PATCH] RHEL code reviews
359ab2
359ab2
---
359ab2
 src/ibuskeymap.c          | 2 +-
359ab2
 src/ibuspanelservice.c    | 6 +++++-
359ab2
 src/tests/ibus-keypress.c | 2 +-
359ab2
 util/IMdkit/FrameMgr.c    | 1 +
359ab2
 4 files changed, 8 insertions(+), 3 deletions(-)
359ab2
359ab2
diff --git a/src/ibuskeymap.c b/src/ibuskeymap.c
359ab2
index 27a56754..5abfb99a 100644
359ab2
--- a/src/ibuskeymap.c
359ab2
+++ b/src/ibuskeymap.c
359ab2
@@ -143,7 +143,7 @@ ibus_keymap_parse_line (gchar  *str,
359ab2
     /* Do not assign *p1 to g_ascii_isalpha() directly for the syntax check */
359ab2
     if (i == 0 &&
359ab2
         strncmp (p2, "addupper", sizeof ("addupper") - 1) == 0 &&
359ab2
-        (ch = *p1) && g_ascii_isalpha (ch)) {
359ab2
+        (ch = *p1) && (ch >= 0) && g_ascii_isalpha (ch)) {
359ab2
         gchar buf[] = "a";
359ab2
         buf[0] = g_ascii_toupper(ch);
359ab2
         keymap[keycode][0] = keymap[keycode][3] = keysym;
359ab2
diff --git a/src/ibuspanelservice.c b/src/ibuspanelservice.c
359ab2
index 9d87e19b..984cc890 100644
359ab2
--- a/src/ibuspanelservice.c
359ab2
+++ b/src/ibuspanelservice.c
359ab2
@@ -1615,7 +1615,11 @@ ibus_panel_service_panel_extension_register_keys (IBusPanelService   *panel,
359ab2
     va_start (var_args, first_property_name);
359ab2
     do {
359ab2
         keys = va_arg (var_args, IBusProcessKeyEventData *);
359ab2
-        g_return_if_fail (keys != NULL);
359ab2
+        if (keys == NULL) {
359ab2
+            va_end (var_args);
359ab2
+            g_warning ("Failed to va_arg for IBusProcessKeyEventData");
359ab2
+            return;
359ab2
+        }
359ab2
         g_variant_builder_init (&child, G_VARIANT_TYPE ("av"));
359ab2
         for (; keys; keys++) {
359ab2
             if (keys->keyval == 0 && keys->keycode == 0 && keys->state == 0)
359ab2
diff --git a/src/tests/ibus-keypress.c b/src/tests/ibus-keypress.c
359ab2
index 3486523b..17920226 100644
359ab2
--- a/src/tests/ibus-keypress.c
359ab2
+++ b/src/tests/ibus-keypress.c
359ab2
@@ -173,7 +173,7 @@ set_engine_cb (GObject      *object,
359ab2
     IBusBus *bus = IBUS_BUS (object);
359ab2
     GtkWidget *entry = GTK_WIDGET (data);
359ab2
     GdkDisplay *display;
359ab2
-    Display *xdisplay;
359ab2
+    Display *xdisplay = NULL;
359ab2
     GError *error = NULL;
359ab2
     int i, j;
359ab2
 
359ab2
diff --git a/util/IMdkit/FrameMgr.c b/util/IMdkit/FrameMgr.c
359ab2
index 084b8810..0e91b78e 100644
359ab2
--- a/util/IMdkit/FrameMgr.c
359ab2
+++ b/util/IMdkit/FrameMgr.c
359ab2
@@ -1414,6 +1414,7 @@ static int FrameInstGetSize (FrameInst fi)
359ab2
 	    break;
359ab2
         }
359ab2
         /*endswitch*/
359ab2
+        assert (i >= 0);
359ab2
         i = _FrameInstIncrement (fi->template, i);
359ab2
     }
359ab2
     /*endwhile*/
359ab2
-- 
359ab2
2.17.1
359ab2