From 53cf2cf81b224aab8a777aea847fbdc1e7a6b903 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 27 Dec 2021 12:43:11 +0800 Subject: [PATCH] * src/pgtkterm.c (pgtk_handle_event): Add pinch event support. --- src/pgtkterm.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/pgtkterm.c b/src/pgtkterm.c index c6b56b271e8..c75dab5130a 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -4812,8 +4812,44 @@ pgtk_any_window_to_frame (GdkWindow * window) } static gboolean -pgtk_handle_event (GtkWidget * widget, GdkEvent * event, gpointer * data) +pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data) { +#if GTK_CHECK_VERSION (3, 18, 0) + struct frame *f; + union buffered_input_event inev; + GtkWidget *frame_widget; + gint x, y; + + if (event->type == GDK_TOUCHPAD_PINCH + && (event->touchpad_pinch.phase + != GDK_TOUCHPAD_GESTURE_PHASE_END)) + { + f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); + frame_widget = FRAME_GTK_WIDGET (f); + + gtk_widget_translate_coordinates (widget, frame_widget, + lrint (event->touchpad_pinch.x), + lrint (event->touchpad_pinch.y), + &x, &y); + if (f) + { + + inev.ie.kind = PINCH_EVENT; + XSETFRAME (inev.ie.frame_or_window, f); + XSETINT (inev.ie.x, x); + XSETINT (inev.ie.y, y); + inev.ie.arg = list4 (make_float (event->touchpad_pinch.dx), + make_float (event->touchpad_pinch.dy), + make_float (event->touchpad_pinch.scale), + make_float (event->touchpad_pinch.angle_delta)); + inev.ie.modifiers = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), + event->touchpad_pinch.state); + evq_enqueue (&inev); + } + + return TRUE; + } +#endif return FALSE; } -- 2.39.2