]> Pileus Git - ~andy/gtk/commitdiff
wayland: Calculate window position offset to give emulated root coordinates
authorRob Bradford <rob@linux.intel.com>
Mon, 23 Apr 2012 16:26:49 +0000 (17:26 +0100)
committerRob Bradford <rob@linux.intel.com>
Wed, 25 Apr 2012 13:36:08 +0000 (14:36 +0100)
This allows combo box popup windows to appear in the correct place. This is a
workaround emulating root coordinates by calculating the offset for a chain
of windows that that are relative to each other.

gdk/wayland/gdkwindow-wayland.c

index 48859cd30ff368ccf9a068a616344ba3885bf7d2..ff3b92b550697ca1ba86f9641bc7b949b48f4405 100644 (file)
@@ -874,6 +874,32 @@ gdk_window_wayland_get_geometry (GdkWindow *window,
     }
 }
 
+void
+_gdk_wayland_window_offset (GdkWindow *window,
+                            gint      *x_out,
+                            gint      *y_out)
+{
+  GdkWindowImplWayland *impl, *parent_impl;
+  GdkWindow *parent_window;
+  gint x_offset = 0, y_offset = 0;
+
+  impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  parent_window = impl->transient_for;
+  while (parent_window)
+    {
+      parent_impl = GDK_WINDOW_IMPL_WAYLAND (parent_window->impl);
+
+      x_offset += window->x;
+      y_offset += window->y;
+
+      parent_window = parent_impl->transient_for;
+    }
+
+  *x_out = x_offset;
+  *y_out = y_offset;
+}
+
 static gint
 gdk_window_wayland_get_root_coords (GdkWindow *window,
                                gint       x,
@@ -881,11 +907,12 @@ gdk_window_wayland_get_root_coords (GdkWindow *window,
                                gint      *root_x,
                                gint      *root_y)
 {
-  /* We can't do this. */
-  if (root_x)
-    *root_x = 0;
-  if (root_y)
-    *root_y = 0;
+  gint x_offset, y_offset;
+
+  _gdk_wayland_window_offset (window, &x_offset, &y_offset);
+
+  *root_x = x_offset + x;
+  *root_y = y_offset + y;
 
   return 1;
 }