summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-10-25 15:14:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-10-25 22:02:17 +0100
commitce5e41ab99af350ca8f4b9fef3017d53f3526f83 (patch)
tree98c7cb352e0e0c4a103049c5b1f72e31197e3e29
parent41df2d06cc13a1c60a4ea9671535afb8bd55b344 (diff)
Related: tdf#137620 use existing SalEvent::SurroundingTextRequest
for signalIMRetrieveSurrounding Change-Id: Ic3280918283e2e1cf63a6d30767949d1c59cd1c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104780 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx32
1 files changed, 13 insertions, 19 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 7da09d72d375..1bccc46f2131 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -4376,28 +4376,22 @@ static uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText(vcl::
return xText;
}
-gboolean GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pContext, gpointer /*im_handler*/ )
+gboolean GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pContext, gpointer im_handler )
{
- vcl::Window *pFocusWin = Application::GetFocusWindow();
- if (!pFocusWin)
- return true;
+ GtkSalFrame::IMHandler* pThis = static_cast<GtkSalFrame::IMHandler*>(im_handler);
- uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
- if (xText.is())
- {
- sal_Int32 nPosition = xText->getCaretPosition();
- if (nPosition != -1)
- {
- OUString sAllText = xText->getText();
- OString sUTF = OUStringToOString(sAllText, RTL_TEXTENCODING_UTF8);
- OUString sCursorText(sAllText.copy(0, nPosition));
- gtk_im_context_set_surrounding(pContext, sUTF.getStr(), sUTF.getLength(),
- OUStringToOString(sCursorText, RTL_TEXTENCODING_UTF8).getLength());
- return true;
- }
- }
+ SalSurroundingTextRequestEvent aEvt;
+ aEvt.maText.clear();
+ aEvt.mnStart = aEvt.mnEnd = 0;
- return false;
+ SolarMutexGuard aGuard;
+ pThis->m_pFrame->CallCallback(SalEvent::SurroundingTextRequest, &aEvt);
+
+ OString sUTF = OUStringToOString(aEvt.maText, RTL_TEXTENCODING_UTF8);
+ OUString sCursorText(aEvt.maText.copy(0, aEvt.mnStart));
+ gtk_im_context_set_surrounding(pContext, sUTF.getStr(), sUTF.getLength(),
+ OUStringToOString(sCursorText, RTL_TEXTENCODING_UTF8).getLength());
+ return true;
}
Selection GtkSalFrame::CalcDeleteSurroundingSelection(const OUString& rSurroundingText, int nCursorIndex, int nOffset, int nChars)