vcl/unx/gtk3/gtkinst.cxx |   52 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

New commits:
commit daa63104b601b7492b62137e77bb0ebf6c6f5b72
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Dec 15 08:14:52 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Dec 15 19:35:35 2022 +0000

    Fix another use of gtk_gesture_zoom_new for GTK 4
    
    ...introduced with 7d5841b435a6794e30f02b62db15660ffe4ee39e "vcl: Implement
    touchpad zoom gesture support in GtkInstanceDrawingArea", and fixing it 
along
    the lines of 903b8f8524b8c84eced3ccbf7cfec9c5b9015f4b "gtk: Fix gtk4 build 
after
    f2bd19f672023 and e6bed4293814d" and 
b37e6d2cbd2cfbd5c6eeba81415182c1c766de8f
    "gtk4: connect the zoom and rotate gestures for gtk4"
    
    Change-Id: I7a4521766e537d33ee3bf1787c317095a2e54af8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144208
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144234
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index ca08ce4d37f6..0525f8118531 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -18281,7 +18281,12 @@ public:
 #endif
 
         ensureMouseEventWidget();
+#if GTK_CHECK_VERSION(4,0,0)
+        m_pZoomGesture = gtk_gesture_zoom_new();
+        gtk_widget_add_controller(m_pMouseEventBox, 
GTK_EVENT_CONTROLLER(m_pZoomGesture));
+#else
         m_pZoomGesture = gtk_gesture_zoom_new(m_pMouseEventBox);
+#endif
         
gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_pZoomGesture),
                                                    GTK_PHASE_TARGET);
         // Note that the default zoom gesture signal handler needs to run 
first to setup correct
commit baf34a3e471c6f3a678bbda8288b8ceb6f867e86
Author:     Povilas Kanapickas <povi...@radix.lt>
AuthorDate: Wed Dec 7 03:13:31 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Dec 15 19:35:25 2022 +0000

    vcl: Implement touchpad zoom gesture support in GtkInstanceDrawingArea
    
    Change-Id: I5ad68ee424fbcc45a3e56045f00ac41cf6c80195
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143758
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144232
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index f44240e216bc..ca08ce4d37f6 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -18089,6 +18089,7 @@ private:
     gulong m_nPopupMenu;
     gulong m_nScrollEvent;
 #endif
+    GtkGesture *m_pZoomGesture;
 
 #if GTK_CHECK_VERSION(4, 0, 0)
     static void signalDraw(GtkDrawingArea*, cairo_t *cr, int /*width*/, int 
/*height*/, gpointer widget)
@@ -18214,6 +18215,38 @@ private:
     }
 #endif
 
+    bool handleSignalZoom(GtkGesture* gesture, GdkEventSequence* sequence,
+                          GestureEventZoomType eEventType)
+    {
+        gdouble x = 0;
+        gdouble y = 0;
+        gtk_gesture_get_point(gesture, sequence, &x, &y);
+
+        double fScaleDelta = 
gtk_gesture_zoom_get_scale_delta(GTK_GESTURE_ZOOM(gesture));
+
+        CommandGestureZoomData aGestureData(x, y, eEventType, fScaleDelta);
+        CommandEvent aCEvt(Point(x, y), CommandEventId::GestureZoom, true, 
&aGestureData);
+        return m_aCommandHdl.Call(aCEvt);
+    }
+
+    static bool signalZoomBegin(GtkGesture* gesture, GdkEventSequence* 
sequence, gpointer widget)
+    {
+        GtkInstanceDrawingArea* pThis = 
static_cast<GtkInstanceDrawingArea*>(widget);
+        return pThis->handleSignalZoom(gesture, sequence, 
GestureEventZoomType::Begin);
+    }
+
+    static bool signalZoomUpdate(GtkGesture* gesture, GdkEventSequence* 
sequence, gpointer widget)
+    {
+        GtkInstanceDrawingArea* pThis = 
static_cast<GtkInstanceDrawingArea*>(widget);
+        return pThis->handleSignalZoom(gesture, sequence, 
GestureEventZoomType::Update);
+    }
+
+    static bool signalZoomEnd(GtkGesture* gesture, GdkEventSequence* sequence, 
gpointer widget)
+    {
+        GtkInstanceDrawingArea* pThis = 
static_cast<GtkInstanceDrawingArea*>(widget);
+        return pThis->handleSignalZoom(gesture, sequence, 
GestureEventZoomType::End);
+    }
+
 #if GTK_CHECK_VERSION(4, 0, 0)
     static void signalResize(GtkDrawingArea*, int nWidth, int nHeight, 
gpointer widget)
     {
@@ -18244,7 +18277,19 @@ public:
         gtk_drawing_area_set_draw_func(m_pDrawingArea, signalDraw, this, 
nullptr);
 #else
         m_nDrawSignalId = g_signal_connect(m_pDrawingArea, "draw", 
G_CALLBACK(signalDraw), this);
+        gtk_widget_add_events(GTK_WIDGET(pDrawingArea), 
GDK_TOUCHPAD_GESTURE_MASK);
 #endif
+
+        ensureMouseEventWidget();
+        m_pZoomGesture = gtk_gesture_zoom_new(m_pMouseEventBox);
+        
gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_pZoomGesture),
+                                                   GTK_PHASE_TARGET);
+        // Note that the default zoom gesture signal handler needs to run 
first to setup correct
+        // scale delta. Otherwise the first "begin" event will always contain 
scale delta of infinity.
+        g_signal_connect_after(m_pZoomGesture, "begin", 
G_CALLBACK(signalZoomBegin), this);
+        g_signal_connect_after(m_pZoomGesture, "update", 
G_CALLBACK(signalZoomUpdate), this);
+        g_signal_connect_after(m_pZoomGesture, "end", 
G_CALLBACK(signalZoomEnd), this);
+
         gtk_widget_set_has_tooltip(m_pWidget, true);
         g_object_set_data(G_OBJECT(m_pDrawingArea), 
"g-lo-GtkInstanceDrawingArea", this);
         m_xDevice->EnableRTL(get_direction());
@@ -18433,6 +18478,8 @@ public:
 
     virtual ~GtkInstanceDrawingArea() override
     {
+        g_clear_object(&m_pZoomGesture);
+
         ImplGetDefaultWindow()->RemoveEventListener(LINK(this, 
GtkInstanceDrawingArea, SettingsChangedHdl));
 
         g_object_steal_data(G_OBJECT(m_pDrawingArea), 
"g-lo-GtkInstanceDrawingArea");

Reply via email to