[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Sun Oct 25 21:03:29 UTC 2020
vcl/unx/gtk3/gtk3gtkframe.cxx | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
New commits:
commit ce5e41ab99af350ca8f4b9fef3017d53f3526f83
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Oct 25 15:14:56 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Oct 25 22:02:17 2020 +0100
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 at redhat.com>
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)
More information about the Libreoffice-commits
mailing list