summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-05-24 11:05:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-05-24 13:41:46 +0200
commit97b2ad3681ca13d936f7ba04c8da5025b53464c3 (patch)
tree6e286a7cb40a40d4b31a2450e4b973d80ff04acc /vcl
parent8719c42ebab0b135b50d559830bfe2c2e0e8debb (diff)
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@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkdata.hxx9
-rw-r--r--vcl/unx/gtk3/gtkframe.cxx8
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx13
3 files changed, 13 insertions, 17 deletions
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);
}