[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 10 15:17:52 UTC 2021
vcl/inc/unx/gtk/gtkframe.hxx | 5 ++++
vcl/unx/gtk3/gtkframe.cxx | 49 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletion(-)
New commits:
commit bd0968922f214663e2e376c9429db2d8f942631f
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 10 13:29:25 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 10 17:17:12 2021 +0200
gtk4: add gesturePressed/gestureReleased support for basic clicks
some unknowns here still, but gets some clicks working
Change-Id: Ib97a3b70baba5bcce70b71b6d030a1ad2a591724
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115331
Tested-by: Caolán McNamara <caolanm at redhat.com>
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 8eaec596dfb4..87ab676c624a 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -275,6 +275,11 @@ class GtkSalFrame final : public SalFrame
#endif
static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
static void gestureLongPress(GtkGestureLongPress* gesture, gdouble x, gdouble y, gpointer frame);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ static void gesturePressed(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
+ static void gestureReleased(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
+ void gestureButton(GtkGestureClick* gesture, SalEvent nEventType, gdouble x, gdouble y);
+#endif
#if !GTK_CHECK_VERSION(4, 0, 0)
static gboolean signalFocus( GtkWidget*, GdkEventFocus*, gpointer );
static void signalSetFocus( GtkWindow* pWindow, GtkWidget* pWidget, gpointer frame );
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index a2838228042b..8a918fe99c67 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -935,8 +935,15 @@ void GtkSalFrame::InitCommon()
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "query-tooltip", G_CALLBACK(signalTooltipQuery), this ));
#if !GTK_CHECK_VERSION(4,0,0)
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this ));
- m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "motion-notify-event", G_CALLBACK(signalMotion), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-release-event", G_CALLBACK(signalButton), this ));
+#else
+ GtkGesture *pClick = gtk_gesture_click_new();
+ gtk_widget_add_controller(pEventWidget, GTK_EVENT_CONTROLLER(pClick));
+ g_signal_connect(pClick, "pressed", G_CALLBACK(gesturePressed), this);
+ g_signal_connect(pClick, "released", G_CALLBACK(gestureReleased), this);
+#endif
+#if !GTK_CHECK_VERSION(4,0,0)
+ m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "motion-notify-event", G_CALLBACK(signalMotion), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "leave-notify-event", G_CALLBACK(signalCrossing), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "enter-notify-event", G_CALLBACK(signalCrossing), this ));
@@ -2933,7 +2940,47 @@ gboolean GtkSalFrame::signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer
return true;
}
+#else
+void GtkSalFrame::gesturePressed(GtkGestureClick* gesture, int /*n_press*/, gdouble x, gdouble y, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->gestureButton(gesture, SalEvent::MouseButtonDown, x, y);
+}
+void GtkSalFrame::gestureReleased(GtkGestureClick* gesture, int /*n_press*/, gdouble x, gdouble y, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->gestureButton(gesture, SalEvent::MouseButtonUp, x, y);
+}
+
+void GtkSalFrame::gestureButton(GtkGestureClick* gesture, SalEvent nEventType, gdouble x, gdouble y)
+{
+ SalMouseEvent aEvent;
+ switch (gtk_gesture_single_get_current_button(GTK_GESTURE_SINGLE(gesture)))
+ {
+ case 1: aEvent.mnButton = MOUSE_LEFT; break;
+ case 2: aEvent.mnButton = MOUSE_MIDDLE; break;
+ case 3: aEvent.mnButton = MOUSE_RIGHT; break;
+ default: return;
+ }
+
+ GdkEvent* pEvent = gtk_gesture_get_last_event(GTK_GESTURE(gesture), nullptr);
+
+ aEvent.mnTime = gdk_event_get_time(pEvent);
+ aEvent.mnX = x;
+ aEvent.mnY = y;
+//TODO aEvent.mnCode = GetMouseModCode( pEvent->state );
+ aEvent.mnCode = aEvent.mnButton;
+
+ if( AllSettings::GetLayoutRTL() )
+ aEvent.mnX = maGeometry.nWidth-1-aEvent.mnX;
+
+ CallCallbackExc(nEventType, &aEvent);
+}
+
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
void GtkSalFrame::LaunchAsyncScroll(GdkEvent const * pEvent)
{
//if we don't match previous pending states, flush that queue now
More information about the Libreoffice-commits
mailing list