From b304ff4b7de22132d397df88cd99cea64159e24f Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 28 Feb 2020 09:05:17 +0100 Subject: tdf#130071 tdf#127815 qt5: Use ExtTextInput only for multi-char key events Only call the SalEvent::ExtTextInput callback for key input events if their text is longer than one character, in which case treating them as SalEvent::KeyInput would produce incorrect results, given that only the first character is set as the SalKeyEvent's mnCharCode below (s.a. tdf#124118). S.a. commit 61c8324394c690ced18ce692ab6d29c8031ad1a8 ("#88063# fixed event handling for redflag", 2001-06-12) which made events with text longer than 1 unicode char to be handled by SalEvent::ExtTextInput for the gen VCL plugin even if not in preedit mode. Process other key events by calling SalEvent::KeyInput callback, which e.g. makes shortcuts involving non-Latin characters (tdf#130071) and auto-insertion of non-breaking spaces when typing French text (tdf#127815) work. The gtk3 and gen VCL plugins also use the length of the text as one criterion to make a disctinction of whether to call SalEvent::ExtTextInput or SalEvent::KeyInput, s. GtkSalFrame::IMHandler::signalIMCommit and X11SalFrame::HandleKeyEvent. Those also take into account whether in preedit mode, but for the qt5 case, input method events when using e.g. ibus are handled in Qt5Widget::inputMethodEvent and the Qt5Widget::handleKeyEvent code path is not used anyway. Change-Id: I2f8925ea26a4fb5419226265c579242889e2a506 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89663 Reviewed-by: Jan-Marek Glogowski Reviewed-by: Michael Weghorn Tested-by: Jenkins (cherry picked from commit 1c6ea413cb01c0b482f87e625ba208eec230618a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89670 Reviewed-by: Adolfo Jayme Barrientos --- vcl/qt5/Qt5Widget.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 8c3d15b14efa..12e9a54f7f4f 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -420,7 +420,7 @@ bool Qt5Widget::handleKeyEvent(Qt5Frame& rFrame, const QWidget& rWidget, QKeyEve const ButtonKeyState eState) { sal_uInt16 nCode = GetKeyCode(pEvent->key(), pEvent->modifiers()); - if (eState == ButtonKeyState::Pressed && nCode == 0 && !pEvent->text().isEmpty() + if (eState == ButtonKeyState::Pressed && nCode == 0 && pEvent->text().length() > 1 && rWidget.testAttribute(Qt::WA_InputMethodEnabled)) { commitText(rFrame, pEvent->text()); -- cgit v1.2.3