diff options
author | Timm Bäder <mail@baedert.org> | 2019-01-17 16:26:24 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2019-01-18 19:43:48 +0100 |
commit | b2eff300b12fcff1f27f51326d23ea3137c51dd0 (patch) | |
tree | 2bf1cc3d393902b21d8a46a2d80f9f0fcf628e46 /gdk | |
parent | dbc8d253c3f63018c85af0b024f6cf8f59340081 (diff) | |
download | gtk+-b2eff300b12fcff1f27f51326d23ea3137c51dd0.tar.gz |
GdkEvent: Add a proper user_data member to GdkEventAny
Setting it as qdata on the object doesn't save any memory since we use
the user_data as the event target, which every event has set these days.
This way is also faster since just reffing the object doesn't do any
locking.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkevents.c | 22 | ||||
-rw-r--r-- | gdk/gdkeventsprivate.h | 1 |
2 files changed, 6 insertions, 17 deletions
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 35558f68b0..300974f3ce 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -79,8 +79,6 @@ static GdkEventFunc _gdk_event_func = NULL; /* Callback for events */ static gpointer _gdk_event_data = NULL; static GDestroyNotify _gdk_event_notify = NULL; -static GQuark quark_event_user_data = 0; - static void gdk_event_constructed (GObject *object); static void gdk_event_finalize (GObject *object); @@ -158,8 +156,6 @@ gdk_event_class_init (GdkEventClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_properties (object_class, N_PROPS, event_props); - - quark_event_user_data = g_quark_from_static_string ("gdk-event-user-data"); } void @@ -626,8 +622,8 @@ gdk_event_copy (const GdkEvent *event) g_object_ref (new_event->any.device); if (new_event->any.source_device) g_object_ref (new_event->any.source_device); - - gdk_event_set_user_data (new_event, gdk_event_get_user_data (event)); + if (new_event->any.user_data) + g_object_ref (new_event->any.user_data); switch ((guint) event->any.type) { @@ -737,6 +733,7 @@ gdk_event_finalize (GObject *object) g_clear_object (&event->any.device); g_clear_object (&event->any.source_device); + g_clear_object (&event->any.user_data); G_OBJECT_CLASS (gdk_event_parent_class)->finalize (object); } @@ -1968,22 +1965,13 @@ void gdk_event_set_user_data (GdkEvent *event, GObject *user_data) { - if (user_data) - { - g_object_set_qdata_full (G_OBJECT (event), quark_event_user_data, - g_object_ref (user_data), - g_object_unref); - } - else - { - g_object_steal_qdata (G_OBJECT (event), quark_event_user_data); - } + g_set_object (&event->any.user_data, user_data); } GObject * gdk_event_get_user_data (const GdkEvent *event) { - return g_object_get_qdata (G_OBJECT (event), quark_event_user_data); + return event->any.user_data; } /** diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h index e7e9cac515..91632604b1 100644 --- a/gdk/gdkeventsprivate.h +++ b/gdk/gdkeventsprivate.h @@ -61,6 +61,7 @@ struct _GdkEventAny GdkDevice *device; GdkDevice *source_device; GdkDisplay *display; + GObject *user_data; }; /* |