[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 24 11:42:27 UTC 2021
vcl/inc/unx/gtk/gtkdata.hxx | 9 +++++++++
vcl/unx/gtk3/gtkframe.cxx | 8 ++------
vcl/unx/gtk3/gtkinst.cxx | 13 ++-----------
3 files changed, 13 insertions(+), 17 deletions(-)
New commits:
commit 97b2ad3681ca13d936f7ba04c8da5025b53464c3
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 24 11:05:08 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 24 13:41:46 2021 +0200
gtk[3|4] wrap gtk_im_context_set_client_[widget|window] variants
Change-Id: I939786e45929ca81dcda479d0fc897f449f890ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116046
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index cf1454b6f589..4bc0ff223507 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -145,6 +145,15 @@ inline cairo_surface_t * surface_create_similar_surface(GdkSurface *pSurface,
#endif
}
+inline void im_context_set_client_widget(GtkIMContext *pIMContext, GtkWidget *pWidget)
+{
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_im_context_set_client_widget(pIMContext, pWidget);
+#else
+ gtk_im_context_set_client_window(pIMContext, pWidget ? gtk_widget_get_window(pWidget) : nullptr);
+#endif
+}
+
#if GTK_CHECK_VERSION(4, 0, 0)
typedef double gtk_coord;
#else
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 40add0ea7f10..ba35080c9641 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -4590,11 +4590,9 @@ void GtkSalFrame::IMHandler::createIMContext()
G_CALLBACK (signalIMPreeditEnd), this );
GetGenericUnixSalData()->ErrorTrapPush();
+ im_context_set_client_widget(m_pIMContext, m_pFrame->getMouseEventWidget());
#if GTK_CHECK_VERSION(4, 0, 0)
- gtk_im_context_set_client_widget(m_pIMContext, m_pFrame->getMouseEventWidget());
gtk_event_controller_key_set_im_context(m_pFrame->m_pKeyController, m_pIMContext);
-#else
- gtk_im_context_set_client_window(m_pIMContext, widget_get_surface(m_pFrame->getMouseEventWidget()));
#endif
gtk_im_context_focus_in( m_pIMContext );
GetGenericUnixSalData()->ErrorTrapPop();
@@ -4609,11 +4607,9 @@ void GtkSalFrame::IMHandler::deleteIMContext()
// first give IC a chance to deinitialize
GetGenericUnixSalData()->ErrorTrapPush();
#if GTK_CHECK_VERSION(4, 0, 0)
- gtk_im_context_set_client_widget(m_pIMContext, nullptr);
gtk_event_controller_key_set_im_context(m_pFrame->m_pKeyController, nullptr);
-#else
- gtk_im_context_set_client_window(m_pIMContext, nullptr);
#endif
+ im_context_set_client_widget(m_pIMContext, nullptr);
GetGenericUnixSalData()->ErrorTrapPop();
// destroy old IC
g_object_unref( m_pIMContext );
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index bea68da88504..d21ac27e1d42 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -15516,12 +15516,7 @@ public:
GtkWidget* pWidget = m_pArea->getWidget();
if (!gtk_widget_get_realized(pWidget))
gtk_widget_realize(pWidget);
-#if GTK_CHECK_VERSION(4, 0, 0)
- gtk_im_context_set_client_widget(m_pIMContext, pWidget);
-#else
- GdkWindow* pWin = widget_get_surface(pWidget);
- gtk_im_context_set_client_window(m_pIMContext, pWin);
-#endif
+ im_context_set_client_widget(m_pIMContext, pWidget);
if (gtk_widget_has_focus(m_pArea->getWidget()))
gtk_im_context_focus_in(m_pIMContext);
}
@@ -15559,11 +15554,7 @@ public:
gtk_im_context_focus_out(m_pIMContext);
// first give IC a chance to deinitialize
-#if GTK_CHECK_VERSION(4, 0, 0)
- gtk_im_context_set_client_widget(m_pIMContext, nullptr);
-#else
- gtk_im_context_set_client_window(m_pIMContext, nullptr);
-#endif
+ im_context_set_client_widget(m_pIMContext, nullptr);
// destroy old IC
g_object_unref(m_pIMContext);
}
More information about the Libreoffice-commits
mailing list