summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-04-25 14:04:56 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-04-26 13:46:54 +0000
commit6264733282ff93d8bbb561f67b880424f31a1f7d (patch)
treee9cc0324c5a69cf4a422c7edd8412255118ab495 /vcl/unx
parent7a4a38895d4e419bf4db57b0668af60b4dc6b595 (diff)
Resolves: fdo#63802 return true if we have known empty context
i.e. false for "we can't provide context", and true for "we can provide context, even if there isn't any" Still looks to me that there's a bug in the si-phonetic-dynamic im (or something in the stack) that assumes that returning false once means it will always return false and give up for ever fix indent while I'm at it also let si-phonetic-dynamic survive libreoffice losing focus and regain it cycle and still use surrounding text. It should be safe to report that we can provide surrounding text but there isn't any during the time window when there is no focus window, because the focus in event was received but it hasn't arrived yet because that happens on a postuserevent. (cherry picked from commit 21fb092398fb21256b0e546e7f38c5e6de4654f2) Change-Id: I0481c42208953f2a0618aaed7b0d9e9f3e7bda07 Reviewed-on: https://gerrit.libreoffice.org/3608 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx38
1 files changed, 19 insertions, 19 deletions
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 03f8c59fcad1..eb87e7481496 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -4223,13 +4223,9 @@ uno::Reference<accessibility::XAccessibleEditableText>
return uno::Reference< accessibility::XAccessibleEditableText >();
}
-static uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText()
+static uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText(Window *pFocusWin)
{
uno::Reference<accessibility::XAccessibleEditableText> xText;
- Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
- if (!pFocusWin)
- return xText;
-
try
{
uno::Reference< accessibility::XAccessible > xAccessible( pFocusWin->GetAccessible( true ) );
@@ -4238,36 +4234,40 @@ static uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText()
}
catch(const uno::Exception& e)
{
- g_warning( "Exception in getting input method surrounding text" );
+ SAL_WARN( "vcl.gtk", "Exception in getting input method surrounding text: " << e.Message);
}
return xText;
}
gboolean GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pContext, gpointer /*im_handler*/ )
{
- uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText();
+ Window *pFocusWin = Application::GetFocusWindow();
+ if (!pFocusWin)
+ return true;
+ uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is())
{
sal_uInt32 nPosition = xText->getCaretPosition();
- rtl::OUString sAllText = xText->getText();
- if (sAllText.isEmpty())
- return sal_False;
- rtl::OString sUTF = rtl::OUStringToOString(sAllText, RTL_TEXTENCODING_UTF8);
- rtl::OUString sCursorText(sAllText.copy(0, nPosition));
- gtk_im_context_set_surrounding(pContext, sUTF.getStr(), sUTF.getLength(),
- rtl::OUStringToOString(sCursorText, RTL_TEXTENCODING_UTF8).getLength());
- return sal_True;
+ 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;
}
- return sal_False;
+ return false;
}
gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint offset, gint nchars,
gpointer /*im_handler*/ )
{
- uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText();
+ Window *pFocusWin = Application::GetFocusWindow();
+ if (!pFocusWin)
+ return true;
+ uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is())
{
sal_uInt32 nPosition = xText->getCaretPosition();
@@ -4282,10 +4282,10 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
nDeleteEnd = xText->getCharacterCount();
xText->deleteText(nDeletePos, nDeleteEnd);
- return sal_True;
+ return true;
}
- return sal_False;
+ return false;
}
Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )