[gtk+/wip/carlosg/event-delivery: 70/104] gdk: Make it possible to attach user data to GdkEvents
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 70/104] gdk: Make it possible to attach user data to GdkEvents
- Date: Thu, 25 May 2017 14:45:59 +0000 (UTC)
commit 65de0ebea3d2656b75ffcb41fd6ce2be1aaa01a2
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu May 4 13:41:29 2017 +0200
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.
gdk/gdkevents.c | 26 ++++++++++++++++++++++++++
gdk/gdkevents.h | 6 ++++++
gdk/gdkinternals.h | 2 ++
3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index ca72b9c..a3512b0 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -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;
+}
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 8ff9613..39cb761 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -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__ */
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 6e0a37b..56c26d2 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -150,6 +150,8 @@ struct _GdkEventPrivate
GdkSeat *seat;
GdkDeviceTool *tool;
guint16 key_scancode;
+
+ GObject *user_data;
};
typedef struct _GdkWindowPaint GdkWindowPaint;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]