[gtk+/wip/carlosg/event-delivery: 199/261] gdk: Add gdk_event_set_coords() method



commit fbef9669cb44baed9e18a99caa95e705d3b367de
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 31 16:51:42 2017 +0200

    gdk: Add gdk_event_set_coords() method
    
    A helper function basically for gtk+, so coordinates can be translated
    in place depending on the widget it's being delivered to.

 gdk/gdkevents.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdk/gdkevents.h |    4 ++++
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index cc6cb5e..ca72b9c 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -1198,6 +1198,59 @@ gdk_event_get_root_coords (const GdkEvent *event,
   return fetched;
 }
 
+void
+gdk_event_set_coords (GdkEvent *event,
+                      gdouble   x,
+                      gdouble   y)
+{
+  g_return_if_fail (event != NULL);
+
+  switch (event->type)
+    {
+    case GDK_CONFIGURE:
+      event->configure.x = x;
+      event->configure.y = y;
+      break;
+    case GDK_ENTER_NOTIFY:
+    case GDK_LEAVE_NOTIFY:
+      event->crossing.x = x;
+      event->crossing.y = y;
+      break;
+    case GDK_SCROLL:
+      event->scroll.x = x;
+      event->scroll.y = y;
+      break;
+    case GDK_BUTTON_PRESS:
+    case GDK_2BUTTON_PRESS:
+    case GDK_3BUTTON_PRESS:
+    case GDK_BUTTON_RELEASE:
+      event->button.x = x;
+      event->button.y = y;
+      break;
+    case GDK_TOUCH_BEGIN:
+    case GDK_TOUCH_UPDATE:
+    case GDK_TOUCH_END:
+    case GDK_TOUCH_CANCEL:
+      event->touch.x = x;
+      event->touch.y = y;
+      break;
+    case GDK_MOTION_NOTIFY:
+      event->motion.x = x;
+      event->motion.y = y;
+      break;
+    case GDK_TOUCHPAD_SWIPE:
+      event->touchpad_swipe.x = x;
+      event->touchpad_swipe.y = y;
+      break;
+    case GDK_TOUCHPAD_PINCH:
+      event->touchpad_pinch.x = x;
+      event->touchpad_pinch.y = y;
+      break;
+    default:
+      break;
+    }
+}
+
 /**
  * gdk_event_get_button:
  * @event: a #GdkEvent
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index e7ebcc2..8ff9613 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -1461,6 +1461,10 @@ GDK_AVAILABLE_IN_ALL
 gboolean  gdk_event_get_coords         (const GdkEvent  *event,
                                         gdouble         *x_win,
                                         gdouble         *y_win);
+GDK_AVAILABLE_IN_3_90
+void      gdk_event_set_coords          (GdkEvent *event,
+                                         gdouble   x,
+                                         gdouble   y);
 GDK_AVAILABLE_IN_ALL
 gboolean  gdk_event_get_root_coords    (const GdkEvent *event,
                                         gdouble        *x_root,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]