[Libreoffice-commits] core.git: 2 commits - vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 28 10:36:02 UTC 2021
vcl/unx/gtk3/customcellrenderer.cxx | 27 +++++++++++++++++++++----
vcl/unx/gtk3/gtkinst.cxx | 38 +++++++++++++++++++++++++++++++++---
2 files changed, 58 insertions(+), 7 deletions(-)
New commits:
commit 15ee306cda425323cb2d58bd88f84686ebc8848c
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jun 28 09:17:46 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 28 12:35:39 2021 +0200
gtk4: implement focus in/out for IMHandler
Change-Id: Id8183b18622a26c0b61c3165b364ecc1d3e3e5bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117994
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 036fca44169c..50d15d75b943 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -16608,6 +16608,9 @@ class IMHandler
{
private:
GtkInstanceDrawingArea* m_pArea;
+#if GTK_CHECK_VERSION(4, 0, 0)
+ GtkEventController* m_pFocusController;
+#endif
GtkIMContext* m_pIMContext;
OUString m_sPreeditText;
gulong m_nFocusInSignalId;
@@ -16618,10 +16621,21 @@ public:
IMHandler(GtkInstanceDrawingArea* pArea)
: m_pArea(pArea)
, m_pIMContext(gtk_im_multicontext_new())
- , m_nFocusInSignalId(g_signal_connect(m_pArea->getWidget(), "focus-in-event", G_CALLBACK(signalFocusIn), this))
- , m_nFocusOutSignalId(g_signal_connect(m_pArea->getWidget(), "focus-out-event", G_CALLBACK(signalFocusOut), this))
, m_bExtTextInput(false)
{
+ GtkWidget* pWidget = m_pArea->getWidget();
+
+#if GTK_CHECK_VERSION(4, 0, 0)
+ m_pFocusController = gtk_event_controller_focus_new();
+ gtk_widget_add_controller(pWidget, m_pFocusController);
+
+ m_nFocusInSignalId = g_signal_connect(m_pFocusController, "enter", G_CALLBACK(signalFocusIn), this);
+ m_nFocusOutSignalId = g_signal_connect(m_pFocusController, "leave", G_CALLBACK(signalFocusOut), this);
+#else
+ m_nFocusInSignalId = g_signal_connect(pWidget, "focus-in-event", G_CALLBACK(signalFocusIn), this);
+ m_nFocusOutSignalId = g_signal_connect(pWidget, "focus-out-event", G_CALLBACK(signalFocusOut), this);
+#endif
+
g_signal_connect(m_pIMContext, "preedit-start", G_CALLBACK(signalIMPreeditStart), this);
g_signal_connect(m_pIMContext, "preedit-end", G_CALLBACK(signalIMPreeditEnd), this);
g_signal_connect(m_pIMContext, "commit", G_CALLBACK(signalIMCommit), this);
@@ -16629,7 +16643,6 @@ public:
g_signal_connect(m_pIMContext, "retrieve-surrounding", G_CALLBACK(signalIMRetrieveSurrounding), this);
g_signal_connect(m_pIMContext, "delete-surrounding", G_CALLBACK(signalIMDeleteSurrounding), this);
- GtkWidget* pWidget = m_pArea->getWidget();
if (!gtk_widget_get_realized(pWidget))
gtk_widget_realize(pWidget);
im_context_set_client_widget(m_pIMContext, pWidget);
@@ -16645,26 +16658,43 @@ public:
gtk_im_context_focus_out(m_pIMContext);
}
+#if GTK_CHECK_VERSION(4, 0, 0)
+ static void signalFocusIn(GtkEventControllerFocus*, gpointer im_handler)
+#else
static gboolean signalFocusIn(GtkWidget*, GdkEvent*, gpointer im_handler)
+#endif
{
IMHandler* pThis = static_cast<IMHandler*>(im_handler);
pThis->signalFocus(true);
+#if !GTK_CHECK_VERSION(4, 0, 0)
return false;
+#endif
}
+#if GTK_CHECK_VERSION(4, 0, 0)
+ static void signalFocusOut(GtkEventControllerFocus*, gpointer im_handler)
+#else
static gboolean signalFocusOut(GtkWidget*, GdkEvent*, gpointer im_handler)
+#endif
{
IMHandler* pThis = static_cast<IMHandler*>(im_handler);
pThis->signalFocus(false);
+#if !GTK_CHECK_VERSION(4, 0, 0)
return false;
+#endif
}
~IMHandler()
{
EndExtTextInput();
+#if GTK_CHECK_VERSION(4, 0, 0)
+ g_signal_handler_disconnect(m_pFocusController, m_nFocusOutSignalId);
+ g_signal_handler_disconnect(m_pFocusController, m_nFocusInSignalId);
+#else
g_signal_handler_disconnect(m_pArea->getWidget(), m_nFocusOutSignalId);
g_signal_handler_disconnect(m_pArea->getWidget(), m_nFocusInSignalId);
+#endif
if (gtk_widget_has_focus(m_pArea->getWidget()))
gtk_im_context_focus_out(m_pIMContext);
@@ -22144,6 +22174,8 @@ weld::Builder* GtkInstance::CreateBuilder(weld::Widget* pParent, const OUString&
rUIFile != "modules/scalc/ui/formatcellsdialog.ui" &&
rUIFile != "modules/scalc/ui/goalseekdlg.ui" &&
rUIFile != "modules/scalc/ui/groupdialog.ui" &&
+ rUIFile != "modules/scalc/ui/headerfootercontent.ui" &&
+ rUIFile != "modules/scalc/ui/headerfooterdialog.ui" &&
rUIFile != "modules/scalc/ui/inputstringdialog.ui" &&
rUIFile != "modules/scalc/ui/insertname.ui" &&
rUIFile != "modules/scalc/ui/insertcells.ui" &&
commit f8f0e4067b09d1d8b5aebc7b28db3b7565606b27
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jun 27 21:22:04 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 28 12:35:26 2021 +0200
gtk4: adapt to GtkCellRendererClass changes
Change-Id: Id5b52f9a3502cecfe693dadea6642dbed3a18aa2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117960
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/customcellrenderer.cxx b/vcl/unx/gtk3/customcellrenderer.cxx
index 69e2395df4de..7021f8be064c 100644
--- a/vcl/unx/gtk3/customcellrenderer.cxx
+++ b/vcl/unx/gtk3/customcellrenderer.cxx
@@ -79,11 +79,16 @@ static bool custom_cell_renderer_get_preferred_size(GtkCellRenderer* cell,
GtkOrientation orientation, gint* minimum_size,
gint* natural_size);
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+static void custom_cell_renderer_snapshot(GtkCellRenderer* cell, GtkSnapshot* snapshot,
+ GtkWidget* widget, const GdkRectangle* background_area,
+ const GdkRectangle* cell_area,
+ GtkCellRendererState flags);
+#endif
+
static void custom_cell_renderer_render(GtkCellRenderer* cell, cairo_t* cr, GtkWidget* widget,
const GdkRectangle* background_area,
const GdkRectangle* cell_area, GtkCellRendererState flags);
-#endif
static void custom_cell_renderer_finalize(GObject* object)
{
@@ -155,7 +160,9 @@ void custom_cell_renderer_class_init(CustomCellRendererClass* klass)
cell_class->get_preferred_height_for_width
= custom_cell_renderer_get_preferred_height_for_width;
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+ cell_class->snapshot = custom_cell_renderer_snapshot;
+#else
cell_class->render = custom_cell_renderer_render;
#endif
@@ -223,7 +230,6 @@ bool custom_cell_renderer_get_preferred_size(GtkCellRenderer* cell, GtkOrientati
return true;
}
-#if !GTK_CHECK_VERSION(4, 0, 0)
void custom_cell_renderer_render(GtkCellRenderer* cell, cairo_t* cr, GtkWidget* /*widget*/,
const GdkRectangle* /*background_area*/,
const GdkRectangle* cell_area, GtkCellRendererState flags)
@@ -271,6 +277,19 @@ void custom_cell_renderer_render(GtkCellRenderer* cell, cairo_t* cr, GtkWidget*
cairo_set_source_surface(cr, pSurface, cell_area->x, cell_area->y);
cairo_paint(cr);
}
+
+#if GTK_CHECK_VERSION(4, 0, 0)
+static void custom_cell_renderer_snapshot(GtkCellRenderer* cell, GtkSnapshot* snapshot,
+ GtkWidget* widget, const GdkRectangle* background_area,
+ const GdkRectangle* cell_area, GtkCellRendererState flags)
+{
+ graphene_rect_t rect = GRAPHENE_RECT_INIT(0.0f, 0.0f, static_cast<float>(cell_area->width),
+ static_cast<float>(cell_area->height));
+ cairo_t* cr = gtk_snapshot_append_cairo(GTK_SNAPSHOT(snapshot), &rect);
+ custom_cell_renderer_render(cell, cr, widget, background_area, cell_area, flags);
+ cairo_destroy(cr);
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list