Fix Bug 1618682 - SEGV with ASCII on emojier in Wayland

- Support Shift-Space on emojier preedit
- Do not move Emojier popup with the active candidate in Xorg
This commit is contained in:
Takao Fujiwara 2018-08-30 13:44:22 +09:00
parent 7d5c2f40f5
commit 3a447b7916
2 changed files with 365 additions and 1 deletions

View File

@ -35,3 +35,360 @@ index 85dcdceb..637ae049 100644
--
2.17.1
From 28d22176aee6be97d88dd6c60fa5395c79563ec0 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 30 Aug 2018 12:57:33 +0900
Subject: [PATCH] ui/gtk3: Fix SEGV when type ASCII on emojier
Emojier still included Gtk.Entry, accepted key events in Wayland,
reset the lookup table and it caused SEGV because IBus.Text
is NULL in the lookup table in Emojier.get_current_candidate().
Now Gtk.Entry is deleted completely.
BUG=rhbz#1618682
---
ui/gtk3/emojier.vala | 139 +------------------------------------------
1 file changed, 1 insertion(+), 138 deletions(-)
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
index 637ae049..0f455800 100644
--- a/ui/gtk3/emojier.vala
+++ b/ui/gtk3/emojier.vala
@@ -283,7 +283,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
private ThemedRGBA m_rgba;
private Gtk.Box m_vbox;
- private EEntry m_entry;
/* If emojier is emoji category list or Unicode category list,
* m_annotation is "" and preedit is also "".
* If emojier is candidate mode, m_annotation is an annotation and
@@ -367,23 +366,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
m_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
add(m_vbox);
- m_entry = new EEntry();
- m_entry.set_placeholder_text(_("Type annotation or choose emoji"));
- //m_vbox.add(m_entry);
- m_entry.changed.connect(() => {
- update_candidate_window();
- });
- m_entry.icon_release.connect((icon_pos, event) => {
- hide_candidate_panel();
- });
-
- /* Set the accessible role of the label to a status bar so it
- * will emit name changed events that can be used by screen
- * readers.
- */
- Atk.Object obj = m_entry.get_accessible();
- obj.set_role (Atk.Role.STATUSBAR);
-
// The constructor of IBus.LookupTable does not support more than
// 16 pages.
m_lookup_table = new IBus.LookupTable(1, 0, true, true);
@@ -1806,18 +1788,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
m_lookup_table.cursor_up();
else if (keyval == Gdk.Key.Right)
m_lookup_table.cursor_down();
- } else if (m_entry.get_text().length > 0) {
- int step = 0;
- if (keyval == Gdk.Key.Left)
- step = -1;
- else if (keyval == Gdk.Key.Right)
- step = 1;
- GLib.Signal.emit_by_name(
- m_entry, "move-cursor",
- Gtk.MovementStep.VISUAL_POSITIONS,
- step,
- (modifiers & Gdk.ModifierType.SHIFT_MASK) != 0
- ? true : false);
} else {
// For Gdk.Key.f and Gdk.Key.b
if (keyval == Gdk.Key.Left)
@@ -1880,20 +1850,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
}
return true;
}
- if (m_entry.get_text().length > 0) {
- int step = 0;
- if (keyval == Gdk.Key.Home)
- step = -1;
- else if (keyval == Gdk.Key.End)
- step = 1;
- GLib.Signal.emit_by_name(
- m_entry, "move-cursor",
- Gtk.MovementStep.DISPLAY_LINE_ENDS,
- step,
- (modifiers & Gdk.ModifierType.SHIFT_MASK) != 0
- ? true : false);
- return true;
- }
return category_list_cursor_move(keyval);
}
@@ -1941,28 +1897,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
}
- private void entry_enter_keyval(uint keyval) {
- unichar ch = IBus.keyval_to_unicode(keyval);
- if (ch.iscntrl())
- return;
- string str = ch.to_string();
-
- // what gtk_entry_commit_cb() do
- if (m_entry.get_selection_bounds(null, null)) {
- m_entry.delete_selection();
- } else {
- if (m_entry.get_overwrite_mode()) {
- uint text_length = m_entry.get_buffer().get_length();
- if (m_entry.cursor_position < text_length)
- m_entry.delete_from_cursor(Gtk.DeleteType.CHARS, 1);
- }
- }
- int pos = m_entry.get_position();
- m_entry.insert_text(str, -1, ref pos);
- m_entry.set_position(pos);
- }
-
-
private Gdk.Rectangle get_monitor_geometry() {
Gdk.Rectangle monitor_area = { 0, };
@@ -2245,10 +2179,7 @@ public class IBusEmojier : Gtk.ApplicationWindow {
/* Let gtk recalculate the window size. */
resize(1, 1);
- m_entry.set_text("");
-
show_category_list();
- m_entry.set_activates_default(true);
show_all();
/* Some window managers, e.g. MATE, GNOME, Plasma desktops,
@@ -2289,13 +2220,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
m_loop.run();
m_loop = null;
- // Need focus-out on Gtk.Entry to send the emoji to applications.
- Gdk.Event fevent = new Gdk.Event(Gdk.EventType.FOCUS_CHANGE);
- fevent.focus_change.in = 0;
- fevent.focus_change.window = get_window();
- m_entry.send_focus_change(fevent);
- fevent.focus_change.window = null;
-
hide();
// Make sure the switcher is hidden before returning from this function.
while (Gtk.events_pending())
@@ -2357,36 +2281,9 @@ public class IBusEmojier : Gtk.ApplicationWindow {
hide();
}
return true;
- case Gdk.Key.BackSpace:
- if (m_entry.get_text().length > 0) {
- if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
- GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
- Gtk.DeleteType.WORD_ENDS, -1);
- } else {
- GLib.Signal.emit_by_name(m_entry, "backspace");
- }
- return true;
- }
- break;
- case Gdk.Key.Delete:
- case Gdk.Key.KP_Delete:
- if (m_entry.get_text().length > 0) {
- if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
- GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
- Gtk.DeleteType.WORD_ENDS, 1);
- } else {
- GLib.Signal.emit_by_name(m_entry, "delete-from-cursor",
- Gtk.DeleteType.CHARS, 1);
- }
- return true;
- }
- break;
case Gdk.Key.space:
case Gdk.Key.KP_Space:
- if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
- if (m_entry.get_text().length > 0)
- entry_enter_keyval(keyval);
- } else if (m_candidate_panel_is_visible) {
+ if (m_candidate_panel_is_visible) {
enter_notify_disable_with_timer();
m_lookup_table.cursor_down();
show_candidate_panel();
@@ -2436,10 +2333,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
key_press_cursor_home_end(Gdk.Key.End, modifiers);
show_all();
return true;
- case Gdk.Key.Insert:
- case Gdk.Key.KP_Insert:
- GLib.Signal.emit_by_name(m_entry, "toggle-overwrite");
- return true;
}
if ((modifiers & Gdk.ModifierType.CONTROL_MASK) != 0) {
@@ -2470,27 +2363,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
key_press_cursor_home_end(Gdk.Key.End, modifiers);
show_all();
return true;
- case Gdk.Key.u:
- if (m_entry.get_text().length > 0) {
- GLib.Signal.emit_by_name(m_entry,
- "delete-from-cursor",
- Gtk.DeleteType.PARAGRAPH_ENDS,
- -1);
- return true;
- }
- break;
- case Gdk.Key.a:
- if (m_entry.get_text().length > 0) {
- m_entry.select_region(0, -1);
- return true;
- }
- break;
- case Gdk.Key.x:
- if (m_entry.get_text().length > 0) {
- GLib.Signal.emit_by_name(m_entry, "cut-clipboard");
- return true;
- }
- break;
case Gdk.Key.C:
case Gdk.Key.c:
if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
@@ -2503,19 +2375,11 @@ public class IBusEmojier : Gtk.ApplicationWindow {
clipboard.store();
return true;
}
- } else if (m_entry.get_text().length > 0) {
- GLib.Signal.emit_by_name(m_entry, "copy-clipboard");
- return true;
}
break;
- case Gdk.Key.v:
- GLib.Signal.emit_by_name(m_entry, "paste-clipboard");
- return true;
}
return false;
}
-
- entry_enter_keyval(keyval);
return true;
}
@@ -2595,7 +2459,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
uint32 timestamp = event.get_time();
present_with_time(timestamp);
- m_entry.set_activates_default(true);
}
--
2.17.1
From e6badb494e0a31b7aca3a5078a5dc5b27b83390d Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 30 Aug 2018 12:57:46 +0900
Subject: [PATCH] ui/gtk3: Support Shift-Space to insert a Space on Emojier
preedit
Implemented Shift-Space on preedit since Shift-Space had worked on
Emojier's GtkEntry in the previous release.
---
ui/gtk3/panelbinding.vala | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/ui/gtk3/panelbinding.vala b/ui/gtk3/panelbinding.vala
index 981b5509..4ebff8da 100644
--- a/ui/gtk3/panelbinding.vala
+++ b/ui/gtk3/panelbinding.vala
@@ -548,6 +548,19 @@ class PanelBinding : IBus.PanelService {
}
+ private bool key_press_keyval(uint keyval) {
+ unichar ch = IBus.keyval_to_unicode(keyval);
+ if (ch.iscntrl())
+ return false;
+ string str = ch.to_string();
+ m_preedit.append_text(str);
+ string annotation = m_preedit.get_text();
+ m_emojier.set_annotation(annotation);
+ m_preedit.set_emoji("");
+ return true;
+ }
+
+
private bool key_press_enter() {
if (m_extension_name != "unicode" && is_emoji_lookup_table()) {
// Check if variats exist
@@ -899,6 +912,12 @@ class PanelBinding : IBus.PanelService {
break;
case Gdk.Key.space:
case Gdk.Key.KP_Space:
+ if ((modifiers & Gdk.ModifierType.SHIFT_MASK) != 0) {
+ if (!key_press_keyval(keyval))
+ return true;
+ show_candidate = is_emoji_lookup_table();
+ break;
+ }
show_candidate = key_press_space();
if (m_extension_name == "unicode") {
key_press_enter();
@@ -979,14 +998,8 @@ class PanelBinding : IBus.PanelService {
show_candidate = key_press_control_keyval(keyval, modifiers);
break;
}
- unichar ch = IBus.keyval_to_unicode(keyval);
- if (ch.iscntrl())
+ if (!key_press_keyval(keyval))
return true;
- string str = ch.to_string();
- m_preedit.append_text(str);
- string annotation = m_preedit.get_text();
- m_emojier.set_annotation(annotation);
- m_preedit.set_emoji("");
show_candidate = is_emoji_lookup_table();
break;
}
--
2.17.1
From 809d880337e75b7cee429292a238bf53899bef6a Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 30 Aug 2018 12:58:57 +0900
Subject: [PATCH] ui/gtk3: Do not move Emojier popup with the active
candidate in Xorg
Probably I think it's not useful to change the popup position frequently.
The popup size is always slightly changed with the emoji annotation length.
---
ui/gtk3/emojier.vala | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
index 0f455800..9811fde5 100644
--- a/ui/gtk3/emojier.vala
+++ b/ui/gtk3/emojier.vala
@@ -1944,7 +1944,15 @@ public class IBusEmojier : Gtk.ApplicationWindow {
x = 0;
bool changed = false;
- if (window_right_bottom.y > monitor_bottom) {
+ // Do not up side down frequently.
+ // The first pos does not show the lookup table yet but the
+ // preedit only and the second pos shows the lookup table.
+ if (m_lookup_table.get_cursor_pos() != 1) {
+ if (m_is_up_side_down)
+ y = m_cursor_location.y - allocation.height;
+ else
+ y = cursor_right_bottom.y;
+ } else if (window_right_bottom.y > monitor_bottom) {
y = m_cursor_location.y - allocation.height;
// Do not up side down in Wayland
if (m_input_context_path == "") {
--
2.17.1

View File

@ -31,7 +31,7 @@
Name: ibus
Version: 1.5.19
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+
Group: System Environment/Libraries
@ -78,6 +78,8 @@ BuildRequires: qt5-qtbase-devel
BuildRequires: cldr-emoji-annotation
BuildRequires: unicode-emoji
BuildRequires: unicode-ucd
# for ibus-keypress
BuildRequires: libXtst-devel
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Requires: %{name}-gtk2%{?_isa} = %{version}-%{release}
@ -426,6 +428,11 @@ dconf update || :
%{_datadir}/gtk-doc/html/*
%changelog
* Thu Aug 30 2018 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.19-3
- Fix Bug 1618682 - SEGV with ASCII on emojier in Wayland
- Support Shift-Space on emojier preedit
- Do not move Emojier popup with the active candidate in Xorg
* Wed Aug 22 2018 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.19-2
- Do not clear Unicode data when emoji annotation lang is changed