[gtk+] wayland: Properly apply the fake root offset to event coordinates



commit 92833a0b823d49ba178f7ecd849988aadcbbf9ae
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 17 15:11:13 2014 -0400

    wayland: Properly apply the fake root offset to event coordinates
    
    GdkEvent's x_root and y_root values should be in the same "fake root
    window" coordinate space as gdk_window_get_root_coords.

 gdk/wayland/gdkdevice-wayland.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 88e6e3f..c4f93ae 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -242,15 +242,30 @@ get_coordinates (GdkWaylandDeviceData *data,
                  double *x, double *y,
                  double *x_root, double *y_root)
 {
+  int root_x, root_y;
+
   if (x)
     *x = data->surface_x;
   if (y)
     *y = data->surface_y;
-  /* TODO: Do something clever for relative here */
+
+  if (data->pointer_focus)
+    {
+      gdk_window_get_root_coords (data->pointer_focus,
+                                  data->surface_x,
+                                  data->surface_y,
+                                  &root_x, &root_y);
+    }
+  else
+    {
+      root_x = data->surface_x;
+      root_y = data->surface_y;
+    }
+
   if (x_root)
-    *x_root = data->surface_x;
+    *x_root = root_x;
   if (y_root)
-    *y_root = data->surface_y;
+    *y_root = root_y;
 }
 
 static void


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