[gtk/wip/exalm/consumes-motion: 2/2] windowhandle: Don't drag on capture phase
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/consumes-motion: 2/2] windowhandle: Don't drag on capture phase
- Date: Fri, 25 Dec 2020 07:40:27 +0000 (UTC)
commit 6efa3bf8aa5b7250db94aee3ef22a86acd00b88c
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Dec 25 12:35:57 2020 +0500
windowhandle: Don't drag on capture phase
This was needed to work around widgets claiming event sequences on press,
by ignoring them and starting the drag anyway unless they have certain
event controllers on them.
The most visible offender was GtkButton, but since the last commit it
doesn't claim the sequence anymore and we can remove the hack.
gtk/gtkwidget.c | 33 --------------------------------
gtk/gtkwidgetprivate.h | 4 ----
gtk/gtkwindowhandle.c | 51 ++++----------------------------------------------
3 files changed, 4 insertions(+), 84 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b26103e87b..214b728ee1 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11324,39 +11324,6 @@ gtk_widget_remove_controller (GtkWidget *widget,
gtk_list_list_model_item_removed (priv->controller_observer, before);
}
-gboolean
-gtk_widget_consumes_motion (GtkWidget *widget,
- GtkWidget *parent,
- GdkEventSequence *sequence)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-
- while (widget != NULL && widget != parent)
- {
- GList *l;
-
- for (l = priv->event_controllers; l; l = l->next)
- {
- GtkEventController *controller = l->data;
-
- if (controller == NULL ||
- !GTK_IS_GESTURE (controller))
- continue;
-
- if ((!GTK_IS_GESTURE_SINGLE (controller) ||
- GTK_IS_GESTURE_DRAG (controller) ||
- GTK_IS_GESTURE_SWIPE (controller)) &&
- gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
- return TRUE;
- }
-
- widget = priv->parent;
- priv = gtk_widget_get_instance_private (widget);
- }
-
- return FALSE;
-}
-
void
gtk_widget_reset_controllers (GtkWidget *widget)
{
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index eb6959fe7c..b7e2a67b84 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -278,10 +278,6 @@ void _gtk_widget_update_parent_muxer (GtkWidget *widget
GtkActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget,
gboolean create);
-gboolean gtk_widget_consumes_motion (GtkWidget *widget,
- GtkWidget *parent,
- GdkEventSequence *sequence);
-
gboolean gtk_widget_has_tick_callback (GtkWidget *widget);
gboolean gtk_widget_has_size_request (GtkWidget *widget);
diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c
index 5a6beeb273..f4f2fa6e49 100644
--- a/gtk/gtkwindowhandle.c
+++ b/gtk/gtkwindowhandle.c
@@ -60,7 +60,6 @@ struct _GtkWindowHandle {
GtkGesture *click_gesture;
GtkGesture *drag_gesture;
- GtkGesture *bubble_drag_gesture;
GtkWidget *child;
GtkWidget *fallback_menu;
@@ -400,36 +399,12 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
if (ABS (offset_x) > double_click_distance ||
ABS (offset_y) > double_click_distance)
{
- GdkEventSequence *sequence;
double start_x, start_y;
double native_x, native_y;
double window_x, window_y;
GtkNative *native;
GdkSurface *surface;
- sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
-
- if (gtk_event_controller_get_propagation_phase (GTK_EVENT_CONTROLLER (gesture)) == GTK_PHASE_CAPTURE)
- {
- GtkWidget *event_widget = gtk_gesture_get_last_target (GTK_GESTURE (gesture), sequence);
-
- /* Check whether the target widget should be left alone at handling
- * the sequence, this is better done late to give room for gestures
- * there to go denied.
- *
- * Besides claiming gestures, we must bail out too if there's gestures
- * in the "none" state at this point, as those are still handling events
- * and can potentially go claimed, and we don't want to stop the target
- * widget from doing anything.
- */
- if (event_widget != GTK_WIDGET (self) &&
- gtk_widget_consumes_motion (event_widget, GTK_WIDGET (self), sequence))
- {
- gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
- return;
- }
- }
-
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
@@ -458,19 +433,6 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
}
}
-static GtkGesture *
-create_drag_gesture (GtkWindowHandle *self)
-{
- GtkGesture *gesture;
-
- gesture = gtk_gesture_drag_new ();
- g_signal_connect (gesture, "drag-update",
- G_CALLBACK (drag_gesture_update_cb), self);
- gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
-
- return gesture;
-}
-
static void
gtk_window_handle_unrealize (GtkWidget *widget)
{
@@ -562,19 +524,14 @@ gtk_window_handle_init (GtkWindowHandle *self)
{
self->click_gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->click_gesture), 0);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->click_gesture),
- GTK_PHASE_BUBBLE);
g_signal_connect (self->click_gesture, "pressed",
G_CALLBACK (click_gesture_pressed_cb), self);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->click_gesture));
- self->drag_gesture = create_drag_gesture (self);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->drag_gesture),
- GTK_PHASE_CAPTURE);
-
- self->bubble_drag_gesture = create_drag_gesture (self);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->bubble_drag_gesture),
- GTK_PHASE_BUBBLE);
+ self->drag_gesture = gtk_gesture_drag_new ();
+ g_signal_connect (self->drag_gesture, "drag-update",
+ G_CALLBACK (drag_gesture_update_cb), self);
+ gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->drag_gesture));
}
static GtkBuildableIface *parent_buildable_iface;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]