From 9ccd51468207e403a3747ebccb8aab36242461d4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Mar 2020 14:28:36 -0400 Subject: [PATCH 1/5] x11: Don't use g_object_unref on events Events are not object anymore. --- gdk/x11/gdkeventsource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index da9ac28979..3e4523077f 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -120,7 +120,7 @@ handle_focus_change (GdkEvent *event) gdk_event_get_source_device (event), focus_in); gdk_display_put_event (gdk_event_get_display (event), focus_event); - g_object_unref (focus_event); + gdk_event_unref (focus_event); } } @@ -209,7 +209,7 @@ handle_touch_synthetic_crossing (GdkEvent *event) if (crossing) { gdk_display_put_event (gdk_device_get_display (device), crossing); - g_object_unref (crossing); + gdk_event_unref (crossing); } } From aa2ca80817aff196ac45f223554ca61ca71458d9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Mar 2020 14:29:08 -0400 Subject: [PATCH 2/5] imcontextsimple: Don't use g_object_unref on events Events are not objects anymore. --- gtk/gtkimcontextsimple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 645f7cd4ca..a96b3f0646 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -929,7 +929,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple, 0); gtk_im_context_filter_keypress (context, tmp_event); - g_object_unref (tmp_event); + gdk_event_unref (tmp_event); } return gtk_im_context_filter_keypress (context, event); From e662438675b66c35d70f977e82885e9298e04a07 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Mar 2020 14:33:01 -0400 Subject: [PATCH 3/5] button: Fix an event handling gotcha We no longer translate event coordinates in-place, so gdk_event_get_position() returns surface-relative coordinates, not widget-relative ones. Just use the coordinates we are given. --- gtk/gtkbutton.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 7da11fb7d5..d633c77fe6 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -306,10 +306,11 @@ click_pressed_cb (GtkGestureClick *gesture, } static gboolean -touch_release_in_button (GtkButton *button) +touch_release_in_button (GtkButton *button, + double x, + double y) { GdkEvent *event; - gdouble x, y; event = gtk_get_current_event (); @@ -322,8 +323,6 @@ touch_release_in_button (GtkButton *button) return FALSE; } - gdk_event_get_position (event, &x, &y); - gdk_event_unref (event); if (gtk_widget_contains (GTK_WIDGET (button), x, y)) @@ -346,7 +345,7 @@ click_released_cb (GtkGestureClick *gesture, gtk_button_do_release (button, gtk_widget_is_sensitive (GTK_WIDGET (button)) && (priv->in_button || - touch_release_in_button (button))); + touch_release_in_button (button, x, y))); sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); From 7b135c96e4d269384000fd3bf81f96333e95b3e6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Mar 2020 14:56:26 -0400 Subject: [PATCH 4/5] cellarea: Fix cell editing We need to translate the event coordinates to widget-relative coordinates. This broke when we stopped translating event coordinates in-place. --- gtk/gtkcellarea.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c index 157c3bc5ed..a4351d14c3 100644 --- a/gtk/gtkcellarea.c +++ b/gtk/gtkcellarea.c @@ -1042,12 +1042,19 @@ gtk_cell_area_real_event (GtkCellArea *area, GtkCellRenderer *renderer = NULL; GtkCellRenderer *focus_renderer; GdkRectangle alloc_area; - gdouble event_x, event_y; + double event_x, event_y; + int x, y; + GtkNative *native; /* We may need some semantics to tell us the offset of the event * window we are handling events for (i.e. GtkTreeView has a bin_window) */ gdk_event_get_position (event, &event_x, &event_y); + native = gtk_widget_get_native (widget); + gtk_widget_translate_coordinates (GTK_WIDGET (native), widget, event_x, event_y, &x, &y); + event_x = x; + event_y = y; + /* Dont try to search for an event coordinate that is not in the area, that will * trigger a runtime warning. */ From 7916b95bc59d4cf93bdbc68ba13e241b9a8e0a36 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Mar 2020 15:03:33 -0400 Subject: [PATCH 5/5] gesture: Fix gtk_gesture_get_bounding_box When we stopped translating event coordinates in-place, this function inadvertently started returning surface-relative bounding boxes instead of widget-relative ones, as expected. Fix this by using the widget-relative coordinates that we already store. --- gtk/gtkgesture.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index 633c1fa3e7..8ef4440b58 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -1293,8 +1293,6 @@ gtk_gesture_get_bounding_box (GtkGesture *gesture, while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &data)) { - gdouble x, y; - if (data->state == GTK_EVENT_SEQUENCE_DENIED) continue; @@ -1304,12 +1302,11 @@ gtk_gesture_get_bounding_box (GtkGesture *gesture, event_type == GDK_BUTTON_RELEASE) continue; - gdk_event_get_position (data->event, &x, &y); n_points++; - x1 = MIN (x1, x); - y1 = MIN (y1, y); - x2 = MAX (x2, x); - y2 = MAX (y2, y); + x1 = MIN (x1, data->widget_x); + y1 = MIN (y1, data->widget_y); + x2 = MAX (x2, data->widget_x); + y2 = MAX (y2, data->widget_y); } if (n_points == 0)