From 42dd11c0a2c9e71e8163363afbfd14f448c65ef5 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 16 Jul 2019 22:59:49 +0100 Subject: input: ensure that removeTextContext happens in the right order. Unfortunately the backspace key-events we emit trigger uno accelerator handling, which happens another PostMessage further out, so cheat by doing it synchronously, and relying on the PostMessage inside to get the ordering right. Change-Id: Ibee80af7674fd5107cb1c9ba323071ac024c45ae Reviewed-on: https://gerrit.libreoffice.org/79883 Tested-by: Jenkins Reviewed-by: Michael Meeks --- desktop/source/lib/init.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 6a43d56c0296..fe11dbaeccee 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3072,16 +3072,33 @@ static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWi return; } + // Annoyingly - backspace and delete are handled in the apps via an accelerator + // which are PostMessage'd by SfxViewShell::ExecKey_Impl so to stay in the same + // order we do this synchronously here, unless we're in a dialog. if (nCharBefore > 0) { // backspace - SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 8, 1283, nCharBefore - 1); + if (nLOKWindowId == 0) + { + KeyEvent aEvt(8, 1283); + for (int i = 0; i < nCharBefore; ++i) + pWindow->KeyInput(aEvt); + } + else + SfxLokHelper::postKeyEventAsync(pWindow, LOK_KEYEVENT_KEYINPUT, 8, 1283, nCharBefore - 1); } if (nCharAfter > 0) { // delete (forward) - SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 46, 1286, nCharAfter - 1); + if (nLOKWindowId == 0) + { + KeyEvent aEvt(46, 1286); + for (int i = 0; i < nCharAfter; ++i) + pWindow->KeyInput(aEvt); + } + else + SfxLokHelper::postKeyEventAsync(pWindow, LOK_KEYEVENT_KEYINPUT, 46, 1286, nCharAfter - 1); } } -- cgit