mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gdk: Make it possible to attach user data to GdkEvents
As event->any.window is the toplevel, this is not useful anymore to determine the window/widget that is the target for this event. Add helper functions to attach user data to GdkEvents so the target widget can be stored on the gtk/ side. These calls should be made private with the rest of GdkEvent related API.
This commit is contained in:
parent
5483b9db2d
commit
65de0ebea3
@ -663,6 +663,7 @@ gdk_event_copy (const GdkEvent *event)
|
||||
new_private->source_device = private->source_device ? g_object_ref (private->source_device) : NULL;
|
||||
new_private->seat = private->seat;
|
||||
new_private->tool = private->tool;
|
||||
g_set_object (&new_private->user_data, private->user_data);
|
||||
}
|
||||
|
||||
switch (event->any.type)
|
||||
@ -2577,3 +2578,28 @@ gdk_event_get_scancode (GdkEvent *event)
|
||||
private = (GdkEventPrivate *) event;
|
||||
return private->key_scancode;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_event_set_user_data (GdkEvent *event,
|
||||
GObject *user_data)
|
||||
{
|
||||
GdkEventPrivate *private;
|
||||
|
||||
if (!gdk_event_is_allocated (event))
|
||||
return;
|
||||
|
||||
private = (GdkEventPrivate *) event;
|
||||
g_set_object (&private->user_data, user_data);
|
||||
}
|
||||
|
||||
GObject *
|
||||
gdk_event_get_user_data (GdkEvent *event)
|
||||
{
|
||||
GdkEventPrivate *private;
|
||||
|
||||
if (!gdk_event_is_allocated (event))
|
||||
return NULL;
|
||||
|
||||
private = (GdkEventPrivate *) event;
|
||||
return private->user_data;
|
||||
}
|
||||
|
@ -1567,6 +1567,12 @@ int gdk_event_get_scancode (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_3_22
|
||||
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
void gdk_event_set_user_data (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GObject * gdk_event_get_user_data (GdkEvent *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_EVENTS_H__ */
|
||||
|
@ -150,6 +150,8 @@ struct _GdkEventPrivate
|
||||
GdkSeat *seat;
|
||||
GdkDeviceTool *tool;
|
||||
guint16 key_scancode;
|
||||
|
||||
GObject *user_data;
|
||||
};
|
||||
|
||||
typedef struct _GdkWindowPaint GdkWindowPaint;
|
||||
|
Loading…
Reference in New Issue
Block a user