+ /* We need to translate (x, y) to coordinates relative to the
+ * toplevel GdkWindow, which should be the GdkWindow backing
+ * nswindow. Then, we convert to the NSWindow coordinate system.
+ */
+ GdkWindow *window = event->any.window;
+ GdkWindow *toplevel = gdk_window_get_effective_toplevel (window);
+
+ while (window != toplevel)
+ {
+ double old_x = x;
+ double old_y = y;
+
+ gdk_window_coords_to_parent (window, old_x, old_y,
+ &x, &y);
+ window = gdk_window_get_effective_parent (window);
+ }
+