summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-14 14:47:21 +0200
committerCaolán McNamara <caolanm@redhat.com>2020-05-14 20:27:06 +0200
commit8c496d3992c91027513c1c4c4811b6cb4c0f88f7 (patch)
treede9c14ebb31eba7ad93fe0fc73ff50cc71783273 /vcl
parentf8e6e545a6cc205fe7450f00acaff9d72e2d617c (diff)
Keep order of GDK input events intact
As explained at <https://bugzilla.redhat.com/show_bug.cgi?id=1377293#c12> "[Wayland] When typing fast at high CPU load, LibreOffice breaks key (letter) order": "with a local LO master --with-lang=ALL ASan+UBSan build (i.e., which executes somewhat slowly): When typing 'file' in Writer right after it started up (but no longer after more typing), that gets garbled as 'fiel'." The reason for that (but probably not for the original issue reported in that rhbz#1377293) apparently was: Two GDK_KEY_PRESS events (A and B) were in the GTK event queue. GtkInstance::AnyInput consumed only A, because it broke from the first while loop as soon as it saw the first event of appropriate type. In the second while loop it put A back on the end of the GTK event loop, so that it now followed B. GtkSalFrame::signalKey (vcl/unx/gtk3/gtk3gtkframe.cxx) thus received the events in the wrong order. Dropping the "break" also reveals that GtkInstance::AnyInput should obviously use a queue (i.e., deque) rather than a stack to hold the events it consumed and needs to re-enqueue. This appears to be a regression introduced with 658954e8b50fc264428402dc5a95b0d6f690d191 "Resolves: fdo#48011 writer idle-callbacks are halting when events pending". Change-Id: I87d601df118a20ea3dd59e9cebbcf5176db04be8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94202 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Jenkins (cherry picked from commit a9a19777d53beb762fabad3a67ddc68ad75bca6c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94005
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 820828c3e796..93b2a94b4c07 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -7,6 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <sal/config.h>
+
+#include <deque>
#include <stack>
#include <string.h>
#include <osl/process.h>
@@ -397,25 +400,24 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
return true;
bool bRet = false;
- std::stack<GdkEvent*> aEvents;
+ std::deque<GdkEvent*> aEvents;
GdkEvent *pEvent = nullptr;
while ((pEvent = gdk_event_get()))
{
- aEvents.push(pEvent);
+ aEvents.push_back(pEvent);
VclInputFlags nEventType = categorizeEvent(pEvent);
if ( (nEventType & nType) || ( nEventType == VclInputFlags::NONE && (nType & VclInputFlags::OTHER) ) )
{
bRet = true;
- break;
}
}
while (!aEvents.empty())
{
- pEvent = aEvents.top();
+ pEvent = aEvents.front();
gdk_event_put(pEvent);
gdk_event_free(pEvent);
- aEvents.pop();
+ aEvents.pop_front();
}
return bRet;
}