summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-05-29 10:10:21 +0300
committerCaolán McNamara <caolanm@redhat.com>2015-06-30 11:50:01 +0000
commit6c76a0a84785b48c29687e6d31b8229a230563d8 (patch)
treedb7001c29f49972ae47db9e61c43fb6bec46bd48
parentc0a79b1dabc1e3c5fb9dd7ff41257a39015da598 (diff)
tdf#91641 adjust cursor when deleting preceding characters
IMDeleteSurrounding is used by input methods to take multiple keystrokes and convert them into a special character. Then the composing keystrokes are removed. Before this fix, the cursor placement was not adjusted, so the special character was inserted in the wrong position and if 3+ keystrokes were involved, the wrong characters were deleted. Change-Id: I35b97bc150dc68ffe65eebc59450e21e0033bd16 Reviewed-on: https://gerrit.libreoffice.org/15961 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 9f8e35d68ee5..7697eca31010 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -4655,7 +4655,7 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is())
{
- sal_uInt32 nPosition = xText->getCaretPosition();
+ sal_Int32 nPosition = xText->getCaretPosition();
// #i111768# range checking
sal_Int32 nDeletePos = nPosition + offset;
sal_Int32 nDeleteEnd = nDeletePos + nchars;
@@ -4667,6 +4667,14 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
nDeleteEnd = xText->getCharacterCount();
xText->deleteText(nDeletePos, nDeleteEnd);
+ //tdf91641 adjust cursor if deleted chars shift it forward (normal case)
+ if (nDeletePos < nPosition)
+ {
+ if (nDeleteEnd <= nPosition)
+ xText->setCaretPosition( nPosition-(nDeleteEnd-nDeletePos) );
+ else
+ xText->setCaretPosition( nDeletePos );
+ }
return true;
}