diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch index c3ef9f9..a0b9991 100644 --- a/ibus-HEAD.patch +++ b/ibus-HEAD.patch @@ -511,3 +511,246 @@ index 48528326..6b208345 100755 -- 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 + diff --git a/ibus.spec b/ibus.spec index 47573f5..e145dd9 100644 --- a/ibus.spec +++ b/ibus.spec @@ -39,7 +39,7 @@ Name: ibus Version: 1.5.26 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Intelligent Input Bus for Linux OS License: LGPLv2+ URL: https://github.com/ibus/%name/wiki @@ -322,6 +322,7 @@ autoreconf -f -i -v --enable-install-tests \ %{nil} +make -C ui/gtk3 maintainer-clean-generic %make_build %install @@ -521,6 +522,9 @@ dconf update || : %{_datadir}/installed-tests/ibus %changelog +* Wed Apr 20 2022 Takao Fujiwara - 1.5.26-4 +- Resolves: #2076596 Disable XKB engines in Plasma Wayland + * Thu Mar 31 2022 Takao Fujiwara - 1.5.26-3 - Fix refcounting issues in IBusText & IBusProperty