mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
gdk: Add a related_target field to some events
Crossing and focus change events are emitted between two widgets, and want to associate both with the events.
This commit is contained in:
parent
c73972f7df
commit
06f790d663
@ -573,6 +573,13 @@ gdk_event_copy (const GdkEvent *event)
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
if (event->crossing.child_surface != NULL)
|
||||
g_object_ref (event->crossing.child_surface);
|
||||
if (event->crossing.related_target)
|
||||
g_object_ref (event->crossing.related_target);
|
||||
break;
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
if (event->focus_change.related_target)
|
||||
g_object_ref (event->focus_change.related_target);
|
||||
break;
|
||||
|
||||
case GDK_DRAG_ENTER:
|
||||
@ -634,6 +641,11 @@ gdk_event_finalize (GObject *object)
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
g_clear_object (&event->crossing.child_surface);
|
||||
g_clear_object (&event->crossing.related_target);
|
||||
break;
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
g_clear_object (&event->focus_change.related_target);
|
||||
break;
|
||||
|
||||
case GDK_DRAG_ENTER:
|
||||
@ -1916,6 +1928,29 @@ gdk_event_get_target (const GdkEvent *event)
|
||||
return event->any.target;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_event_set_related_target (GdkEvent *event,
|
||||
GObject *target)
|
||||
{
|
||||
if (event->any.type == GDK_ENTER_NOTIFY ||
|
||||
event->any.type == GDK_LEAVE_NOTIFY)
|
||||
g_set_object (&event->crossing.related_target, target);
|
||||
else if (event->any.type == GDK_FOCUS_CHANGE)
|
||||
g_set_object (&event->focus_change.related_target, target);
|
||||
}
|
||||
|
||||
GObject *
|
||||
gdk_event_get_related_target (const GdkEvent *event)
|
||||
{
|
||||
if (event->any.type == GDK_ENTER_NOTIFY ||
|
||||
event->any.type == GDK_LEAVE_NOTIFY)
|
||||
return event->crossing.related_target;
|
||||
else if (event->any.type == GDK_FOCUS_CHANGE)
|
||||
return event->focus_change.related_target;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_is_sent:
|
||||
* @event: a #GdkEvent
|
||||
|
@ -303,6 +303,7 @@ struct _GdkEventCrossing
|
||||
GdkNotifyType detail;
|
||||
gboolean focus;
|
||||
guint state;
|
||||
GObject *related_target;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -323,6 +324,7 @@ struct _GdkEventFocus
|
||||
gint16 in;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
GObject *related_target;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -639,6 +641,9 @@ union _GdkEvent
|
||||
void gdk_event_set_target (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GObject * gdk_event_get_target (const GdkEvent *event);
|
||||
void gdk_event_set_related_target (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GObject * gdk_event_get_related_target (const GdkEvent *event);
|
||||
|
||||
|
||||
#endif /* __GDK_EVENTS_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user