From 571e3b6e4f386abf12d3db70b9468e092c8d72bd Mon Sep 17 00:00:00 2001 From: Alynx Zhou Date: Tue, 24 Aug 2021 10:12:52 +0800 Subject: [PATCH] client/gtk2/ibusimcontext: Fix wrong cursor location in gtk3 apps If you apply this patch in your tarball, please also apply this to client/gtk3/ibusimcontext.c besides client/gtk2/ibusimcontext.c . BUG=https://github.com/ibus/ibus/issues/2337 --- client/gtk2/ibusimcontext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index da9a402f..b1ccede9 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -1497,7 +1497,10 @@ _set_cursor_location_internal (IBusIMContext *ibusimcontext) #if GTK_CHECK_VERSION (3, 98, 4) #elif GTK_CHECK_VERSION (2, 91, 0) - area.y += gdk_window_get_height (ibusimcontext->client_window); + if (area.x == -1 && area.y == -1 && area.width == 0 && area.height == 0) { + area.x = 0; + area.y += gdk_window_get_height (ibusimcontext->client_window); + } #else if (area.x == -1 && area.y == -1 && area.width == 0 && area.height == 0) { gint w, h; -- 2.31.1 From 5487a6baa4b22605ba8197ca1a0fa43c91d57786 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 6 Sep 2021 20:23:59 +0900 Subject: [PATCH] client/gtk2/ibusimcontext: Implement clear preedit for GTK4 IBus IM module uses synchornized key processes for GTK4 and the timing of the GTK reset siginal may work with focus-in/out between windows. (I don't test GTK4 firefox and terminal yet and the verification is not completed.) So ibus_im_context_clear_preedit_text() is now called with the GTK4 reset siginal. ibus_im_context_clear_preedit_text() works with ibus-setup-anthy -> "Conversion" tab -> "Behavior on Focus Out" pull down menu. BUG=https://github.com/ibus/ibus/issues/2334 --- client/gtk2/ibusimcontext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index b1ccede9..e12be45d 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -1270,6 +1270,8 @@ ibus_im_context_reset (GtkIMContext *context) * IBus uses button-press-event instead until GTK is fixed. * https://gitlab.gnome.org/GNOME/gtk/issues/1534 */ + if (_use_sync_mode) + ibus_im_context_clear_preedit_text (ibusimcontext); ibus_input_context_reset (ibusimcontext->ibuscontext); } gtk_im_context_reset (ibusimcontext->slave); @@ -1383,7 +1385,7 @@ ibus_im_context_set_client_window (GtkIMContext *context, if (ibusimcontext->client_window) { #if !GTK_CHECK_VERSION (3, 98, 4) - if (ibusimcontext->use_button_press_event) + if (ibusimcontext->use_button_press_event && !_use_sync_mode) _connect_button_press_event (ibusimcontext, FALSE); #endif g_object_unref (ibusimcontext->client_window); @@ -1393,7 +1395,7 @@ ibus_im_context_set_client_window (GtkIMContext *context, if (client != NULL) { ibusimcontext->client_window = g_object_ref (client); #if !GTK_CHECK_VERSION (3, 98, 4) - if (!ibusimcontext->use_button_press_event) + if (!ibusimcontext->use_button_press_event && !_use_sync_mode) _connect_button_press_event (ibusimcontext, TRUE); #endif } @@ -1994,7 +1996,8 @@ _ibus_context_update_preedit_text_cb (IBusInputContext *ibuscontext, #if !GTK_CHECK_VERSION (3, 98, 4) if (!ibusimcontext->use_button_press_event && - mode == IBUS_ENGINE_PREEDIT_COMMIT) { + mode == IBUS_ENGINE_PREEDIT_COMMIT && + !_use_sync_mode) { if (ibusimcontext->client_window) { _connect_button_press_event (ibusimcontext, TRUE); } -- 2.28.0 From 4957d1468db4fc5ed30c3ae1f2afac9e51b329d6 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 6 Sep 2021 20:25:52 +0900 Subject: [PATCH] client/gtk2/ibusimcontext: Calculate keycode from keysym in GTK3 forward-key-event IBus GTK3 mode also calculates keycode from keysym if keycode == 0 with forward-key-event signal to follow GTK4. --- client/gtk2/ibusimcontext.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index e12be45d..b1424e87 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -1939,13 +1939,16 @@ _ibus_context_forward_key_event_cb (IBusInputContext *ibuscontext, int group = 0; g_return_if_fail (GTK_IS_IM_CONTEXT (ibusimcontext)); if (keycode == 0 && ibusimcontext->client_window) { - GdkDisplay *display = gtk_widget_get_display (ibusimcontext->client_window); + GdkDisplay *display = + gtk_widget_get_display (ibusimcontext->client_window); GdkKeymapKey *keys = NULL; gint n_keys = 0; - if (!gdk_display_map_keyval (display, keyval, &keys, &n_keys)) + if (gdk_display_map_keyval (display, keyval, &keys, &n_keys)) { + keycode = keys->keycode; + group = keys->group; + } else { g_warning ("Failed to parse keycode from keyval %x", keyval); - keycode = keys->keycode; - group = keys->group; + } } gtk_im_context_filter_key ( GTK_IM_CONTEXT (ibusimcontext), @@ -1957,6 +1960,17 @@ _ibus_context_forward_key_event_cb (IBusInputContext *ibuscontext, (GdkModifierType)state, group); #else + if (keycode == 0 && ibusimcontext->client_window) { + GdkDisplay *display = + gdk_window_get_display (ibusimcontext->client_window); + GdkKeymap *keymap = gdk_keymap_get_for_display (display); + GdkKeymapKey *keys = NULL; + gint n_keys = 0; + if (gdk_keymap_get_entries_for_keyval (keymap, keyval, &keys, &n_keys)) + keycode = keys->keycode; + else + g_warning ("Failed to parse keycode from keyval %x", keyval); + } GdkEventKey *event = _create_gdk_event (ibusimcontext, keyval, keycode, state); gdk_event_put ((GdkEvent *)event); gdk_event_free ((GdkEvent *)event); -- 2.28.0 From 943d37444d9cc0881cb5fff87bdd4b9efd5abdb4 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 9 Aug 2021 12:49:15 +0900 Subject: [PATCH] client/gtk2/ibusimcontext: Fix a key event loop with forwarding keys. _ibus_context_forward_key_event_cb() caused a key event loop in _key_snooper_cb() with key release events. --- client/gtk2/ibusimcontext.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index da9a402f..e66125df 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -366,6 +366,10 @@ ibus_im_context_commit_event (IBusIMContext *ibusimcontext, g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text); g_object_unref (text); _request_surrounding_text (ibusimcontext); +#if !GTK_CHECK_VERSION (3, 98, 4) + /* Avoid a loop with _ibus_context_forward_key_event_cb() */ + event->state |= IBUS_HANDLED_MASK; +#endif return TRUE; } return FALSE; @@ -643,12 +647,15 @@ _key_snooper_cb (GtkWidget *widget, } while (0); - if (ibusimcontext != NULL) { + if (ibusimcontext != NULL && event->type == GDK_KEY_PRESS) { /* "retrieve-surrounding" signal sometimes calls unref by * gtk_im_multicontext_get_slave() because priv->context_id is not * the latest than global_context_id in GtkIMMulticontext. * Since _focus_im_context is gotten by the focus_in event, * it would be good to call ref here. + * + * Most release key events would be redundant from + * _ibus_context_forward_key_event_cb (). */ g_object_ref (ibusimcontext); _request_surrounding_text (ibusimcontext); @@ -657,7 +664,7 @@ _key_snooper_cb (GtkWidget *widget, retval = _process_key_event (ibuscontext, event, ibusimcontext); - if (ibusimcontext != NULL) { + if (ibusimcontext != NULL && event->type == GDK_KEY_PRESS) { /* unref ibusimcontext could call ibus_im_context_finalize here * because "retrieve-surrounding" signal could call unref. */ -- 2.28.0 From 179ebddf4dbde1cef1cea2df4e659cf4940d1a30 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Fri, 27 Aug 2021 20:05:02 +0900 Subject: [PATCH] src/tests: Add --screendump option in ibus-desktop-testing-runner The screendump is useful in CI to if check gnome-shell-extension-no-overview works. Also add ibus-desktop-testing-autostart to get the debug info in CI. You can copy ibus-desktop-testing.desktop to $HOME/.config/autostart if CI fails. --- src/tests/Makefile.am | 11 +++++ src/tests/ibus-desktop-testing-autostart | 55 +++++++++++++++++++++++ src/tests/ibus-desktop-testing-runner.in | 20 +++++++-- src/tests/ibus-desktop-testing.desktop.in | 11 +++++ 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100755 src/tests/ibus-desktop-testing-autostart create mode 100644 src/tests/ibus-desktop-testing.desktop.in diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 13c06eb4..7d00f236 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -96,6 +96,7 @@ test_sourcesdir = $(datadir)/installed-tests/ibus CLEANFILES += \ $(test_metas) \ ibus-desktop-testing-runner \ + org.freedesktop.IBus.Desktop.Testing.desktop \ $(NULL) test_execs_PROGRAMS = $(TESTS) @@ -106,6 +107,14 @@ CLEANFILES += \ $(NULL) endif test_execsdir = $(libexecdir)/installed-tests/ibus +libexec_SCRIPTS = ibus-desktop-testing-autostart + +test_frame_DATA = org.freedesktop.IBus.Desktop.Testing.desktop +test_framedir = $(pkgdatadir)/tests +org.freedesktop.IBus.Desktop.Testing.desktop: ibus-desktop-testing.desktop.in + $(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|g" \ + $< > $@.tmp && \ + mv $@.tmp $@ endif $(test_metas): $(test_metas_in) $(test_programs) @@ -133,6 +142,8 @@ EXTRA_DIST = \ ibus-compose.emoji \ ibus-compose.env \ ibus-compose-locales.in \ + ibus-desktop-testing.desktop.in \ + ibus-desktop-testing-autostart \ ibus-desktop-testing-runner.in \ $(NULL) diff --git a/src/tests/ibus-desktop-testing-autostart b/src/tests/ibus-desktop-testing-autostart new file mode 100755 index 00000000..da22b64e --- /dev/null +++ b/src/tests/ibus-desktop-testing-autostart @@ -0,0 +1,55 @@ +#!/bin/sh +# -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- +# vim:set noet ts=4: +# +# ibus - The Input Bus +# +# Copyright (c) 2021 Takao Fujiwara +# Copyright (c) 2021 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_LOG= +COMMANDS=' +id +echo $DISPLAY +pwd +pstree -asp $$ +gsettings list-recursively org.gnome.shell +rpm -q gnome-shell-extension-no-overview gnome-shell gnome-session +' + +if [ $# -gt 0 ] ; then + TEST_LOG=$1 +fi + +run_test() +{ +while read cmd ; do + if [ x"$cmd" = x ] ; then + continue + fi + echo "# $cmd" + eval "$cmd" +done << EOF_COMMANDS +`echo "$COMMANDS"` +EOF_COMMANDS +} + +if [ x"$TEST_LOG" = x ] ; then + run_test +else + run_test 2>>$TEST_LOG 1>>$TEST_LOG +fi diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in index c1016703..48528326 100755 --- a/src/tests/ibus-desktop-testing-runner.in +++ b/src/tests/ibus-desktop-testing-runner.in @@ -36,13 +36,14 @@ PROGNAME=`basename $0` -VERSION=0.2 +VERSION=0.3 DISPLAY=:99.0 BUILDDIR="." SRCDIR="." TEST_LOG="test-suite.log" TEST_LOG_STDOUT=0 RESULT_LOG="" +SCREEN_LOG="" HAVE_GRAPHICS=1 DESKTOP_COMMAND="dbus-launch --exit-with-session gnome-session" PID_XORG=0 @@ -90,14 +91,15 @@ usage() "-T, --timeout=TIMEOUT Set timeout (default TIMEOUT is 300 sec).\n" \ "-o, --output=OUTPUT_FILE OUtput the log to OUTPUT_FILE\n" \ "-O, --result=RESULT_FILE OUtput the result to RESULT_FILE\n" \ +"-S, --screendump=DUMP_FILE OUtput the screen to DUMP_FILE ('STDOUT' can be stdout)\n" \ "" } parse_args() { # This is GNU getopt. "sudo port getopt" in BSD? - ARGS=`getopt -o hvb:s:cd:t:r:T:o:O: --long \ - help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,timeout:,output:,result:\ + ARGS=`getopt -o hvb:s:cd:t:r:T:o:O:S: --long \ + help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,timeout:,output:,result:,screendump:\ -- "$@"`; eval set -- "$ARGS" while [ 1 ] ; do @@ -113,6 +115,7 @@ parse_args() -T | --timeout ) TIMEOUT="$2"; shift 2;; -o | --output ) TEST_LOG="$2"; shift 2;; -O | --result ) RESULT_LOG="$2"; shift 2;; + -S | --screendump ) SCREEN_LOG="$2"; shift 2;; -- ) shift; break;; * ) usage; exit 1;; esac @@ -259,6 +262,7 @@ run_desktop() { echo "$DESKTOP_COMMAND" | grep gnome-session > /dev/null HAS_GNOME=$? + export DISPLAY=$DISPLAY if test $HAVE_GRAPHICS -eq 1 ; then /usr/libexec/Xorg.wrap -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . $DISPLAY & else @@ -266,7 +270,6 @@ run_desktop() fi PID_XORG=$! sleep 1 - export DISPLAY=$DISPLAY # init_gnome need to be called with $DISPLAY before gnome-session is called if [ $HAS_GNOME -eq 0 ] ; then init_gnome @@ -454,6 +457,15 @@ main() init_desktop run_dbus_daemon 2>>$TEST_LOG 1>>$TEST_LOG run_desktop 2>>$TEST_LOG 1>>$TEST_LOG + if [ x"$SCREEN_LOG" != x ] ; then + SCREEN_PNG="`date '+%Y%m%d%H%M%S'`.png" + gnome-screenshot --file=$SCREEN_PNG + if [ x"$SCREEN_LOG" = xSTDOUT ] ; then + base64 $SCREEN_PNG + else + base64 $SCREEN_PNG > $SCREEN_LOG + fi + fi run_test_suite finit } diff --git a/src/tests/ibus-desktop-testing.desktop.in b/src/tests/ibus-desktop-testing.desktop.in new file mode 100644 index 00000000..fa0c9b40 --- /dev/null +++ b/src/tests/ibus-desktop-testing.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=IBus Desktop Testing Runner +GenericName=Input Method Desktop Testing Runner +Comment=Test plugin for IBus Desktop Testing +Exec=@ibexecdir@/ibus-desktop-testing-autostart /var/tmp/ibus-ci-autostart.log +Terminal=false +Type=Application +Encoding=UTF-8 +Icon=ibus +Categories=System +Keywords=im; -- 2.28.0 From acc5570511698c7b5cc037eb81be2c4be52a824f Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Fri, 29 Oct 2021 12:56:49 +0900 Subject: [PATCH] ui/gtk3: Erase Emojier preedit/lookup popup between applications It would be better to erase Emojier popup window when users change the input focus between applications. But it hasn't been implemented because the focus-out/in events also happen when the Emojier popup window is launching or rebuilding to the category list in GNOME Wayland. The focus-out/in events do not happen in Xorg desktops with the rebuilding GUI because GTK popup window causes focus-in/out evnets in Wayland. Now I'm convinced with several issues and added a little complicated logic to erase Emojier popup window with the focus changes between input contexts to handle focus-in/out events in Wayland. BUG=rhbz#1942970 --- ui/gtk3/emojier.vala | 69 ++++++++++++++++++++++++++++++++++++--- ui/gtk3/emojierapp.vala | 12 +++++-- ui/gtk3/panelbinding.vala | 21 ++++++++++-- 3 files changed, 94 insertions(+), 8 deletions(-) diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala index 9e6e9263..69fb8abe 100644 --- a/ui/gtk3/emojier.vala +++ b/ui/gtk3/emojier.vala @@ -2,7 +2,7 @@ * * ibus - The Input Bus * - * Copyright (c) 2017-2019 Takao Fujiwara + * Copyright (c) 2017-2021 Takao Fujiwara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -227,6 +227,8 @@ public class IBusEmojier : Gtk.ApplicationWindow { BACKWARD, } + public bool is_wayland { get; set; } + public const uint BUTTON_CLOSE_BUTTON = 1000; private const uint EMOJI_GRID_PAGE = 10; @@ -317,15 +319,18 @@ public class IBusEmojier : Gtk.ApplicationWindow { private Gdk.Rectangle m_cursor_location; private bool m_is_up_side_down = false; private uint m_redraw_window_id; + private bool m_rebuilding_gui = false; + private uint m_rebuilding_gui_timeout_id; public signal void candidate_clicked(uint index, uint button, uint state); public signal void commit_text(string text); public signal void cancel(); - public IBusEmojier() { + public IBusEmojier(bool is_wayland) { GLib.Object( type : Gtk.WindowType.POPUP ); + this.is_wayland = is_wayland; // GLib.ActionEntry accepts const variables only. var action = new GLib.SimpleAction.stateful( @@ -1002,6 +1007,7 @@ public class IBusEmojier : Gtk.ApplicationWindow { button.button_press_event.connect((w, e) => { m_category_active_index = -1; m_show_unicode = false; + start_rebuild_gui(false); hide_candidate_panel(); show_all(); return true; @@ -1458,6 +1464,7 @@ public class IBusEmojier : Gtk.ApplicationWindow { show_emoji_for_category(m_backward); show_candidate_panel(); } else { + start_rebuild_gui(false); hide_candidate_panel(); show_all(); } @@ -1778,6 +1785,34 @@ public class IBusEmojier : Gtk.ApplicationWindow { } + private void start_rebuild_gui(bool initial_launching) { + if (!this.is_wayland) + return; + if (!initial_launching && !base.get_visible()) + return; + if (initial_launching && base.get_visible()) + return; + if (m_rebuilding_gui_timeout_id != 0) { + GLib.Source.remove(m_rebuilding_gui_timeout_id); + m_rebuilding_gui_timeout_id = 0; + } + + m_rebuilding_gui = true; + m_rebuilding_gui_timeout_id = + GLib.Timeout.add_seconds(10, () => { + if (!m_rebuilding_gui) { + m_rebuilding_gui_timeout_id = 0; + return false; + } + warning("Rebuilding GUI is time out."); + m_rebuilding_gui = false; + m_rebuilding_gui_timeout_id = 0; + return false; + }, + GLib.Priority.DEFAULT_IDLE); + } + + public bool has_variants(uint index, bool need_commit_signal) { if (index >= m_lookup_table.get_number_of_candidates()) @@ -1880,12 +1915,17 @@ public class IBusEmojier : Gtk.ApplicationWindow { m_show_unicode = false; m_category_active_index = -1; } + start_rebuild_gui(false); hide_candidate_panel(); return true; } else if (m_backward_index >= 0 && m_backward != null) { + // Escape on Emoji variants window does not call focus-out events + // because hide() is not called here so start_rebuild_gui() + // is not called. show_emoji_for_category(m_backward); return true; } else if (m_candidate_panel_is_visible && m_backward != null) { + start_rebuild_gui(false); hide_candidate_panel(); return true; } @@ -2218,7 +2258,7 @@ public class IBusEmojier : Gtk.ApplicationWindow { /* Some window managers, e.g. MATE, GNOME, Plasma desktops, * does not give the keyboard focus when Emojier is lauched - * twice with Ctrl-Shift-e via XIEvent, if present_with_time() + * twice with Ctrl-period via XIEvent, if present_with_time() * is not applied. * But XFCE4 desktop does not effect this bug. * Seems this is caused by the window manager's focus stealing @@ -2265,8 +2305,10 @@ public class IBusEmojier : Gtk.ApplicationWindow { #endif - /* override virtual functions */ + // override virtual functions public override void show_all() { + // Ctrl-period, space keys causes focus-out/in events in GNOME Wayland. + start_rebuild_gui(true); base.show_all(); if (m_candidate_panel_mode) show_candidate_panel(); @@ -2416,6 +2458,17 @@ public class IBusEmojier : Gtk.ApplicationWindow { } + public override bool focus_in_event(Gdk.EventFocus event) { + m_rebuilding_gui = false; + return base.focus_in_event(event); + } + + + public override bool focus_out_event(Gdk.EventFocus event) { + return base.focus_out_event(event); + } + + public bool is_running() { return m_is_running; } @@ -2511,6 +2564,14 @@ public class IBusEmojier : Gtk.ApplicationWindow { } + public bool is_rebuilding_gui() { + /* The candidate window and preedit text should not be closed + * when the GUI is rebuilding. + */ + return m_rebuilding_gui; + } + + public static bool has_loaded_emoji_dict() { if (m_emoji_to_data_dict == null) return false; diff --git a/ui/gtk3/emojierapp.vala b/ui/gtk3/emojierapp.vala index 783c611c..812356f0 100644 --- a/ui/gtk3/emojierapp.vala +++ b/ui/gtk3/emojierapp.vala @@ -3,7 +3,7 @@ * ibus - The Input Bus * * Copyright (c) 2017 Peng Wu - * Copyright (c) 2017-2019 Takao Fujiwara + * Copyright (c) 2017-2021 Takao Fujiwara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -208,7 +208,15 @@ public class EmojiApplication : Gtk.Application { IBusEmojier.load_unicode_dict(); if (m_emojier == null) { - m_emojier = new IBusEmojier(); + bool is_wayland = false; +#if USE_GDK_WAYLAND + Type instance_type = Gdk.Display.get_default().get_type(); + Type wayland_type = typeof(GdkWayland.Display); + is_wayland = instance_type.is_a(wayland_type); +#else + warning("Checking Wayland is disabled"); +#endif + m_emojier = new IBusEmojier(is_wayland); // For title handling in gnome-shell add_window(m_emojier); m_emojier.candidate_clicked.connect((i, b, s) => { diff --git a/ui/gtk3/panelbinding.vala b/ui/gtk3/panelbinding.vala index 861255b1..e63d93f2 100644 --- a/ui/gtk3/panelbinding.vala +++ b/ui/gtk3/panelbinding.vala @@ -3,7 +3,7 @@ * ibus - The Input Bus * * Copyright(c) 2018 Peng Huang - * Copyright(c) 2018-2020 Takao Fujwiara + * Copyright(c) 2018-2021 Takao Fujwiara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -799,6 +799,23 @@ class PanelBinding : IBus.PanelService { public override void focus_out(string input_context_path) { m_current_context_path = ""; + /* Close emoji typing when the focus out happens but it's not a + * rebuilding GUI. + * Emojier rebuilding GUI happens when Escape key is pressed on + * Emojier candidate list and the rebuilding also causes focus-out/in + * events in GNOME Wayland but not Xorg desktops. + * The rebuilding GUI can be checked with m_emojier.is_rebuilding_gui() + * in Wayland. + * m_emojier.is_rebuilding_gui() always returns false in Xorg desktops + * since focus-out/in events does not happen. + */ + if (m_emojier != null && !m_emojier.is_rebuilding_gui()) { + m_preedit.reset(); + m_emojier.set_annotation(""); + if (m_wayland_lookup_table_is_visible) + hide_wayland_lookup_table(); + key_press_escape(); + } } @@ -822,7 +839,7 @@ class PanelBinding : IBus.PanelService { m_loaded_unicode = true; } if (m_emojier == null) { - m_emojier = new IBusEmojier(); + m_emojier = new IBusEmojier(m_is_wayland); // For title handling in gnome-shell m_application.add_window(m_emojier); m_emojier.candidate_clicked.connect((i, b, s) => { -- 2.28.0