[gtk+/wip/carlosg/event-as-object: 834/844] gdk: Move additional code in gdk_event_new() to GdkEvent::constructed
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-as-object: 834/844] gdk: Move additional code in gdk_event_new() to GdkEvent::constructed
- Date: Wed, 13 Dec 2017 17:07:53 +0000 (UTC)
commit 2e07652c259b5291f6ac509ad22c849987cce11f
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Oct 25 15:49:19 2017 +0200
gdk: Move additional code in gdk_event_new() to GdkEvent::constructed
Now that the type is a construct only property, we can initialize the
event fields properly here.
gdk/gdkevents.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index aaf1810..1f16884 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -68,6 +68,7 @@ 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);
G_DEFINE_TYPE (GdkEvent, gdk_event, G_TYPE_OBJECT)
@@ -133,6 +134,7 @@ gdk_event_class_init (GdkEventClass *klass)
object_class->get_property = gdk_event_real_get_property;
object_class->set_property = gdk_event_real_set_property;
+ object_class->constructed = gdk_event_constructed;
object_class->finalize = gdk_event_finalize;
event_props[PROP_EVENT_TYPE] =
@@ -448,11 +450,15 @@ gdk_event_handler_set (GdkEventFunc func,
GdkEvent*
gdk_event_new (GdkEventType type)
{
- GdkEvent *new_event;
+ return g_object_new (GDK_TYPE_EVENT,
+ "event-type", type,
+ NULL);
+}
- new_event = g_object_new (GDK_TYPE_EVENT,
- "event-type", type,
- NULL);
+static void
+gdk_event_constructed (GObject *object)
+{
+ GdkEvent *new_event = GDK_EVENT (object);
/*
* Bytewise 0 initialization is reasonable for most of the
@@ -460,7 +466,7 @@ gdk_event_new (GdkEventType type)
* since I trust bytewise 0 == 0. less than for integers
* or pointers.
*/
- switch ((guint) type)
+ switch ((guint) new_event->any.type)
{
case GDK_MOTION_NOTIFY:
new_event->motion.x = 0.;
@@ -521,8 +527,8 @@ gdk_event_new (GdkEventType type)
default:
break;
}
-
- return new_event;
+
+ G_OBJECT_CLASS (gdk_event_parent_class)->constructed (object);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]