summaryrefslogtreecommitdiff
path: root/gtk/gtkdnd-quartz.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@lanedo.com>2012-04-22 17:11:38 +0200
committerKristian Rietveld <kris@lanedo.com>2012-04-22 17:38:52 +0200
commit89f166b54218ac3dc9b7b1584db9044d88f85966 (patch)
tree9682ed5708c3b6885ed32996524298ffb4b88033 /gtk/gtkdnd-quartz.c
parent88ed04cc372cdda51071372cdd3177e70bc4aba0 (diff)
downloadgtk+-89f166b54218ac3dc9b7b1584db9044d88f85966.tar.gz
quartz: fix coordinates for synthesized event
Of course, we must pass coordinates in the NSWindow coordinate system when creating an NSEvent. This fixes drag icon positioning and makes the icon slide back to the correct position when the drag is canceled.
Diffstat (limited to 'gtk/gtkdnd-quartz.c')
-rw-r--r--gtk/gtkdnd-quartz.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 6b89b355c3..d9d8ca72a9 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1090,7 +1090,7 @@ gtk_drag_begin_idle (gpointer arg)
[nswindow dragImage:drag_image
at:point
- offset:NSMakeSize(0, 0)
+ offset:NSZeroSize
event:info->nsevent
pasteboard:pasteboard
source:nswindow
@@ -1134,8 +1134,25 @@ gtk_drag_begin_internal (GtkWidget *widget,
{
if (gdk_event_get_coords (event, &x, &y))
{
+ /* 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);
+ }
+
point.x = x;
- point.y = y;
+ point.y = gdk_window_get_height (window) - y;
}
time = (double)gdk_event_get_time (event);
}