[gtk/wip/readonly-events] gdk: Add constructors for dnd events
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/readonly-events] gdk: Add constructors for dnd events
- Date: Sat, 15 Feb 2020 00:30:48 +0000 (UTC)
commit 35d2dac64c6b4092d6c5a193ae0853d133be040f
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 14 18:47:50 2020 -0500
gdk: Add constructors for dnd events
gdk/gdkdrop.c | 48 ++++++++++++++++++++++++------------------------
gdk/gdkevents.c | 28 ++++++++++++++++++++++++++++
gdk/gdkeventsprivate.h | 7 +++++++
3 files changed, 59 insertions(+), 24 deletions(-)
---
diff --git a/gdk/gdkdrop.c b/gdk/gdkdrop.c
index f4a5b27916..a9a7c2eb79 100644
--- a/gdk/gdkdrop.c
+++ b/gdk/gdkdrop.c
@@ -923,11 +923,12 @@ gdk_drop_emit_enter_event (GdkDrop *self,
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
- event = gdk_event_new (GDK_DRAG_ENTER);
- event->any.surface = g_object_ref (priv->surface);
- event->dnd.drop = g_object_ref (self);
- event->dnd.time = time;
- gdk_event_set_device (event, priv->device);
+ event = gdk_event_drag_new (GDK_DRAG_ENTER,
+ priv->surface,
+ priv->device,
+ self,
+ time,
+ 0, 0);
gdk_drop_do_emit_event (event, dont_queue);
}
@@ -942,13 +943,12 @@ gdk_drop_emit_motion_event (GdkDrop *self,
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
- event = gdk_event_new (GDK_DRAG_MOTION);
- event->any.surface = g_object_ref (priv->surface);
- event->dnd.drop = g_object_ref (self);
- event->dnd.time = time;
- event->dnd.x = x;
- event->dnd.y = y;
- gdk_event_set_device (event, priv->device);
+ event = gdk_event_drag_new (GDK_DRAG_MOTION,
+ priv->surface,
+ priv->device,
+ self,
+ time,
+ x, y);
gdk_drop_do_emit_event (event, dont_queue);
}
@@ -961,11 +961,12 @@ gdk_drop_emit_leave_event (GdkDrop *self,
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
- event = gdk_event_new (GDK_DRAG_LEAVE);
- event->any.surface = g_object_ref (priv->surface);
- event->dnd.drop = g_object_ref (self);
- event->dnd.time = time;
- gdk_event_set_device (event, priv->device);
+ event = gdk_event_drag_new (GDK_DRAG_LEAVE,
+ priv->surface,
+ priv->device,
+ self,
+ time,
+ 0, 0);
gdk_drop_do_emit_event (event, dont_queue);
}
@@ -980,13 +981,12 @@ gdk_drop_emit_drop_event (GdkDrop *self,
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
- event = gdk_event_new (GDK_DROP_START);
- event->any.surface = g_object_ref (priv->surface);
- event->dnd.drop = g_object_ref (self);
- event->dnd.time = time;
- event->dnd.x = x;
- event->dnd.y = y;
- gdk_event_set_device (event, priv->device);
+ event = gdk_event_drag_new (GDK_DROP_START,
+ priv->surface,
+ priv->device,
+ self,
+ time,
+ x, y);
gdk_drop_do_emit_event (event, dont_queue);
}
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 13cde03660..4c6b053832 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -2834,3 +2834,31 @@ gdk_event_pad_group_mode_new (GdkSurface *surface,
return event;
}
+
+GdkEvent *
+gdk_event_drag_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDrop *drop,
+ guint32 time,
+ double x,
+ double y)
+{
+ GdkEvent *event;
+
+ g_return_val_if_fail (type == GDK_DRAG_ENTER ||
+ type == GDK_DRAG_MOTION ||
+ type == GDK_DRAG_LEAVE ||
+ type == GDK_DROP_START, NULL);
+
+ event = gdk_event_new (type);
+
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->dnd.drop = g_object_ref (drop);
+ event->dnd.time = time;
+ event->dnd.x = x;
+ event->dnd.y = y;
+
+ return event;
+}
diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h
index a99489ea3e..5c376f0038 100644
--- a/gdk/gdkeventsprivate.h
+++ b/gdk/gdkeventsprivate.h
@@ -764,6 +764,13 @@ GdkEvent * gdk_event_pad_group_mode_new (GdkSurface *surface,
guint group,
guint mode);
+GdkEvent * gdk_event_drag_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDrop *drop,
+ guint32 time,
+ double x,
+ double y);
#endif /* __GDK_EVENTS_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]