[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 10 11:58:43 UTC 2021
vcl/inc/unx/gtk/gtkframe.hxx | 17 +++++++++--
vcl/unx/gtk3/gtkframe.cxx | 65 +++++++++++++++++++++++++++++++++----------
2 files changed, 65 insertions(+), 17 deletions(-)
New commits:
commit b03af6e223b95f047f50018c3b1b1eac6dfe6091
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 10 11:44:43 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 10 13:58:04 2021 +0200
gtk4: implement drawing and resizing
now we can see something
Change-Id: I428354ce382bb4dbf163309b80316488436b027c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115319
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 254d9b2ec4dd..25fd37386e97 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -176,8 +176,10 @@ class GtkSalFrame final : public SalFrame
GtkGrid* m_pTopLevelGrid;
#if !GTK_CHECK_VERSION(4, 0, 0)
GtkEventBox* m_pEventBox;
-#endif
GtkFixed* m_pFixedContainer;
+#else
+ GtkDrawingArea* m_pFixedContainer;
+#endif
#if !GTK_CHECK_VERSION(4, 0, 0)
GdkWindow* m_pForeignParent;
GdkNativeWindow m_aForeignParentWindow;
@@ -241,9 +243,18 @@ class GtkSalFrame final : public SalFrame
// signals
static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer );
static void signalStyleUpdated(GtkWidget*, gpointer);
+#endif
+ void DrawingAreaResized(GtkWidget* pWidget, int nWidth, int nHeight);
+ void DrawingAreaDraw(cairo_t *cr);
+#if !GTK_CHECK_VERSION(4, 0, 0)
static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
- static void signalRealize(GtkWidget*, gpointer frame);
static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
+#else
+ static void signalDraw(GtkDrawingArea*, cairo_t *cr, int width, int height, gpointer);
+ static void sizeAllocated(GtkWidget*, int nWidth, int nHeight, gpointer frame);
+#endif
+#if !GTK_CHECK_VERSION(4, 0, 0)
+ static void signalRealize(GtkWidget*, gpointer frame);
static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
gboolean keyboard_mode, GtkTooltip *tooltip,
gpointer frame);
@@ -357,7 +368,7 @@ public:
static GtkSalDisplay* getDisplay();
static GdkDisplay* getGdkDisplay();
GtkWidget* getWindow() const { return m_pWindow; }
- GtkFixed* getFixedContainer() const { return m_pFixedContainer; }
+ GtkFixed* getFixedContainer() const { return GTK_FIXED(m_pFixedContainer); }
#if !GTK_CHECK_VERSION(4, 0, 0)
GtkEventBox* getEventBox() const { return m_pEventBox; }
#endif
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 52e7331ccc3b..c4f1dd3c58db 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -906,7 +906,11 @@ void GtkSalFrame::InitCommon()
// add the fixed container child,
// fixed is needed since we have to position plugin windows
+#if !GTK_CHECK_VERSION(4,0,0)
m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr ));
+#else
+ m_pFixedContainer = GTK_DRAWING_AREA(gtk_drawing_area_new());
+#endif
gtk_widget_set_can_focus(GTK_WIDGET(m_pFixedContainer), true);
gtk_widget_set_size_request(GTK_WIDGET(m_pFixedContainer), 1, 1);
#if !GTK_CHECK_VERSION(4,0,0)
@@ -950,10 +954,18 @@ void GtkSalFrame::InitCommon()
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "drag-data-delete", G_CALLBACK(signalDragDelete), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "drag-data-get", G_CALLBACK(signalDragDataGet), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "scroll-event", G_CALLBACK(signalScroll), this ));
+#endif
+#if !GTK_CHECK_VERSION(4,0,0)
g_signal_connect( G_OBJECT(m_pFixedContainer), "draw", G_CALLBACK(signalDraw), this );
- g_signal_connect( G_OBJECT(m_pFixedContainer), "realize", G_CALLBACK(signalRealize), this );
g_signal_connect( G_OBJECT(m_pFixedContainer), "size-allocate", G_CALLBACK(sizeAllocated), this );
+#else
+ gtk_drawing_area_set_draw_func(m_pFixedContainer, signalDraw, this, nullptr);
+ g_signal_connect( G_OBJECT(m_pFixedContainer), "resize", G_CALLBACK(sizeAllocated), this );
+#endif
+
+#if !GTK_CHECK_VERSION(4,0,0)
+ g_signal_connect( G_OBJECT(m_pFixedContainer), "realize", G_CALLBACK(signalRealize), this );
GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget);
g_signal_connect(pSwipe, "swipe", G_CALLBACK(gestureSwipe), this);
@@ -3216,34 +3228,59 @@ void GtkSalFrame::damaged(sal_Int32 nExtentsX, sal_Int32 nExtentsY,
#endif
}
-#if !GTK_CHECK_VERSION(4, 0, 0)
// blit our backing cairo surface to the target cairo context
-gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
+void GtkSalFrame::DrawingAreaDraw(cairo_t *cr)
{
- GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
-
- cairo_set_source_surface(cr, pThis->m_pSurface, 0, 0);
+ cairo_set_source_surface(cr, m_pSurface, 0, 0);
cairo_paint(cr);
+}
+#if !GTK_CHECK_VERSION(4, 0, 0)
+gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->DrawingAreaDraw(cr);
return false;
}
-
-void GtkSalFrame::sizeAllocated(GtkWidget* pWidget, GdkRectangle *pAllocation, gpointer frame)
+#else
+void GtkSalFrame::signalDraw(GtkDrawingArea*, cairo_t *cr, int /*width*/, int /*height*/, gpointer frame)
{
GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->DrawingAreaDraw(cr);
+}
+#endif
+
+void GtkSalFrame::DrawingAreaResized(GtkWidget* pWidget, int nWidth, int nHeight)
+{
+ SolarMutexGuard aGuard;
// ignore size-allocations that occur during configuring an embedded SalObject
- if (pThis->m_bSalObjectSetPosSize)
+ if (m_bSalObjectSetPosSize)
return;
- pThis->maGeometry.nWidth = pAllocation->width;
- pThis->maGeometry.nHeight = pAllocation->height;
+ maGeometry.nWidth = nWidth;
+ maGeometry.nHeight = nHeight;
bool bRealized = gtk_widget_get_realized(pWidget);
if (bRealized)
- pThis->AllocateFrame();
- pThis->CallCallbackExc( SalEvent::Resize, nullptr );
+ AllocateFrame();
+ CallCallbackExc( SalEvent::Resize, nullptr );
if (bRealized)
- pThis->TriggerPaintEvent();
+ TriggerPaintEvent();
}
+#if !GTK_CHECK_VERSION(4, 0, 0)
+void GtkSalFrame::sizeAllocated(GtkWidget* pWidget, GdkRectangle *pAllocation, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->DrawingAreaResized(pWidget, pAllocation->width, pAllocation->height);
+}
+#else
+void GtkSalFrame::sizeAllocated(GtkWidget* pWidget, int nWidth, int nHeight, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->DrawingAreaResized(pWidget, nWidth, nHeight);
+}
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
namespace {
void swapDirection(GdkGravity& gravity)
More information about the Libreoffice-commits
mailing list