From 17648f0522910480b6c5dd4f5356ca1f6c160bf5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 29 Mar 2022 22:48:19 +0200 Subject: [PATCH] src: Fix refcounting issues Commit 5a455b1ead attempted to fix both GLib warnings around floating references and other presumed refcounting issues. However it missed 2 kinds of bugs: - The places that take an IBusText created from a static string were made to avoid freeing it afterwards, but the staticness refers to the string content, not the object itself. - The places that are documented to emit signals on floating object references used to do the following after signal emission: if (g_object_is_floating (object)) g_object_unref (object) And did possibly trigger GLib warnings were changed to: if (g_object_is_floating (object)) g_object_sink_ref (object); g_object_unref (object); Which fixes the GLib warning for floating references, but do unintendedly steal one reference away for non floating references. This commit is essentially a revert of commit 5a455b1ead, but addressing both things differently: - All label/tooltip/symbol IBusText properties in IBusProperty do now always sink the reference of the stored object. - All places documented as maybe using objects with a floating reference on signals changed to doing: if (g_object_is_floating (object)) { g_object_ref_sink (object); g_object_unref (object); } So the floating reference is owned and unreferenced without warnings, but already owned references are left unchanged. This addresses the possible GLib warnings, fixes the possible double unrefs happening on IBusText used in signals, and fixes the missing unrefs on IBusText objects created from static strings. BUG=https://github.com/ibus/ibus/issues/2393 BUG=https://github.com/ibus/ibus/issues/2387 --- src/ibusinputcontext.c | 35 +++++++++++++++++++++-------------- src/ibusproperty.c | 32 +++++++++++++++++--------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c index 4b27551b..7981de38 100644 --- a/src/ibusinputcontext.c +++ b/src/ibusinputcontext.c @@ -549,9 +549,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, g_variant_unref (variant); g_signal_emit (context, context_signals[COMMIT_TEXT], 0, text); - if (g_object_is_floating (text)) + if (g_object_is_floating (text)) { g_object_ref_sink (text); - g_object_unref (text); + g_object_unref (text); + } return; } if (g_strcmp0 (signal_name, "UpdatePreeditText") == 0) { @@ -569,9 +570,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, cursor_pos, visible); - if (g_object_is_floating (text)) + if (g_object_is_floating (text)) { g_object_ref_sink (text); - g_object_unref (text); + g_object_unref (text); + } return; } if (g_strcmp0 (signal_name, "UpdatePreeditTextWithMode") == 0) { @@ -592,9 +594,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, visible, mode); - if (g_object_is_floating (text)) + if (g_object_is_floating (text)) { g_object_ref_sink (text); - g_object_unref (text); + g_object_unref (text); + } return; } @@ -621,9 +624,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, 0, text, visible); - if (g_object_is_floating (text)) + if (g_object_is_floating (text)) { g_object_ref_sink (text); - g_object_unref (text); + g_object_unref (text); + } return; } @@ -640,9 +644,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, 0, table, visible); - if (g_object_is_floating (table)) + if (g_object_is_floating (table)) { g_object_ref_sink (table); - g_object_unref (table); + g_object_unref (table); + } return; } @@ -659,9 +664,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, 0, prop_list); - if (g_object_is_floating (prop_list)) + if (g_object_is_floating (prop_list)) { g_object_ref_sink (prop_list); - g_object_unref (prop_list); + g_object_unref (prop_list); + } return; } @@ -673,9 +679,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, g_signal_emit (context, context_signals[UPDATE_PROPERTY], 0, prop); - if (g_object_is_floating (prop)) + if (g_object_is_floating (prop)) { g_object_ref_sink (prop); - g_object_unref (prop); + g_object_unref (prop); + } return; } diff --git a/src/ibusproperty.c b/src/ibusproperty.c index 6d4ed088..cd8a0e2a 100644 --- a/src/ibusproperty.c +++ b/src/ibusproperty.c @@ -336,20 +336,17 @@ ibus_property_destroy (IBusProperty *prop) prop->priv->icon = NULL; if (prop->priv->label) { - if (!ibus_text_get_is_static (prop->priv->label)) - g_object_unref (prop->priv->label); + g_object_unref (prop->priv->label); prop->priv->label = NULL; } if (prop->priv->symbol) { - if (!ibus_text_get_is_static (prop->priv->symbol)) - g_object_unref (prop->priv->symbol); + g_object_unref (prop->priv->symbol); prop->priv->symbol = NULL; } if (prop->priv->tooltip) { - if (!ibus_text_get_is_static (prop->priv->tooltip)) - g_object_unref (prop->priv->tooltip); + g_object_unref (prop->priv->tooltip); prop->priv->tooltip = NULL; } @@ -404,7 +401,7 @@ ibus_property_deserialize (IBusProperty *prop, g_variant_get_child (variant, retval++, "u", &prop->priv->type); GVariant *subvar = g_variant_get_child_value (variant, retval++); - if (prop->priv->label && !ibus_text_get_is_static (prop->priv->label)) { + if (prop->priv->label) { g_object_unref (prop->priv->label); } prop->priv->label = IBUS_TEXT (ibus_serializable_deserialize (subvar)); @@ -414,7 +411,7 @@ ibus_property_deserialize (IBusProperty *prop, ibus_g_variant_get_child_string (variant, retval++, &prop->priv->icon); subvar = g_variant_get_child_value (variant, retval++); - if (prop->priv->tooltip && !ibus_text_get_is_static (prop->priv->tooltip)) { + if (prop->priv->tooltip) { g_object_unref (prop->priv->tooltip); } prop->priv->tooltip = IBUS_TEXT (ibus_serializable_deserialize (subvar)); @@ -435,7 +432,7 @@ ibus_property_deserialize (IBusProperty *prop, /* Keep the serialized order for the compatibility when add new members. */ subvar = g_variant_get_child_value (variant, retval++); - if (prop->priv->symbol && !ibus_text_get_is_static (prop->priv->symbol)) { + if (prop->priv->symbol) { g_object_unref (prop->priv->symbol); } prop->priv->symbol = IBUS_TEXT (ibus_serializable_deserialize (subvar)); @@ -567,7 +564,7 @@ ibus_property_set_label (IBusProperty *prop, g_assert (IBUS_IS_PROPERTY (prop)); g_return_if_fail (label == NULL || IBUS_IS_TEXT (label)); - if (prop->priv->label && !ibus_text_get_is_static (prop->priv->label)) { + if (prop->priv->label) { g_object_unref (prop->priv->label); } @@ -575,8 +572,10 @@ ibus_property_set_label (IBusProperty *prop, prop->priv->label = ibus_text_new_from_static_string (""); } else { - prop->priv->label = g_object_ref_sink (label); + prop->priv->label = label; } + + g_object_ref_sink (prop->priv->label); } void @@ -586,7 +585,7 @@ ibus_property_set_symbol (IBusProperty *prop, g_assert (IBUS_IS_PROPERTY (prop)); g_return_if_fail (symbol == NULL || IBUS_IS_TEXT (symbol)); - if (prop->priv->symbol && !ibus_text_get_is_static (prop->priv->symbol)) { + if (prop->priv->symbol) { g_object_unref (prop->priv->symbol); } @@ -594,8 +593,10 @@ ibus_property_set_symbol (IBusProperty *prop, prop->priv->symbol = ibus_text_new_from_static_string (""); } else { - prop->priv->symbol = g_object_ref_sink (symbol); + prop->priv->symbol = symbol; } + + g_object_ref_sink (prop->priv->symbol); } void @@ -615,7 +616,7 @@ ibus_property_set_tooltip (IBusProperty *prop, g_assert (IBUS_IS_PROPERTY (prop)); g_assert (tooltip == NULL || IBUS_IS_TEXT (tooltip)); - if (prop->priv->tooltip && !ibus_text_get_is_static (prop->priv->tooltip)) { + if (prop->priv->tooltip) { g_object_unref (prop->priv->tooltip); } @@ -624,8 +625,9 @@ ibus_property_set_tooltip (IBusProperty *prop, } else { prop->priv->tooltip = tooltip; - g_object_ref_sink (prop->priv->tooltip); } + + g_object_ref_sink (prop->priv->tooltip); } void -- 2.34.1 From 1b5b9548ad418765717ce1fbdc70b3f3eaae67fc Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 14 Mar 2022 14:25:10 +0900 Subject: [PATCH] client/gtk2: Revert CCedilla change for pt-BR gtk_im_context_simple_add_table() is deprecated in GTK4. I decide to delete gtk_im_context_simple_add_table() here because the change 03c9e591430c62354bbf26ef7bd4a2e6acfb7c8f is no longer needed because IBusEngineSimple has implemented to load pt_br compose key by locale BUG=chromium-os:11421 BUG=http://codereview.appspot.com/3989060 --- client/gtk2/ibusimcontext.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index a5e5e792..e314ae98 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -2,7 +2,7 @@ /* vim:set et sts=4: */ /* ibus - The Input Bus * Copyright (C) 2008-2013 Peng Huang - * Copyright (C) 2015-2021 Takao Fujiwara + * Copyright (C) 2015-2022 Takao Fujiwara * Copyright (C) 2008-2021 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -874,33 +874,6 @@ ibus_im_context_class_fini (IBusIMContextClass *class) g_bus_unwatch_name (_daemon_name_watch_id); } -/* Copied from gtk+2.0-2.20.1/modules/input/imcedilla.c to fix crosbug.com/11421. - * Overwrite the original Gtk+'s compose table in gtk+-2.x.y/gtk/gtkimcontextsimple.c. */ - -/* The difference between this and the default input method is the handling - * of C+acute - this method produces C WITH CEDILLA rather than C WITH ACUTE. - * For languages that use CCedilla and not acute, this is the preferred mapping, - * and is particularly important for pt_BR, where the us-intl keyboard is - * used extensively. - */ -static guint16 cedilla_compose_seqs[] = { -#ifdef DEPRECATED_GDK_KEYSYMS - GDK_dead_acute, GDK_C, 0, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_dead_acute, GDK_c, 0, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ - GDK_Multi_key, GDK_apostrophe, GDK_C, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_Multi_key, GDK_apostrophe, GDK_c, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ - GDK_Multi_key, GDK_C, GDK_apostrophe, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_Multi_key, GDK_c, GDK_apostrophe, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ -#else - GDK_KEY_dead_acute, GDK_KEY_C, 0, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_KEY_dead_acute, GDK_KEY_c, 0, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ - GDK_KEY_Multi_key, GDK_KEY_apostrophe, GDK_KEY_C, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_KEY_Multi_key, GDK_KEY_apostrophe, GDK_KEY_c, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ - GDK_KEY_Multi_key, GDK_KEY_C, GDK_KEY_apostrophe, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ - GDK_KEY_Multi_key, GDK_KEY_c, GDK_KEY_apostrophe, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ -#endif -}; - static void ibus_im_context_init (GObject *obj) { @@ -936,10 +909,6 @@ ibus_im_context_init (GObject *obj) // Create slave im context ibusimcontext->slave = gtk_im_context_simple_new (); - gtk_im_context_simple_add_table (GTK_IM_CONTEXT_SIMPLE (ibusimcontext->slave), - cedilla_compose_seqs, - 4, - G_N_ELEMENTS (cedilla_compose_seqs) / (4 + 2)); g_signal_connect (ibusimcontext->slave, "commit", -- 2.34.1 From 37900574934bb01cc31860ae3ae2f668e4360838 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 28 Mar 2022 23:18:58 +0900 Subject: [PATCH] src/tests: Run ibus-daemon from CI even if GNOME desktop gnome-shell no longer launch ibus-daemon with IBus systemd file. This is a workaround to call ibus-daemon after GNOME fails to launch ibus-daemon BUG=https://gitlab.gnome.org/GNOME/gdm/-/issues/777 --- src/tests/ibus-desktop-testing-runner.in | 38 +++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in index 48528326..6b208345 100755 --- a/src/tests/ibus-desktop-testing-runner.in +++ b/src/tests/ibus-desktop-testing-runner.in @@ -55,6 +55,7 @@ GREEN='\033[0;32m' RED='\033[0;31m' NC='\033[0m' + print_log() { if [ x"$RESULT_LOG" != x ] ; then @@ -69,6 +70,7 @@ print_log() fi } + usage() { $ECHO -e \ @@ -95,6 +97,7 @@ usage() "" } + parse_args() { # This is GNU getopt. "sudo port getopt" in BSD? @@ -129,6 +132,7 @@ parse_args() fi } + init_desktop() { if [ "$RESULT_LOG" != "" ] ; then @@ -207,6 +211,7 @@ _EOF #export XDG_SEAT=seat0 } + run_dbus_daemon() { # Use dbus-launch --exit-with-session later instead of --sh-syntax @@ -216,6 +221,7 @@ run_dbus_daemon() export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus" } + init_gnome() { # gsettings set command needs dconf-service with the same $DISPLAY @@ -258,6 +264,7 @@ init_gnome() fi } + run_desktop() { echo "$DESKTOP_COMMAND" | grep gnome-session > /dev/null @@ -278,12 +285,28 @@ run_desktop() $DESKTOP_COMMAND & PID_GNOME_SESSION=$! sleep 30 - if [ $HAS_GNOME -ne 0 ] ; then - ibus-daemon --daemonize --verbose - sleep 3 - fi + + # gnome-shell 42 checks if org.freedesktop.IBus.session.GNOME.service + # systemd file is available with org.freedesktop.systemd1.Manager.GetUnit + # D-Bus method, which is provided by IBus 1.5.26, and if the file + # is available, gnome-shell no longer launch ibus-daemon + # because gnome-shell assumes gnome-session would launch ibus-daemon + # with org.freedesktop.systemd1.Manager.StartUnit D-Bus method. + # But actually gnome-session failed to launch ibus-daemon + # because the IBus systemd file depends on gnome-session.target + # but this CI launches gnome-session directly. + # + # So ibus-dameon is now always called here after gnome-shell fails to + # launch ibus-daemon. + # It may be better this CI launches GDM autologin to run gnome-session + # with gnome-session.target systemd file. + # But `systemctl start gdm` terminates the parent script forcibly + # and the script cannot get the CI result. + ibus-daemon --daemonize --verbose + sleep 3 } + count_case_result() { retval=$1 @@ -298,6 +321,7 @@ count_case_result() echo $pass $fail } + echo_case_result() { retval=$1 @@ -311,6 +335,7 @@ echo_case_result() fi } + run_direct_test_cases() { pass=0 @@ -363,6 +388,7 @@ EOF_ENVS echo $pass $fail } + run_gnome_desktop_testing_runner() { pass=0 @@ -397,6 +423,7 @@ EOF echo $pass $fail } + run_test_suite() { pass=0 @@ -435,6 +462,7 @@ EOF_RUNNER fi } + finit() { echo "# Killing left gnome-session and Xorg" @@ -451,6 +479,7 @@ finit() echo "# Finished $PROGNAME testing" } + main() { parse_args "$@" @@ -470,5 +499,6 @@ main() finit } + # Need to enclose $@ with double quotes not to split the array. main "$@" -- 2.34.1 From b024ea8fcee6fe1a20570a6f80cc4f9f8f420706 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Wed, 20 Apr 2022 19:36:10 +0900 Subject: [PATCH] ui/gtk3: Disable XKB engines in Plasma Wayland Currently ibus-ui-gtk3 runs the setxkbmap command internally to set the XKB keymaps from XKB engines but setxkbmap does not work in Wayland session. The IBus XKB engines are disabled at the moment in Plamsa Wayland and ibus-ui-gtk3 asks users to use systemsettings5. Will use libinput and libxkbcommon later but it would be better to implement IBus in Plamsa Wayland compositor. BUG=rhbz#2076596 --- configure.ac | 16 ++++++++++ ui/gtk3/Makefile.am | 17 ++++++++++- ui/gtk3/panel.vala | 74 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 100 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index a3cdb2da..79b9c11a 100644 --- a/configure.ac +++ b/configure.ac @@ -636,6 +636,21 @@ if test x"$enable_engine" = x"yes"; then enable_engine="yes (enabled, use --disable-engine to disable)" fi +# --disable-libnotify +AC_ARG_ENABLE(libnotify, + AS_HELP_STRING([--disable-libnotify], + [Disable to link libnotify]), + [enable_libnotify=$enableval], + [enable_libnotify=yes] +) +AM_CONDITIONAL([ENABLE_LIBNOTIFY], [test x"$enable_libnotify" = x"yes"]) +if test x"$enable_libnotify" = x"yes"; then + PKG_CHECK_MODULES(LIBNOTIFY, [ + libnotify >= 0.7 + ]) + enable_libnotify="yes (enabled, use --disable-libnotify to disable)" +fi + PKG_CHECK_MODULES(XTEST, [x11 xtst], [enable_xtest=yes], @@ -871,6 +886,7 @@ Build options: No snooper regexes "$NO_SNOOPER_APPS" Panel icon "$IBUS_ICON_KEYBOARD" Enable surrounding-text $enable_surrounding_text + Enable libnotify $enable_libnotify Enable Emoji dict $enable_emoji_dict Unicode Emoji directory $UNICODE_EMOJI_DIR CLDR annotation directory $EMOJI_ANNOTATION_DIR diff --git a/ui/gtk3/Makefile.am b/ui/gtk3/Makefile.am index ab379328..2a9cabde 100644 --- a/ui/gtk3/Makefile.am +++ b/ui/gtk3/Makefile.am @@ -3,7 +3,7 @@ # ibus - The Input Bus # # Copyright (c) 2007-2015 Peng Huang -# Copyright (c) 2015-2020 Takao Fujwiara +# Copyright (c) 2015-2022 Takao Fujwiara # Copyright (c) 2007-2020 Red Hat, Inc. # # This library is free software; you can redistribute it and/or @@ -81,6 +81,21 @@ AM_VALAFLAGS = \ --target-glib="$(VALA_TARGET_GLIB_VERSION)" \ $(NULL) +if ENABLE_LIBNOTIFY +AM_CFLAGS += \ + @LIBNOTIFY_CFLAGS@ \ + $(NULL) + +AM_LDADD += \ + @LIBNOTIFY_LIBS@ \ + $(NULL) + +AM_VALAFLAGS += \ + --pkg=libnotify \ + -D ENABLE_LIBNOTIFY \ + $(NULL) +endif + if ENABLE_APPINDICATOR AM_VALAFLAGS += --define=INDICATOR endif diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index 07ce6524..bd70d7d2 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -73,6 +73,7 @@ class Panel : IBus.PanelService { private string m_icon_prop_key = ""; private int m_property_icon_delay_time = 500; private uint m_property_icon_delay_time_id; + private bool m_is_wayland; #if INDICATOR private bool m_is_kde = is_kde(); #else @@ -93,6 +94,18 @@ class Panel : IBus.PanelService { m_bus = bus; +#if USE_GDK_WAYLAND + Gdk.set_allowed_backends("*"); + var display = Gdk.DisplayManager.get().open_display(null); + Type instance_type = display.get_type(); + Type wayland_type = typeof(GdkWayland.Display); + m_is_wayland = instance_type.is_a(wayland_type); + Gdk.set_allowed_backends("x11"); +#else + m_is_wayland = false; + warning("Checking Wayland is disabled"); +#endif + init_settings(); // init ui @@ -553,6 +566,11 @@ class Panel : IBus.PanelService { GLib.List im_engines = get_engines_from_locale(engines); + if (m_is_wayland) { + if (xkb_engines.length() > 0) + xkb_engines = new GLib.List(); + } + string[] names = {}; foreach (unowned IBus.EngineDesc engine in xkb_engines) names += engine.get_name(); @@ -728,6 +746,32 @@ class Panel : IBus.PanelService { inited_engines_order = false; } + private void update_version_1_5_26() { +#if ENABLE_LIBNOTIFY + if (!Notify.is_initted()) { + Notify.init ("ibus"); + } + + var notification = new Notify.Notification( + _("IBus Attention"), + _("Layout changes do not work in Plasma Wayland. " + + "Please use systemsettings5."), + "ibus"); + notification.set_timeout(30 * 1000); + notification.set_category("hotkey"); + + try { + notification.show(); + } catch (GLib.Error e){ + warning (_("Layout changes do not work in Plasma Wayland. " + + "Please use systemsettings5.")); + } +#else + warning (_("Layout changes do not work in Plasma Wayland. " + + "Please use systemsettings5.")); +#endif + } + private void set_version() { string prev_version = m_settings_general.get_string("version"); string current_version = null; @@ -735,6 +779,9 @@ class Panel : IBus.PanelService { if (compare_versions(prev_version, "1.5.8") < 0) update_version_1_5_8(); + if (compare_versions(prev_version, "1.5.26") < 0) + update_version_1_5_26(); + current_version = "%d.%d.%d".printf(IBus.MAJOR_VERSION, IBus.MINOR_VERSION, IBus.MICRO_VERSION); @@ -856,7 +903,7 @@ class Panel : IBus.PanelService { m_icon_prop_key = ""; // set xkb layout - if (!m_use_system_keyboard_layout) + if (!m_use_system_keyboard_layout && !m_is_wayland) m_xkblayout.set_layout(engine); set_language_from_engine(engine); @@ -960,17 +1007,25 @@ class Panel : IBus.PanelService { string[]? order_names) { string[]? engine_names = unowned_engine_names; - if (engine_names == null || engine_names.length == 0) - engine_names = {"xkb:us::eng"}; + if (engine_names == null || engine_names.length == 0) { + if (m_is_wayland) + engine_names = {}; + else + engine_names = {"xkb:us::eng"}; + } string[] names = {}; foreach (var name in order_names) { + if (m_is_wayland && name.has_prefix("xkb:")) + continue; if (name in engine_names) names += name; } foreach (var name in engine_names) { + if (m_is_wayland && name.has_prefix("xkb:")) + continue; if (name in names) continue; names += name; @@ -1011,9 +1066,14 @@ class Panel : IBus.PanelService { } if (m_engines.length == 0) { - m_engines = engines; - switch_engine(0, true); - run_preload_engines(engines, 1); + if (engines.length > 0) { + m_engines = engines; + switch_engine(0, true); + run_preload_engines(engines, 1); + } else { + m_candidate_panel.set_language(new Pango.AttrLanguage( + Pango.Language.from_string(null))); + } } else { var current_engine = m_engines[0]; m_engines = engines; @@ -1478,6 +1538,8 @@ class Panel : IBus.PanelService { /* Do not change the order of m_engines during running switcher. */ if (m_switcher.is_running()) return; + if (m_engines.length == 0) + return; if (m_icon_type == IconType.INDICATOR) { // Wait for the callback of the session bus. -- 2.34.1 From bca7bf0f97230806a26f53c798050408108cfb3d Mon Sep 17 00:00:00 2001 From: Mike FABIAN Date: Wed, 25 May 2022 23:07:24 +0900 Subject: [PATCH] data/dconf: Update xkb-latin-layouts in gschema Add more keyboard layouts which cannot produce ASCII to data/dconf/org.freedesktop.ibus.gschema.xml Remove "mal" and "mkd", there are no such layouts. BUG=https://github.com/ibus/ibus/issues/2404 --- data/dconf/org.freedesktop.ibus.gschema.xml | 47 ++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/data/dconf/org.freedesktop.ibus.gschema.xml b/data/dconf/org.freedesktop.ibus.gschema.xml index 516f7520..8b181d76 100644 --- a/data/dconf/org.freedesktop.ibus.gschema.xml +++ b/data/dconf/org.freedesktop.ibus.gschema.xml @@ -28,7 +28,52 @@ The saved version number will be used to check the difference between the version of the previous installed ibus and one of the current ibus. - [ 'ara', 'bg', 'cz', 'dev', 'gr', 'gur', 'in', 'jp(kana)', 'mal', 'mkd', 'ru', 'ua' ] + + [ 'af', 'af(fa-olpc)', 'af(ps-olpc)', 'af(ps)', 'af(uz)', + 'af(uz-olpc)', 'am', 'am(eastern)', 'am(eastern-alt)', + 'am(phonetic)', 'am(phonetic-alt)', 'am(western)', 'ara', + 'ara(azerty)', 'ara(azerty_digits)', 'ara(buckwalter)', + 'ara(digits)', 'ara(qwerty)', 'ara(qwerty_digits)', + 'az(cyrillic)', 'bd', 'bd(probhat)', 'bg', 'bg(bas_phonetic)', + 'bg(phonetic)', 'brai', 'brai(left_hand)', 'brai(right_hand)', + 'bt', 'by', 'by(legacy)', 'ca(ike)', 'ca(multi-2gr)', + 'cn(tib)', 'cn(tib_asciinum)', 'cn(ug)', 'cz', 'cz(ucw)', + 'de(ru)', 'dev', 'et', 'fr(geo)', 'ge', 'ge(os)', 'gr', + 'gr(extended)', 'gr(nodeadkeys)', 'gr(polytonic)', + 'gr(simple)', 'gur', 'il', 'il(biblical)', 'il(lyx)', + 'il(phonetic)', 'in', 'in(ben)', 'in(ben_baishakhi)', + 'in(ben_bornona)', 'in(ben_gitanjali)', 'in(ben_inscript)', + 'in(ben_probhat)', 'in(bolnagri)', 'in(deva)', 'in(guj)', + 'in(guru)', 'in(hin-kagapa)', 'in(hin-wx)', 'in(jhelum)', + 'in(kan)', 'in(kan-kagapa)', 'in(mal)', 'in(mal_enhanced)', + 'in(mal_lalitha)', 'in(mar-kagapa)', 'in(ori)', + 'in(san-kagapa)', 'in(tam)', 'in(tam_tamilnet)', + 'in(tam_tamilnet_TAB)', 'in(tam_tamilnet_TSCII)', + 'in(tam_tamilnet_with_tam_nums)', 'in(tel)', 'in(tel-kagapa)', + 'in(urd-phonetic)', 'in(urd-phonetic3)', 'in(urd-winkeys)', + 'iq', 'ir', 'ir(pes_keypad)', 'jp(kana)', 'jp(mac)', 'kg', + 'kg(phonetic)', 'kh', 'kz', 'kz(kazrus)', 'kz(ruskaz)', 'la', + 'la(stea)', 'lk', 'lk(tam_TAB)', 'lk(tam_unicode)', 'ma', + 'ma(tifinagh)', 'ma(tifinagh-alt)', + 'ma(tifinagh-alt-phonetic)', 'ma(tifinagh-extended)', + 'ma(tifinagh-extended-phonetic)', 'ma(tifinagh-phonetic)', + 'me(cyrillic)', 'me(cyrillicalternatequotes)', + 'me(cyrillicyz)', 'mk', 'mk(nodeadkeys)', 'mm', 'mn', 'mv', + 'np', 'ph(capewell-dvorak-bay)', 'ph(capewell-qwerf2k6-bay)', + 'ph(colemak-bay)', 'ph(dvorak-bay)', 'ph(qwerty-bay)', 'pk', + 'pk(ara)', 'pk(snd)', 'pk(urd-crulp)', 'pk(urd-nla)', + 'pl(ru_phonetic_dvorak)', 'rs', 'rs(alternatequotes)', + 'rs(rue)', 'rs(yz)', 'ru', 'ru(bak)', 'ru(chm)', 'ru(cv)', + 'ru(dos)', 'ru(kom)', 'ru(legacy)', 'ru(mac)', + 'ru(os_legacy)', 'ru(os_winkeys)', 'ru(phonetic)', + 'ru(phonetic_winkeys)', 'ru(sah)', 'ru(srp)', 'ru(tt)', + 'ru(typewriter)', 'ru(typewriter-legacy)', 'ru(udm)', + 'ru(xal)', 'se(rus)', 'se(rus_nodeadkeys)', 'se(swl)', 'sy', + 'sy(syc)', 'sy(syc_phonetic)', 'th', 'th(pat)', 'th(tis)', + 'tj', 'tj(legacy)', 'tz', 'ua', 'ua(homophonic)', + 'ua(legacy)', 'ua(phonetic)', 'ua(rstu)', 'ua(rstu_ru)', + 'ua(typewriter)', 'ua(winkeys)', 'us(chr)', 'us(rus)', 'uz' ] + Latin layouts which have no ASCII US layout is appended to the Latin layouts. variant can be omitted. -- 2.35.3 From 16df64edadc21f50906e5442b73425b9256fbf65 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Wed, 25 May 2022 23:07:33 +0900 Subject: [PATCH] src/tests: Add xkb-latin-layouts case BUG=https://github.com/ibus/ibus/issues/2404 --- src/tests/Makefile.am | 26 ++++++-- src/tests/runtest | 1 + src/tests/xkb-latin-layouts | 130 ++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 8 deletions(-) create mode 100755 src/tests/xkb-latin-layouts diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index f932f18f..ca5285bd 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -41,8 +41,9 @@ prog_ldadd =\ $(top_builddir)/src/libibus-@IBUS_API_VERSION@.la \ $(NULL) -noinst_PROGRAMS = $(TESTS) -TESTS = \ +noinst_PROGRAMS = $(TESTS_C) +noinst_SCRIPTS = $(TESTS_SCRIPT) +TESTS_C = \ ibus-bus \ ibus-config \ ibus-configservice \ @@ -56,16 +57,25 @@ TESTS = \ ibus-util \ $(NULL) +TESTS_SCRIPT = \ + xkb-latin-layouts \ + $(NULL) + +TESTS = \ + $(TESTS_C) \ + $(TESTS_SCRIPT) \ + $(NULL) + CLEANFILES = if ENABLE_ENGINE -TESTS += ibus-engine-switch +TESTS_C += ibus-engine-switch endif if ENABLE_GTK3 -TESTS += ibus-compose +TESTS_C += ibus-compose if ENABLE_XTEST -TESTS += ibus-keypress +TESTS_C += ibus-keypress endif endif @@ -99,9 +109,10 @@ CLEANFILES += \ org.freedesktop.IBus.Desktop.Testing.desktop \ $(NULL) -test_execs_PROGRAMS = $(TESTS) +test_execs_PROGRAMS = $(TESTS_C) +test_execs_SCRIPTS = $(TESTS_SCRIPT) if ENABLE_GTK3 -test_execs_SCRIPTS = ibus-compose-locales +test_execs_SCRIPTS += ibus-compose-locales CLEANFILES += \ ibus-compose-locales \ $(NULL) @@ -138,6 +149,7 @@ ibus-desktop-testing-runner: ibus-desktop-testing-runner.in EXTRA_DIST = \ $(test_metas_in) \ + $(TESTS_SCRIPT) \ runtest \ ibus-compose.emoji \ ibus-compose.env \ diff --git a/src/tests/runtest b/src/tests/runtest index a6e4194b..a229140a 100755 --- a/src/tests/runtest +++ b/src/tests/runtest @@ -35,6 +35,7 @@ ibus-engine-switch ibus-compose ibus-keypress test-stress +xkb-latin-layouts " IBUS_SCHEMA_FILE='org.freedesktop.ibus.gschema.xml' GTK_QUERY_MODULE=gtk-query-immodules-3.0-32 diff --git a/src/tests/xkb-latin-layouts b/src/tests/xkb-latin-layouts new file mode 100755 index 00000000..f8dced6b --- /dev/null +++ b/src/tests/xkb-latin-layouts @@ -0,0 +1,130 @@ +#!/bin/bash + +PROGNAME=`basename $0` +VERSION=0.1 +# POSIX sh has no 'echo -e' +: ${ECHO:='/usr/bin/echo'} +TMPDIR= +INSTALLED_SCHEMAS_DIR= + + +usage() +{ + $ECHO -e \ +"This test runs setxkbmap command for gsettings xkb-latin-layouts value\n" \ +"$PROGNAME [OPTIONS…]\n" \ +"\n" \ +"OPTIONS:\n" \ +"-h, --help This help\n" \ +"-v, --version Show version\n" \ +"-D, --schemasdir=DIR Load the latest schema file in DIR\n" \ +"" +} + + +parse_args() +{ + # This is GNU getopt. "sudo port getopt" in BSD? + ARGS=`getopt -o hD:Tv --long \ + help,schemasdir:,tap,version\ + -- "$@"`; + eval set -- "$ARGS" + while [ 1 ] ; do + case "$1" in + -h | --help ) usage; exit 0;; + -D | --schemasdir ) INSTALLED_SCHEMAS_DIR="$2"; shift 2;; + -T | --tap ) shift;; # ignore the option + -v | --version ) $ECHO -e "$VERSION"; exit 0;; + -- ) shift; break;; + * ) shift;; + esac + done +} + + +init() +{ + set -e + + # gnome-continuous doesn't have a machine-id set, which + # breaks dbus-launch. There's dbus-run-session which is + # better, but not everyone has it yet. + export DBUS_FATAL_WARNINGS=0 + export TMPDIR=$(mktemp -d --tmpdir="$PWD") + export XDG_CONFIG_HOME="$TMPDIR/config" + export XDG_CACHE_HOME="$TMPDIR/cache" + export GSETTINGS_SCHEMA_DIR="$TMPDIR/schemas" + mkdir -p $XDG_CONFIG_HOME $XDG_CACHE_HOME $GSETTINGS_SCHEMA_DIR + + eval `dbus-launch --sh-syntax` + + trap 'rm -rf $TMPDIR; kill $DBUS_SESSION_BUS_PID; setxkbmap -layout us' ERR + + # in case that schema is not installed on the system + glib-compile-schemas --targetdir "$GSETTINGS_SCHEMA_DIR" "$INSTALLED_SCHEMAS_DIR" +} + + +finit() +{ + # dbus-launch and gsettings run /usr/lib*/gvfsd-fuse $TMPDIR/cache/gvfs -f + # via systemd since gvfs 1.45.90 in Fedora 33 + # and rm $TMPDIR could be failed until umount would be called. + if [ -d $TMPDIR/cache/gvfs ] ; then + umount $TMPDIR/cache/gvfs + fi + rm -rf $TMPDIR + + kill $DBUS_SESSION_BUS_PID + exit 0 +} + + +test_xkb_keymaps() +{ + # Loop over top level schemas since "gsettings list-recursively" only + # looks for direct children. + xkb_latin_layouts=`gsettings get org.freedesktop.ibus.general xkb-latin-layouts` + while read keymap ; do + eval keymap="$keymap" + HAS_VARIANT=$($ECHO "$keymap" | grep '(' 2> /dev/null) ||: + if [ "x$HAS_VARIANT" != "x" ] ; then + layout=$($ECHO "$keymap" | sed -e 's/\([^(]*\)([^)]*)/\1/') + variant=$($ECHO "$keymap" | sed -e 's/[^(]*(\([^)]*\))/\1/') + $ECHO setxkbmap -layout $layout -variant $variant + setxkbmap -layout $layout -variant $variant + else + layout="$keymap" + $ECHO setxkbmap -layout $layout + setxkbmap -layout $layout + fi + if [ $? -ne 0 ] ; then + $ECHO "Error in layout $layout variant $variant" + setxkbmap -layout us + exit 1 + fi + done << EOF_READ_XKB + `$ECHO $xkb_latin_layouts | sed -e 's/^\[//' -e 's/\]$//' | tr "," "\n"` +EOF_READ_XKB + + setxkbmap -layout us +} + + +main() +{ + parse_args "$@" + + if [ x"$INSTALLED_SCHEMAS_DIR" != x ] ; then + init + fi + + test_xkb_keymaps + + if [ x"$INSTALLED_SCHEMAS_DIR" != x ] ; then + finit + fi +} + + +main "$@" -- 2.35.3 From 9f2f24e615d7280b11cd244395c6b8122c47177a Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 26 May 2022 14:47:49 +0900 Subject: [PATCH] src/tests: Unset G_MESSAGES_DEBUG for gsettings in xkb-latin-layouts gsettings cannot get the key value when G_MESSAGES_DEBUG is enabled. --- src/tests/xkb-latin-layouts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/xkb-latin-layouts b/src/tests/xkb-latin-layouts index f8dced6b..92464234 100755 --- a/src/tests/xkb-latin-layouts +++ b/src/tests/xkb-latin-layouts @@ -82,9 +82,16 @@ finit() test_xkb_keymaps() { + # G_MESSAGES_DEBUG=all or G_MESSAGES_DEBUG=GLib-GIO-DEBUG would append + # debug messages to gsettings output and could not get the result correctly. + backup_G_MESSAGES_DEBUG="$G_MESSAGES_DEBUG" + unset G_MESSAGES_DEBUG # Loop over top level schemas since "gsettings list-recursively" only # looks for direct children. xkb_latin_layouts=`gsettings get org.freedesktop.ibus.general xkb-latin-layouts` + if [ x"$backup_G_MESSAGES_DEBUG" != x ] ; then + export G_MESSAGES_DEBUG=$backup_G_MESSAGES_DEBUG + fi while read keymap ; do eval keymap="$keymap" HAS_VARIANT=$($ECHO "$keymap" | grep '(' 2> /dev/null) ||: -- 2.35.3 From 59d9401da254c0152c313f9027457eb234a23a8c Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Sat, 11 Jun 2022 21:10:12 +0900 Subject: [PATCH] ui/gtk3: Hide XKB engine but enable it in Plasma Wayland IBus just cannot forward key events in Plasma Wayland because IBus has to handle the compose keys. BUG=rhbz#2088656 --- ui/gtk3/panel.vala | 50 ++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index 61bfa1b6..28a1aa0b 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -41,6 +41,7 @@ class Panel : IBus.PanelService { private Gtk.Menu m_ime_menu; private Gtk.Menu m_sys_menu; private IBus.EngineDesc[] m_engines = {}; + private IBus.EngineDesc m_en_engine; private GLib.HashTable m_engine_contexts = new GLib.HashTable(GLib.str_hash, GLib.str_equal); @@ -910,13 +911,20 @@ class Panel : IBus.PanelService { } private void switch_engine(int i, bool force = false) { - GLib.assert(i >= 0 && i < m_engines.length); + if (m_is_wayland) + GLib.assert(i >= 0 && i <= m_engines.length); + else + GLib.assert(i >= 0 && i < m_engines.length); // Do not need switch if (i == 0 && !force) return; - IBus.EngineDesc engine = m_engines[i]; + IBus.EngineDesc engine; + if (m_is_wayland && m_engines.length == 0) + engine = m_en_engine; + else + engine = m_engines[i]; set_engine(engine); } @@ -1006,17 +1014,15 @@ class Panel : IBus.PanelService { string[]? order_names) { string[]? engine_names = unowned_engine_names; - if (engine_names == null || engine_names.length == 0) { - if (m_is_wayland) - engine_names = {}; - else - engine_names = {"xkb:us::eng"}; - } + if (engine_names == null || engine_names.length == 0) + engine_names = {"xkb:us::eng"}; string[] names = {}; foreach (var name in order_names) { if (m_is_wayland && name.has_prefix("xkb:")) + name = "xkb:us::eng"; + if (name in names) continue; if (name in engine_names) names += name; @@ -1024,7 +1030,7 @@ class Panel : IBus.PanelService { foreach (var name in engine_names) { if (m_is_wayland && name.has_prefix("xkb:")) - continue; + name = "xkb:us::eng"; if (name in names) continue; names += name; @@ -1065,14 +1071,20 @@ class Panel : IBus.PanelService { } if (m_engines.length == 0) { - if (engines.length > 0) { - m_engines = engines; - switch_engine(0, true); - run_preload_engines(engines, 1); - } else { - m_candidate_panel.set_language(new Pango.AttrLanguage( - Pango.Language.from_string(null))); + m_engines = engines; + // Do not show engines in panel icon and suggest systemsettings5 + // in Plasma Wayland in case all engines are XKB. + if (m_is_wayland && m_engines.length == 1 && + m_engines[0].get_name() == "xkb:us::eng") { + m_engines = {}; + if (m_en_engine == null) { + m_en_engine = + m_bus.get_engines_by_names({"xkb:us::eng"})[0]; + } } + switch_engine(0, true); + if (m_engines.length > 0) + run_preload_engines(m_engines, 1); } else { var current_engine = m_engines[0]; m_engines = engines; @@ -1289,6 +1301,10 @@ class Panel : IBus.PanelService { var longname = engine.get_longname(); var textdomain = engine.get_textdomain(); var transname = GLib.dgettext(textdomain, longname); + if (m_is_wayland && engine.get_name().has_prefix("xkb:")) { + language = _("Other"); + transname = _("No input method"); + } var item = new Gtk.MenuItem.with_label( "%s - %s".printf (IBus.get_language_name(language), transname)); // Make a copy of engine to workaround a bug in vala. @@ -1566,7 +1582,7 @@ class Panel : IBus.PanelService { if (engine != null) { var name = engine.get_name(); - if (name.length >= 4 && name[0:4] == "xkb:") + if (!m_is_wayland && name.length >= 4 && name[0:4] == "xkb:") language = m_switcher.get_xkb_language(engine); } -- 2.35.3