Commit 505efbb3 authored by Carlos Garnacho's avatar Carlos Garnacho

widget: Change GtkCapturePhase behavior in event controllers' handling

Previously, there would be globally just a capture and a bubble phase,
with the event just going down the hierarchy once, and the up once.
GTK_PHASE_TARGET actually meaning "run within event handlers", so in
a hierarchy of 3 widgets, emission would be:

  Capture(C)
  Capture(B)
  Capture(A)
  Target(A) (if event handlers allow)
  Bubble(A)
  Target(B) (if event handlers allow)
  Bubble(B)
  Target(C) (if event handlers allow)
  Bubble(C)

This commit changes this behavior and uses GTK_PHASE_TARGET in a less
misleading way, running only on the widget that was meant to receive
the event. And GTK_PHASE_BUBBLE has taken over the execution place of
GTK_PHASE_TARGET, so the emission remains:

  Capture(C)
  Capture(B)
  Capture(A)
  Target(A)
  Bubble(A) (if event handlers allow)
  Bubble(B) (...)
  Bubble(C) (...)

As it was, GTK_PHASE_BUBBLE was useful for running event controllers
paralelly to event handlers, without modifying a single line in those.
For those mixed scenarios, Any of the other phases will have to be
used at discretion, or the event handlers eventually changed to chain
up and let the default event handlers in GtkWidget to be run.
parent a8e833dc
......@@ -7130,7 +7130,7 @@ gtk_widget_real_button_event (GtkWidget *widget,
GdkEventButton *event)
{
return _gtk_widget_run_controllers (widget, (GdkEvent *) event,
GTK_PHASE_TARGET);
GTK_PHASE_BUBBLE);
}
static gboolean
......@@ -7138,7 +7138,7 @@ gtk_widget_real_motion_event (GtkWidget *widget,
GdkEventMotion *event)
{
return _gtk_widget_run_controllers (widget, (GdkEvent *) event,
GTK_PHASE_TARGET);
GTK_PHASE_BUBBLE);
}
static gboolean
......@@ -7183,7 +7183,7 @@ gtk_widget_real_touch_event (GtkWidget *widget,
if (!event->emulating_pointer)
return _gtk_widget_run_controllers (widget, (GdkEvent*) event,
GTK_PHASE_TARGET);
GTK_PHASE_BUBBLE);
if (event->type == GDK_TOUCH_BEGIN ||
event->type == GDK_TOUCH_END)
......@@ -7248,7 +7248,7 @@ gtk_widget_real_grab_broken_event (GtkWidget *widget,
GdkEventGrabBroken *event)
{
return _gtk_widget_run_controllers (widget, (GdkEvent*) event,
GTK_PHASE_TARGET);
GTK_PHASE_BUBBLE);
}
#define WIDGET_REALIZED_FOR_EVENT(widget, event) \
......@@ -7586,6 +7586,9 @@ gtk_widget_event_internal (GtkWidget *widget,
g_object_ref (widget);
if (widget == gtk_get_event_widget (event))
return_val |= _gtk_widget_run_controllers (widget, event, GTK_PHASE_TARGET);
g_signal_emit (widget, widget_signals[EVENT], 0, event, &handled);
return_val |= handled | !WIDGET_REALIZED_FOR_EVENT (widget, event);
if (!return_val)
......@@ -7699,8 +7702,6 @@ gtk_widget_event_internal (GtkWidget *widget,
else
return_val = TRUE;
return_val |= _gtk_widget_run_controllers (widget, event, GTK_PHASE_BUBBLE);
g_object_unref (widget);
return return_val;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment