From 3f2bea55a57cad2729e7f375a3f0aca12ec471c76eb81b79189dab520ebe5a68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Lie?= <bjorn.lie@gmail.com>
Date: Tue, 2 Nov 2021 11:43:59 +0000
Subject: [PATCH] Accepting request 927837 from home:sp1rit:testing

Added clutter-only_reset_preedit_text_if_set.patch:
this fixes "scrollback" issue I've talked about in https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/WYSUDJFTZIEEJS3QBBBUNLD3XBXULABU/
however it seems like upstream will only include it as of GNOME 42, even tho this seems like a pretty detrimental bug that should be addressed sooner.

Used proper guide line for patch @dimstar requsted

OBS-URL: https://build.opensuse.org/request/show/927837
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/mutter?expand=0&rev=391
---
 clutter-only_reset_preedit_text_if_set.patch | 45 ++++++++++++++++++++
 mutter.changes                               |  7 +++
 mutter.spec                                  |  4 +-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 clutter-only_reset_preedit_text_if_set.patch

diff --git a/clutter-only_reset_preedit_text_if_set.patch b/clutter-only_reset_preedit_text_if_set.patch
new file mode 100644
index 0000000..6828700
--- /dev/null
+++ b/clutter-only_reset_preedit_text_if_set.patch
@@ -0,0 +1,45 @@
+From 3b6f9111c7da3fee82d3ffd19c444155f84d86ea Mon Sep 17 00:00:00 2001
+From: Carlos Garnacho <carlosg@gnome.org>
+Date: Tue, 19 Oct 2021 16:53:13 +0200
+Subject: [PATCH] clutter: Only reset preedit text if set
+
+On ClutterInputFocus::reset, avoid to unset the preedit text if
+none was set earlier. This seems to trick GTK clients into focusing
+the cursor position again, even when we are moving away from it.
+
+Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4647
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2059>
+---
+ clutter/clutter/clutter-input-focus.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/clutter/clutter/clutter-input-focus.c b/clutter/clutter/clutter-input-focus.c
+index c22e3a32c0..117bab72ce 100644
+--- a/clutter/clutter/clutter-input-focus.c
++++ b/clutter/clutter/clutter-input-focus.c
+@@ -103,14 +103,16 @@ clutter_input_focus_reset (ClutterInputFocus *focus)
+ 
+   priv = clutter_input_focus_get_instance_private (focus);
+ 
+-  if (priv->preedit &&
+-      priv->mode == CLUTTER_PREEDIT_RESET_COMMIT)
+-    clutter_input_focus_commit (focus, priv->preedit);
++  if (priv->preedit)
++    {
++      if (priv->mode == CLUTTER_PREEDIT_RESET_COMMIT)
++        clutter_input_focus_commit (focus, priv->preedit);
+ 
+-  clutter_input_focus_set_preedit_text (focus, NULL, 0);
+-  g_clear_pointer (&priv->preedit, g_free);
+-  priv->mode = CLUTTER_PREEDIT_RESET_CLEAR;
++      clutter_input_focus_set_preedit_text (focus, NULL, 0);
++      g_clear_pointer (&priv->preedit, g_free);
++    }
+ 
++  priv->mode = CLUTTER_PREEDIT_RESET_CLEAR;
+   clutter_input_method_reset (priv->im);
+ }
+ 
+-- 
+GitLab
+
diff --git a/mutter.changes b/mutter.changes
index a6113b9..0bf83e2 100644
--- a/mutter.changes
+++ b/mutter.changes
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Thu Oct 21 12:41:20 UTC 2021 - Florian "spirit" <packaging@sp1rit.anonaddy.me>
+
+- Added clutter-only_reset_preedit_text_if_set.patch
+  + fixes "scrollback" issue of GtkTextView
+    (see lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/WYSUDJFTZIEEJS3QBBBUNLD3XBXULABU/)
+
 -------------------------------------------------------------------
 Wed Oct 20 03:13:48 UTC 2021 - Yifan Jiang <yfjiang@suse.com>
 
diff --git a/mutter.spec b/mutter.spec
index e72985e..710afb6 100644
--- a/mutter.spec
+++ b/mutter.spec
@@ -30,7 +30,8 @@ License:        GPL-2.0-or-later
 Group:          System/GUI/GNOME
 URL:            https://www.gnome.org
 Source:         https://download.gnome.org/sources/mutter/41/%{name}-%{version}.tar.xz
-
+# PATCH-FIX-UPSTREAM clutter-only_reset_preedit_text_if_set.patch glgo#GNOME/mutter!2059 -- Upstream bugfix that will be part of GNOME 42: Only reset preedit text if set
+Patch1:         clutter-only_reset_preedit_text_if_set.patch
 # PATCH-FIX-OPENSUSE mutter-Lower-HIDPI_LIMIT-to-144.patch fate#326682, bsc#1125467 qkzhu@suse.com -- Lower HIDPI_LIMIT to 144
 Patch3:         mutter-Lower-HIDPI_LIMIT-to-144.patch
 # PATCH-FIX-UPSTREAM mutter-disable-cvt-s390x.patch bsc#1158128 fcrozat@suse.com -- Do not search for cvt on s390x, it doesn't exist there
@@ -138,6 +139,7 @@ applications that want to make use of the mutter library.
 
 %prep
 %setup -q
+%patch1 -p1
 %patch3 -p1
 %patch4 -p1