kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-Keep-order-of-GDK-input-events-intact.patch

a977ad
From 0c20ed4d58f7b55bcc12fa288b93d1c6d88a7dcc Mon Sep 17 00:00:00 2001
a977ad
From: Stephan Bergmann <sbergman@redhat.com>
a977ad
Date: Thu, 14 May 2020 14:47:21 +0200
a977ad
Subject: [PATCH] Keep order of GDK input events intact
a977ad
a977ad
As explained at <https://bugzilla.redhat.com/show_bug.cgi?id=1377293#c12>
a977ad
"[Wayland] When typing fast at high CPU load, LibreOffice breaks key (letter)
a977ad
order":  "with a local LO master --with-lang=ALL ASan+UBSan build (i.e., which
a977ad
executes somewhat slowly):  When typing 'file' in Writer right after it started
a977ad
up (but no longer after more typing), that gets garbled as 'fiel'."  The reason
a977ad
for that (but probably not for the original issue reported in that rhbz#1377293)
a977ad
apparently was:
a977ad
a977ad
Two GDK_KEY_PRESS events (A and B) were in the GTK event queue.
a977ad
GtkInstance::AnyInput consumed only A, because it broke from the first while
a977ad
loop as soon as it saw the first event of appropriate type.  In the second while
a977ad
loop it put A back on the end of the GTK event loop, so that it now followed B.
a977ad
GtkSalFrame::signalKey (vcl/unx/gtk3/gtk3gtkframe.cxx) thus received the events
a977ad
in the wrong order.
a977ad
a977ad
Dropping the "break" also reveals that GtkInstance::AnyInput should obviously
a977ad
use a queue (i.e., deque) rather than a stack to hold the events it consumed and
a977ad
needs to re-enqueue.
a977ad
a977ad
This appears to be a regression introduced with
a977ad
658954e8b50fc264428402dc5a95b0d6f690d191 "Resolves: fdo#48011 writer
a977ad
idle-callbacks are halting when events pending".
a977ad
a977ad
Change-Id: I87d601df118a20ea3dd59e9cebbcf5176db04be8
a977ad
---
a977ad
 vcl/unx/gtk/gtkinst.cxx | 9 ++++-----
a977ad
 1 file changed, 4 insertions(+), 5 deletions(-)
a977ad
a977ad
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
a977ad
index 02ed688f366b..744c66b0baf0 100644
a977ad
--- a/vcl/unx/gtk/gtkinst.cxx
a977ad
+++ b/vcl/unx/gtk/gtkinst.cxx
a977ad
@@ -427,25 +427,24 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
a977ad
         return true;
a977ad
 
a977ad
     bool bRet = false;
a977ad
-    std::stack<GdkEvent*> aEvents;
a977ad
+    std::deque<GdkEvent*> aEvents;
a977ad
     GdkEvent *pEvent = nullptr;
a977ad
     while ((pEvent = gdk_event_get()))
a977ad
     {
a977ad
-        aEvents.push(pEvent);
a977ad
+        aEvents.push_back(pEvent);
a977ad
         VclInputFlags nEventType = categorizeEvent(pEvent);
a977ad
         if ( (nEventType & nType) || ( nEventType == VclInputFlags::NONE && (nType & VclInputFlags::OTHER) ) )
a977ad
         {
a977ad
             bRet = true;
a977ad
-            break;
a977ad
         }
a977ad
     }
a977ad
 
a977ad
     while (!aEvents.empty())
a977ad
     {
a977ad
-        pEvent = aEvents.top();
a977ad
+        pEvent = aEvents.front();
a977ad
         gdk_event_put(pEvent);
a977ad
         gdk_event_free(pEvent);
a977ad
-        aEvents.pop();
a977ad
+        aEvents.pop_front();
a977ad
     }
a977ad
 #endif
a977ad
     return bRet;
a977ad
-- 
a977ad
2.25.4
a977ad