forked from AuroraMiddleware/gtk
gtk: Refactor crossing event synthesization into a separate function
This is now called outside update_pointer_focus_state() with the events that actually matter (i.e. pointer ones, so no sequence == NULL checks)
This commit is contained in:
parent
e892e20841
commit
f5fde52d61
@ -1318,12 +1318,13 @@ get_virtual_notify_type (GdkNotifyType notify_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
synth_crossing_for_motion (GtkWidget *widget,
|
synth_crossing (GtkWidget *widget,
|
||||||
GtkWidget *toplevel,
|
GtkWidget *toplevel,
|
||||||
gboolean enter,
|
gboolean enter,
|
||||||
GtkWidget *other_widget,
|
GtkWidget *other_widget,
|
||||||
GdkEvent *source,
|
GdkEvent *source,
|
||||||
GdkNotifyType notify_type)
|
GdkNotifyType notify_type,
|
||||||
|
GdkCrossingMode crossing_mode)
|
||||||
{
|
{
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
@ -1345,7 +1346,7 @@ synth_crossing_for_motion (GtkWidget *widget,
|
|||||||
gdk_event_get_coords (source, &x, &y);
|
gdk_event_get_coords (source, &x, &y);
|
||||||
event->crossing.x = x;
|
event->crossing.x = x;
|
||||||
event->crossing.y = y;
|
event->crossing.y = y;
|
||||||
event->crossing.mode = GDK_CROSSING_NORMAL;
|
event->crossing.mode = crossing_mode;
|
||||||
event->crossing.detail = notify_type;
|
event->crossing.detail = notify_type;
|
||||||
|
|
||||||
gtk_widget_event (widget, event);
|
gtk_widget_event (widget, event);
|
||||||
@ -1357,8 +1358,7 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
|||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
GtkWidget *new_target)
|
GtkWidget *new_target)
|
||||||
{
|
{
|
||||||
GtkWidget *old_target = NULL, *ancestor = NULL, *widget;
|
GtkWidget *old_target = NULL;
|
||||||
GdkNotifyType enter_type, leave_type, notify_type;
|
|
||||||
GdkEventSequence *sequence;
|
GdkEventSequence *sequence;
|
||||||
GdkDevice *device;
|
GdkDevice *device;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
@ -1373,8 +1373,18 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
|||||||
gtk_window_update_pointer_focus (toplevel, device, sequence,
|
gtk_window_update_pointer_focus (toplevel, device, sequence,
|
||||||
new_target, x, y);
|
new_target, x, y);
|
||||||
|
|
||||||
if (sequence != NULL)
|
|
||||||
return old_target;
|
return old_target;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_synthesize_crossing_events (GtkWindow *toplevel,
|
||||||
|
GtkWidget *old_target,
|
||||||
|
GtkWidget *new_target,
|
||||||
|
GdkEvent *event,
|
||||||
|
GdkCrossingMode mode)
|
||||||
|
{
|
||||||
|
GtkWidget *ancestor = NULL, *widget;
|
||||||
|
GdkNotifyType enter_type, leave_type, notify_type;
|
||||||
|
|
||||||
if (old_target && new_target)
|
if (old_target && new_target)
|
||||||
ancestor = gtk_widget_common_ancestor (old_target, new_target);
|
ancestor = gtk_widget_common_ancestor (old_target, new_target);
|
||||||
@ -1401,8 +1411,8 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
|||||||
notify_type = (widget == old_target) ?
|
notify_type = (widget == old_target) ?
|
||||||
leave_type : get_virtual_notify_type (leave_type);
|
leave_type : get_virtual_notify_type (leave_type);
|
||||||
|
|
||||||
synth_crossing_for_motion (widget, GTK_WIDGET (toplevel), FALSE,
|
synth_crossing (widget, GTK_WIDGET (toplevel), FALSE,
|
||||||
new_target, event, notify_type);
|
new_target, event, notify_type, mode);
|
||||||
widget = gtk_widget_get_parent (widget);
|
widget = gtk_widget_get_parent (widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1426,12 +1436,10 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
|||||||
notify_type = (widget == new_target) ?
|
notify_type = (widget == new_target) ?
|
||||||
enter_type : get_virtual_notify_type (enter_type);
|
enter_type : get_virtual_notify_type (enter_type);
|
||||||
|
|
||||||
synth_crossing_for_motion (widget, GTK_WIDGET (toplevel), TRUE,
|
synth_crossing (widget, GTK_WIDGET (toplevel), TRUE,
|
||||||
old_target, event, notify_type);
|
old_target, event, notify_type, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return old_target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1497,8 +1505,14 @@ handle_pointing_event (GdkEvent *event)
|
|||||||
case GDK_MOTION_NOTIFY:
|
case GDK_MOTION_NOTIFY:
|
||||||
target = _gtk_toplevel_pick (toplevel, x, y, NULL, NULL);
|
target = _gtk_toplevel_pick (toplevel, x, y, NULL, NULL);
|
||||||
old_target = update_pointer_focus_state (toplevel, event, target);
|
old_target = update_pointer_focus_state (toplevel, event, target);
|
||||||
|
|
||||||
if (event->type == GDK_MOTION_NOTIFY || event->type == GDK_ENTER_NOTIFY)
|
if (event->type == GDK_MOTION_NOTIFY || event->type == GDK_ENTER_NOTIFY)
|
||||||
|
{
|
||||||
|
gtk_synthesize_crossing_events (toplevel, old_target, target,
|
||||||
|
event, GDK_CROSSING_NORMAL);
|
||||||
|
|
||||||
gtk_window_maybe_update_cursor (toplevel, NULL, device);
|
gtk_window_maybe_update_cursor (toplevel, NULL, device);
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type == GDK_TOUCH_BEGIN)
|
if (event->type == GDK_TOUCH_BEGIN)
|
||||||
gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
|
gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
|
||||||
|
Loading…
Reference in New Issue
Block a user