Related: tdf#118038 use an intermediate GdkPixbuf under gtk < 3.20.0
otherwise the GtkImage's width isn't right
Change-Id: Id5e44749fb9925037d5777512e3123de8840d346
Reviewed-on: https://gerrit.libreoffice.org/60484
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index f93b598..1d5ca9e 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3135,7 +3135,18 @@ public:
gtk_widget_show(GTK_WIDGET(m_pImage));
}
if (pDevice)
gtk_image_set_from_surface(m_pImage, get_underlying_cairo_surface(*pDevice));
{
cairo_surface_t* surface = get_underlying_cairo_surface(*pDevice);
if (gtk_check_version(3, 20, 0) == nullptr)
gtk_image_set_from_surface(m_pImage, get_underlying_cairo_surface(*pDevice));
else
{
Size aSize(pDevice->GetOutputSizePixel());
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, aSize.Width(), aSize.Height());
gtk_image_set_from_pixbuf(m_pImage, pixbuf);
g_object_unref(pixbuf);
}
}
else
gtk_image_set_from_surface(m_pImage, nullptr);
}