From cc605cf5f40fd65327a7ca40726a6e0dbc43ccc4 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 8 Jan 2002 21:17:55 +0000 Subject: [PATCH] Fix coordinate translations, once and for all. Tue Jan 8 15:53:28 2002 Owen Taylor * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate translations, once and for all. * gtk/gtktextbuffer.c (paste_from_buffer): Free the ClipboardRequest structure. (#66198, HideToshi Tajima) --- ChangeLog | 10 ++++++++++ ChangeLog.pre-2-0 | 10 ++++++++++ ChangeLog.pre-2-10 | 10 ++++++++++ ChangeLog.pre-2-2 | 10 ++++++++++ ChangeLog.pre-2-4 | 10 ++++++++++ ChangeLog.pre-2-6 | 10 ++++++++++ ChangeLog.pre-2-8 | 10 ++++++++++ gtk/gtkdnd.c | 46 ++++++++++++++++++++++----------------------- gtk/gtktextbuffer.c | 1 + 9 files changed, 94 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26490977c5..8ffd41af97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 26490977c5..8ffd41af97 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Tue Jan 8 15:53:28 2002 Owen Taylor + + * gtk/gtkdnd.c (gtk_drag_find_widget): Fix coordinate + translations, once and for all. + + * gtk/gtktextbuffer.c (paste_from_buffer): Free + the ClipboardRequest structure. (#66198, HideToshi + Tajima) + 2002-01-08 jacob berkman * gtk/gtklayout.c (gtk_layout_move_internal): queue a resize on @@ -7,6 +16,7 @@ Tue Jan 8 14:51:19 2002 Owen Taylor * gtk/gtkpaned.c (gtk_paned_expose): Don't draw the handle if we aren't showing both children. + (#68135, Diego Gonzalez) Tue Jan 8 14:45:43 2002 Owen Taylor diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 9611bbe0f9..ca209fade0 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1229,6 +1229,8 @@ gtk_drag_find_widget (GtkWidget *widget, GtkDragFindData *data) { GtkAllocation new_allocation; + gint allocation_to_window_x = 0; + gint allocation_to_window_y = 0; gint x_offset = 0; gint y_offset = 0; @@ -1253,38 +1255,36 @@ gtk_drag_find_widget (GtkWidget *widget, if (widget->parent) { - gint tx, ty, twidth, theight; + gint tx, ty; GdkWindow *window = widget->window; - /* Correct for the fact that the allocation is relative - * to the parent window for window widgets, not to widget->window. + /* Compute the offset from allocation-relative to + * window-relative coordinates. */ + allocation_to_window_x = widget->allocation.x; + allocation_to_window_y = widget->allocation.y; + if (!GTK_WIDGET_NO_WINDOW (widget)) { + /* The allocation is relative to the parent window for + * window widgets, not to widget->window. + */ gdk_window_get_position (window, &tx, &ty); - new_allocation.x -= tx; - new_allocation.y -= ty; + allocation_to_window_x -= tx; + allocation_to_window_y -= ty; } + new_allocation.x = 0 + allocation_to_window_x; + new_allocation.y = 0 + allocation_to_window_y; + while (window && window != widget->parent->window) - { - gdk_window_get_size (window, &twidth, &theight); + { + GdkRectangle window_rect = { 0, 0, 0, 0 }; + + gdk_window_get_size (window, &window_rect.width, &window_rect.height); - if (new_allocation.x < 0) - { - new_allocation.width += new_allocation.x; - new_allocation.x = 0; - } - if (new_allocation.y < 0) - { - new_allocation.height += new_allocation.y; - new_allocation.y = 0; - } - if (new_allocation.x + new_allocation.width > twidth) - new_allocation.width = twidth - new_allocation.x; - if (new_allocation.y + new_allocation.height > theight) - new_allocation.height = theight - new_allocation.y; + gdk_rectangle_intersect (&new_allocation, &window_rect, &new_allocation); gdk_window_get_position (window, &tx, &ty); new_allocation.x += tx; @@ -1342,8 +1342,8 @@ gtk_drag_find_widget (GtkWidget *widget, { data->found = data->callback (widget, data->context, - data->x - new_allocation.x - x_offset, - data->y - new_allocation.y - y_offset, + data->x - x_offset - allocation_to_window_x, + data->y - y_offset - allocation_to_window_y, data->time); /* If so, send a "drag_leave" to the last widget */ if (data->found) diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 250dde4e6a..7650d41e2a 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -2897,6 +2897,7 @@ paste_from_buffer (ClipboardRequest *request_data, post_paste_cleanup (request_data); g_object_unref (G_OBJECT (src_buffer)); + g_free (request_data); } static void