From ba75e27d37c117171984f298e23e904f244268be Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mon, 23 Mar 2020 12:43:23 -0700 Subject: [PATCH] Backport fix for preedit cursor position bug (#1812449) --- ...t-preedit-string-cursor-offset-in-by.patch | 42 +++++++++++++++++++ mutter.spec | 10 ++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 0001-wayland-Represent-preedit-string-cursor-offset-in-by.patch diff --git a/0001-wayland-Represent-preedit-string-cursor-offset-in-by.patch b/0001-wayland-Represent-preedit-string-cursor-offset-in-by.patch new file mode 100644 index 0000000..7177538 --- /dev/null +++ b/0001-wayland-Represent-preedit-string-cursor-offset-in-by.patch @@ -0,0 +1,42 @@ +From db9b60cc6357539d0deefd9ded236b1dd302d4a2 Mon Sep 17 00:00:00 2001 +From: Carlos Garnacho +Date: Tue, 17 Mar 2020 16:11:57 +0100 +Subject: [PATCH] wayland: Represent preedit string cursor offset in bytes + +Both IBus and ClutterInputFocus work in character offsets for the cursor +position in the preedit string. However the zwp_text_input protocol does +define the preedit string cursor offset to be in bytes. + +Fixes client bugs in representing the caret within the preedit string, +as we were clearly giving the wrong offset. + +Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2517 + +https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1132 +--- + src/wayland/meta-wayland-text-input.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c +index ee9b895cb..deff44c1b 100644 +--- a/src/wayland/meta-wayland-text-input.c ++++ b/src/wayland/meta-wayland-text-input.c +@@ -207,12 +207,14 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus, + { + MetaWaylandTextInput *text_input; + struct wl_resource *resource; ++ gsize pos; + + text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; ++ pos = g_utf8_offset_to_pointer (text, cursor) - text; + + wl_resource_for_each (resource, &text_input->focus_resource_list) + { +- zwp_text_input_v3_send_preedit_string (resource, text, cursor, cursor); ++ zwp_text_input_v3_send_preedit_string (resource, text, pos, pos); + } + + meta_wayland_text_input_focus_defer_done (focus); +-- +2.25.1 + diff --git a/mutter.spec b/mutter.spec index 6222810..447f400 100644 --- a/mutter.spec +++ b/mutter.spec @@ -8,7 +8,7 @@ Name: mutter Version: 3.36.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Window and compositing manager based on Clutter License: GPLv2+ @@ -18,6 +18,11 @@ Source0: http://download.gnome.org/sources/%{name}/3.36/%{name}-%{version} # Work-around for OpenJDK's compliance test Patch0: 0001-window-actor-Special-case-shaped-Java-windows.patch +# Fix preedit string cursor position bug +# https://gitlab.gnome.org/GNOME/gtk/issues/2517 +# https://bugzilla.redhat.com/show_bug.cgi?id=1812449 +# https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1132 +Patch1: 0001-wayland-Represent-preedit-string-cursor-offset-in-by.patch BuildRequires: chrpath BuildRequires: pango-devel @@ -163,6 +168,9 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop %{_datadir}/mutter-%{mutter_api_version}/tests %changelog +* Mon Mar 23 2020 Adam Williamson - 3.36.0-2 +- Backport fix for preedit cursor position bug (#1812449) + * Sat Mar 07 2020 Florian Müllner - 3.36.0-1 - Update to 3.36.0