From 997e5cb1b100c6af267b8121445db1db7e580d5f Mon Sep 17 00:00:00 2001 From: "Eric R. Schulz" Date: Thu, 18 Aug 2016 11:17:11 +0900 Subject: [PATCH 1/3] Fix GVariant leaks The expectation is that g_dbus_message_set_body() takes ownership of the GVariant, but this does not happen if the BusInputContext connection is NULL. Call g_variant_unref() in that case to free the memory. Alternatively, a GVariantBuilder could be used. BUG=https://github.com/ibus/ibus/pull/1872 R=Shawn.P.Huang@gmail.com Review URL: https://codereview.appspot.com/307050043 Patch from Eric R. Schulz . --- bus/inputcontext.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bus/inputcontext.c b/bus/inputcontext.c index 6c82e20..0612fac 100644 --- a/bus/inputcontext.c +++ b/bus/inputcontext.c @@ -673,8 +673,10 @@ bus_input_context_send_signal (BusInputContext *context, GVariant *parameters, GError **error) { - if (context->connection == NULL) + if (context->connection == NULL) { + g_variant_unref (parameters); return TRUE; + } GDBusMessage *message = g_dbus_message_new_signal (ibus_service_get_object_path ((IBusService *)context), interface_name, @@ -704,8 +706,10 @@ bus_input_context_emit_signal (BusInputContext *context, GVariant *parameters, GError **error) { - if (context->connection == NULL) + if (context->connection == NULL) { + g_variant_unref (parameters); return TRUE; + } return bus_input_context_send_signal (context, "org.freedesktop.IBus.InputContext", -- 2.7.4 From ceb6a9b47deaa898d8151606831669a7446ad382 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Tue, 6 Sep 2016 13:05:35 +0900 Subject: [PATCH 2/3] ui/gtk3: Fix radio buttons on Property Panel Use gtk_container_remove() instead g_object_unref() because if an widget has a parent, it's not destroyed and the signal is not sent to the parent since the parent was destroyed. R=shawn.p.huang@gmail.com Review URL: https://codereview.appspot.com/302650043 --- ui/gtk3/propertypanel.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/gtk3/propertypanel.vala b/ui/gtk3/propertypanel.vala index 6d5fd81..ea960b8 100644 --- a/ui/gtk3/propertypanel.vala +++ b/ui/gtk3/propertypanel.vala @@ -2,9 +2,9 @@ * * ibus - The Input Bus * - * Copyright(c) 2013-2015 Red Hat, Inc. + * Copyright(c) 2013-2016 Red Hat, Inc. * Copyright(c) 2013-2015 Peng Huang - * Copyright(c) 2013-2015 Takao Fujiwara + * Copyright(c) 2013-2016 Takao Fujiwara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -85,7 +85,7 @@ public class PropertyPanel : Gtk.Box { debug("set_properties()\n"); foreach (var item in m_items) - (item as Gtk.Widget).destroy(); + remove((item as Gtk.Widget)); m_items = {}; m_props = props; @@ -481,6 +481,8 @@ public class PropMenu : Gtk.Menu, IPropToolItem { public override void destroy() { m_parent_button = null; + foreach (var item in m_items) + remove((item as Gtk.Widget)); m_items = {}; base.destroy(); } @@ -739,7 +741,7 @@ public class PropMenuToolButton : PropToggleToolButton, IPropToolItem { m_menu = new PropMenu(prop); m_menu.deactivate.connect((m) => set_active(false)); - m_menu.property_activate.connect((w, k, s) => + m_menu.property_activate.connect((k, s) => property_activate(k, s)); base.set_property(prop); -- 2.7.4 From e795eda1a3b054e6fdc921bfe04c83733761905f Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 6 Oct 2016 15:28:24 +0900 Subject: [PATCH 1/3] src: Hide lookup table if emoji annotation does not hit If emoji annotation hits "aaa" but not "aaab", hide the lookup window with "aaab". Also hide the lookup window with Escape key. BUG=rhbz#1380675 Review URL: https://codereview.appspot.com/307400043 --- src/ibusenginesimple.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c index 8efe5a9..b22b06f 100644 --- a/src/ibusenginesimple.c +++ b/src/ibusenginesimple.c @@ -1018,6 +1018,10 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, } else if (is_escape) { ibus_engine_simple_reset (engine); + if (priv->lookup_table != NULL && priv->lookup_table_visible) { + priv->lookup_table_visible = FALSE; + ibus_engine_simple_update_lookup_and_aux_table (simple); + } return TRUE; } @@ -1165,6 +1169,10 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, } else if (is_escape) { ibus_engine_simple_reset (engine); + if (priv->lookup_table != NULL && priv->lookup_table_visible) { + priv->lookup_table_visible = FALSE; + ibus_engine_simple_update_lookup_and_aux_table (simple); + } return TRUE; } } else { @@ -1243,8 +1251,10 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, priv->lookup_table_visible = FALSE; update_lookup_table = TRUE; } - } - else if (check_emoji_table (simple, n_compose, -1)) { + } else if (check_emoji_table (simple, n_compose, -1)) { + update_lookup_table = TRUE; + } else { + priv->lookup_table_visible = FALSE; update_lookup_table = TRUE; } } -- 2.7.4 From 4d86e59d0245df6d3a6aa1a32cdf7702b6dc7f0d Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 6 Oct 2016 15:35:03 +0900 Subject: [PATCH 2/3] src: Enable to type digit to commit emoji on lookup window Enables to commit an emoji on the lookup window by a digit key. Before this patch, Ctrl-Shift-U, "11" shows emojis of 11 clock. After this patch, Ctrl-Shift-U, "11" commits an emoji of 1 clock. Probably Ctrl-Shift-U, "clock" can be a workaround. BUG=rhbz#1380690 R=Shawn.P.Huang@gmail.com Review URL: https://codereview.appspot.com/309640043 --- src/ibusenginesimple.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c index b22b06f..23e1c9d 100644 --- a/src/ibusenginesimple.c +++ b/src/ibusenginesimple.c @@ -901,6 +901,66 @@ ibus_engine_simple_update_lookup_and_aux_table (IBusEngineSimple *simple) } static gboolean +ibus_engine_simple_if_in_range_of_lookup_table (IBusEngineSimple *simple, + guint keyval) +{ + IBusEngineSimplePrivate *priv; + int index, candidates, cursor_pos, cursor_in_page, page_size; + + priv = simple->priv; + + if (priv->lookup_table == NULL || !priv->lookup_table_visible) + return FALSE; + if (keyval < IBUS_KEY_0 || keyval > IBUS_KEY_9) + return FALSE; + if (keyval == IBUS_KEY_0) + keyval = IBUS_KEY_9 + 1; + index = keyval - IBUS_KEY_1; + candidates = + ibus_lookup_table_get_number_of_candidates (priv->lookup_table); + cursor_pos = ibus_lookup_table_get_cursor_pos (priv->lookup_table); + cursor_in_page = ibus_lookup_table_get_cursor_in_page (priv->lookup_table); + page_size = ibus_lookup_table_get_page_size (priv->lookup_table); + if (index > ((candidates - (cursor_pos - cursor_in_page)) % page_size)) + return FALSE; + return TRUE; +} + +static void +ibus_engine_simple_set_number_on_lookup_table (IBusEngineSimple *simple, + guint keyval, + int n_compose) +{ + IBusEngineSimplePrivate *priv; + int index, cursor_pos, cursor_in_page, real_index; + + priv = simple->priv; + + if (keyval == IBUS_KEY_0) + keyval = IBUS_KEY_9 + 1; + index = keyval - IBUS_KEY_1; + cursor_pos = ibus_lookup_table_get_cursor_pos (priv->lookup_table); + cursor_in_page = ibus_lookup_table_get_cursor_in_page (priv->lookup_table); + real_index = cursor_pos - cursor_in_page + index; + + ibus_lookup_table_set_cursor_pos (priv->lookup_table, real_index); + check_emoji_table (simple, n_compose, real_index); + priv->lookup_table_visible = FALSE; + ibus_engine_simple_update_lookup_and_aux_table (simple); + + if (priv->tentative_emoji && *priv->tentative_emoji) { + ibus_engine_simple_commit_str (simple, priv->tentative_emoji); + priv->compose_buffer[0] = 0; + } else { + g_clear_pointer (&priv->tentative_emoji, g_free); + priv->in_emoji_sequence = FALSE; + priv->compose_buffer[0] = 0; + } + + ibus_engine_simple_update_preedit_text (simple); +} + +static gboolean ibus_engine_simple_process_key_event (IBusEngine *engine, guint keyval, guint keycode, @@ -1162,7 +1222,15 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, } } else if (priv->in_emoji_sequence) { if (printable_keyval) { - priv->compose_buffer[n_compose++] = printable_keyval; + if (!ibus_engine_simple_if_in_range_of_lookup_table (simple, + printable_keyval)) { + /* digit keyval can be an index on the current lookup table + * but it also can be a part of an emoji annotation. + * E.g. "1" and "2" are indexes of emoji "1". + * "100" is an annotation of the emoji "100". + */ + priv->compose_buffer[n_compose++] = printable_keyval; + } } else if (is_space && (modifiers & IBUS_SHIFT_MASK)) { priv->compose_buffer[n_compose++] = IBUS_KEY_space; @@ -1243,7 +1311,15 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, } if (!update_lookup_table) { - if (is_hex_end && !is_space) { + if (ibus_engine_simple_if_in_range_of_lookup_table (simple, + keyval)) { + ibus_engine_simple_set_number_on_lookup_table ( + simple, + keyval, + n_compose); + return TRUE; + } + else if (is_hex_end && !is_space) { if (priv->lookup_table) { int index = (int) ibus_lookup_table_get_cursor_pos ( priv->lookup_table); -- 2.7.4 From faf5e3c56d746d2f171618d552cff9149bb1d952 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 6 Oct 2016 15:37:25 +0900 Subject: [PATCH 3/3] src: Enable PageUp, PageDown, CandidateClick buttons with emoji lookup BUG=rhbz#1380691 Review URL: https://codereview.appspot.com/312760043 --- src/ibusenginesimple.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c index 23e1c9d..65c33a0 100644 --- a/src/ibusenginesimple.c +++ b/src/ibusenginesimple.c @@ -107,6 +107,13 @@ static gboolean ibus_engine_simple_process_key_event guint keyval, guint keycode, guint modifiers); +static void ibus_engine_simple_page_down (IBusEngine *engine); +static void ibus_engine_simple_page_up (IBusEngine *engine); +static void ibus_engine_simple_candidate_clicked + (IBusEngine *engine, + guint index, + guint button, + guint state); static void ibus_engine_simple_commit_char (IBusEngineSimple *simple, gunichar ch); static void ibus_engine_simple_commit_str (IBusEngineSimple *simple, @@ -128,6 +135,10 @@ ibus_engine_simple_class_init (IBusEngineSimpleClass *class) engine_class->reset = ibus_engine_simple_reset; engine_class->process_key_event = ibus_engine_simple_process_key_event; + engine_class->page_down = ibus_engine_simple_page_down; + engine_class->page_up = ibus_engine_simple_page_up; + engine_class->candidate_clicked + = ibus_engine_simple_candidate_clicked; g_type_class_add_private (class, sizeof (IBusEngineSimplePrivate)); } @@ -1395,6 +1406,50 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, return no_sequence_matches (simple, n_compose, keyval, keycode, modifiers); } +static void +ibus_engine_simple_page_down (IBusEngine *engine) +{ + IBusEngineSimple *simple = (IBusEngineSimple *)engine; + IBusEngineSimplePrivate *priv = simple->priv; + if (priv->lookup_table == NULL) + return; + ibus_lookup_table_page_down (priv->lookup_table); + ibus_engine_simple_update_lookup_and_aux_table (simple); +} + +static void +ibus_engine_simple_page_up (IBusEngine *engine) +{ + IBusEngineSimple *simple = (IBusEngineSimple *)engine; + IBusEngineSimplePrivate *priv = simple->priv; + if (priv->lookup_table == NULL) + return; + ibus_lookup_table_page_up (priv->lookup_table); + ibus_engine_simple_update_lookup_and_aux_table (simple); +} + +static void +ibus_engine_simple_candidate_clicked (IBusEngine *engine, + guint index, + guint button, + guint state) +{ + IBusEngineSimple *simple = (IBusEngineSimple *)engine; + IBusEngineSimplePrivate *priv = simple->priv; + guint keyval; + gint n_compose = 0; + + if (priv->lookup_table == NULL || !priv->lookup_table_visible) + return; + if (index == 9) + keyval = IBUS_KEY_0; + else + keyval = IBUS_KEY_1 + index; + while (priv->compose_buffer[n_compose] != 0) + n_compose++; + ibus_engine_simple_set_number_on_lookup_table (simple, keyval, n_compose); +} + void ibus_engine_simple_add_table (IBusEngineSimple *simple, const guint16 *data, -- 2.7.4 From 52b7272d97a881a8a6c872e28c1970ec47cb4337 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 12 Oct 2016 15:17:24 +0900 Subject: [PATCH] ui/gtk3: support scroll event in candidates panel When press scroll button of mouse on candidates, automatically cursor up/cursor down. BUG= R=takao.fujiwara1@gmail.com Review URL: https://codereview.appspot.com/302700043 Patch from Peng Wu . --- ui/gtk3/candidatearea.vala | 33 +++++++++++++++++++++++++++++---- ui/gtk3/panel.vala | 2 ++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ui/gtk3/candidatearea.vala b/ui/gtk3/candidatearea.vala index 3848f0d..88db268 100644 --- a/ui/gtk3/candidatearea.vala +++ b/ui/gtk3/candidatearea.vala @@ -61,6 +61,18 @@ class CandidateArea : Gtk.Box { set_vertical(vertical, true); } + public bool candidate_scrolled(Gdk.EventScroll event) { + switch (event.direction) { + case Gdk.ScrollDirection.UP: + cursor_up(); + break; + case Gdk.ScrollDirection.DOWN: + cursor_down(); + break; + } + return true; + } + public bool get_vertical() { return m_vertical; } @@ -167,9 +179,17 @@ class CandidateArea : Gtk.Box { next_button.set_relief(Gtk.ReliefStyle.NONE); if (m_vertical) { + Gtk.EventBox container_ebox = new Gtk.EventBox(); + container_ebox.add_events(Gdk.EventMask.SCROLL_MASK); + container_ebox.scroll_event.connect(candidate_scrolled); + add(container_ebox); + + Gtk.Box vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); + container_ebox.add(vbox); + // Add Candidates Gtk.Box candidates_hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); - pack_start(candidates_hbox, false, false, 0); + vbox.pack_start(candidates_hbox, false, false, 0); Gtk.Box labels_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); labels_vbox.set_homogeneous(true); Gtk.Box candidates_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); @@ -179,7 +199,7 @@ class CandidateArea : Gtk.Box { candidates_hbox.pack_start(candidates_vbox, true, true, 4); // Add HSeparator - pack_start(new HSeparator(), false, false, 0); + vbox.pack_start(new HSeparator(), false, false, 0); // Add buttons Gtk.Box buttons_hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); @@ -188,7 +208,7 @@ class CandidateArea : Gtk.Box { buttons_hbox.pack_start(state_label, true, true, 0); buttons_hbox.pack_start(prev_button, false, false, 0); buttons_hbox.pack_start(next_button, false, false, 0); - pack_start(buttons_hbox, false, false, 0); + vbox.pack_start(buttons_hbox, false, false, 0); m_labels = {}; m_candidates = {}; @@ -234,8 +254,13 @@ class CandidateArea : Gtk.Box { m_widgets += candidate_ebox; } } else { + Gtk.EventBox container_ebox = new Gtk.EventBox(); + container_ebox.add_events(Gdk.EventMask.SCROLL_MASK); + container_ebox.scroll_event.connect(candidate_scrolled); + add(container_ebox); + Gtk.Box hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); - add(hbox); + container_ebox.add(hbox); m_labels = {}; m_candidates = {}; diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index cc19350..ee08c59 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -111,6 +111,8 @@ class Panel : IBus.PanelService { m_candidate_panel = new CandidatePanel(); m_candidate_panel.page_up.connect((w) => this.page_up()); m_candidate_panel.page_down.connect((w) => this.page_down()); + m_candidate_panel.cursor_up.connect((w) => this.cursor_up()); + m_candidate_panel.cursor_down.connect((w) => this.cursor_down()); m_candidate_panel.candidate_clicked.connect( (w, i, b, s) => this.candidate_clicked(i, b, s)); -- 2.7.4 From f80dcc978fdc9a3d7853434e86f4ee02c2a92b33 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Wed, 11 Jan 2017 12:11:22 +0900 Subject: [PATCH] src: Avoid emoji typing during Unicode typing If 'sk' layout is used, digit keys need Shift key and Unicode typing of U+1AE requires Shift key after Ctrl-Shift-u. This patch does not enable the emoji typing with Ctrl-Shift-e during Unicode typing. BUG=rhbz#1403985 Review URL: https://codereview.appspot.com/311510043 --- src/ibusenginesimple.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c index 65c33a0..2a98d58 100644 --- a/src/ibusenginesimple.c +++ b/src/ibusenginesimple.c @@ -2,8 +2,8 @@ /* vim:set et sts=4: */ /* ibus - The Input Bus * Copyright (C) 2014 Peng Huang - * Copyright (C) 2015-2016 Takao Fujiwara - * Copyright (C) 2014-2016 Red Hat, Inc. + * Copyright (C) 2015-2017 Takao Fujiwara + * Copyright (C) 2014-2017 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1187,7 +1187,8 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, } /* Check for hex sequence start */ - if (!priv->in_hex_sequence && have_hex_mods && is_hex_start) { + if (!priv->in_hex_sequence && !priv->in_emoji_sequence && + have_hex_mods && is_hex_start) { priv->compose_buffer[0] = 0; priv->in_hex_sequence = TRUE; priv->in_emoji_sequence = FALSE; @@ -1200,7 +1201,8 @@ ibus_engine_simple_process_key_event (IBusEngine *engine, ibus_engine_simple_update_preedit_text (simple); return TRUE; - } else if (!priv->in_emoji_sequence && have_hex_mods && is_emoji_start) { + } else if (!priv->in_hex_sequence && !priv->in_emoji_sequence && + have_hex_mods && is_emoji_start) { priv->compose_buffer[0] = 0; priv->in_hex_sequence = FALSE; priv->in_emoji_sequence = TRUE; -- 2.7.4 From aacf5adbba9b9b34a1ec07005e670d209513fb5b Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Wed, 11 Jan 2017 12:16:59 +0900 Subject: [PATCH] ui/gtk3: Fix panel CSS format for GTK 3.22 GtkCssProvider no longer works with the Pango format in GTK 3.22 and need to use the CSS format. BUG=https://github.com/ibus/ibus/issues/1879 Review URL: https://codereview.appspot.com/319960043 --- ui/gtk3/panel.vala | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index ee08c59..4fb7555 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -3,7 +3,7 @@ * ibus - The Input Bus * * Copyright(c) 2011-2014 Peng Huang - * Copyright(c) 2015-2016 Takao Fujwiara + * Copyright(c) 2015-2017 Takao Fujwiara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -538,26 +538,33 @@ class Panel : IBus.PanelService { return; } - string font_name = m_settings_panel.get_string("custom-font"); + string custom_font = m_settings_panel.get_string("custom-font"); - if (font_name == null) { + if (custom_font == null) { warning("No config panel:custom-font."); return; } - string data_format = "label { font: %s; }"; + Pango.FontDescription font_desc = + Pango.FontDescription.from_string(custom_font); + string font_family = font_desc.get_family(); + int font_size = font_desc.get_size() / Pango.SCALE; + string data; + if (Gtk.MAJOR_VERSION < 3 || (Gtk.MAJOR_VERSION == 3 && Gtk.MINOR_VERSION < 20)) { - data_format = "GtkLabel { font: %s; }"; + data = "GtkLabel { font: %s; }".printf(custom_font); + } else { + data = "label { font-family: %s; font-size: %dpt; }" + .printf(font_family, font_size); } - string data = data_format.printf(font_name); m_css_provider = new Gtk.CssProvider(); try { m_css_provider.load_from_data(data, -1); } catch (GLib.Error e) { - warning("Failed css_provider_from_data: %s: %s", font_name, + warning("Failed css_provider_from_data: %s: %s", custom_font, e.message); return; } -- 2.7.4 From 4134113a1ae30534367a9ca729c7f36a0a8e3662 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 27 Jul 2017 14:07:00 +0900 Subject: [PATCH] ui/gtk3: Fix SEGV of XKeysymToKeycode() on Wayland BUG=rhbz#1368593 --- ui/gtk3/application.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/gtk3/application.vala b/ui/gtk3/application.vala index 5ae6e83..fa80272 100644 --- a/ui/gtk3/application.vala +++ b/ui/gtk3/application.vala @@ -3,6 +3,7 @@ * ibus - The Input Bus * * Copyright(c) 2011 Peng Huang + * Copyright(c) 2017 Takao Fujiwara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -99,6 +100,9 @@ class Application { } public static void main(string[] argv) { + // for Gdk.X11.get_default_xdisplay() + Gdk.set_allowed_backends("x11"); + Application app = new Application(argv); app.run(); } -- 2.9.3