Re: long standing dnd bug fixes
- From: Owen Taylor <otaylor redhat com>
- To: Tim Janik <timj gtk org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: long standing dnd bug fixes
- Date: 07 Jan 2002 12:10:09 -0500
Tim Janik <timj gtk org> writes:
> as far as the allocation is concerned, it is just size constrained,
> the required pointer offset is kept in x/y_offset.
>
> GtkDragFindData new_data = *data;
>
> new_data.x -= x_offset;
> new_data.y -= y_offset;
>
> gtk_drag_find_widget (tmp_list->data, &new_data);
>
> this portion offsets the pointer relative to child->parent->window and
> then recurses to child, while:
>
> data->found = data->callback (widget,
> data->context,
> data->x - new_allocation.x,
> data->y - new_allocation.y,
> data->time);
>
> only offsets the old pointer (still relative to widget->parent->window)
> with respect to the constrained allocation. it however fails to offset
> the pointer relative to widget->window via x/y_offset.
Ah, <sigh>, I _knew_ I was going to regret leaving merging up some of
the 1.2.9/1.2.10 fixes for "later".
Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor redhat com>
* gtk/gtkdnd.c (gtk_drag_find_widget): Don't use
new_allocation.x/new_allocation.y for coordinate,
translation since they are clipped, use the
x_offset/y_offset variables we keep for the purpose instead.
> the apropriate fix is then:
>
> diff -u -p -u -r1.77 gtkdnd.c
> --- gtkdnd.c 2002/01/04 18:28:18 1.77
> +++ gtkdnd.c 2002/01/07 07:47:12
> @@ -1342,8 +1342,8 @@ gtk_drag_find_widget (GtkWidget *w
> {
> data->found = data->callback (widget,
> data->context,
> - data->x - new_allocation.x,
> - data->y - new_allocation.y,
> + data->x - new_allocation.x - x_offset,
> + data->y - new_allocation.y - y_offset,
> data->time);
> /* If so, send a "drag_leave" to the last widget */
> if (data->found)
>
> it fixes beast, doesn't break testdnd, should be reasonably explained
> above and i had other changes pending in the same tree, so it's already
> committed.
This isn't right; new_allocation.x is completel meaningless here, and it
just happens to work in your case since you have new_allocation.x,y == 0.
The GTK+-1.2 fix was:
data->found = data->callback (widget,
data->context,
data->x - x_offset,
data->y - y_offset,
data->time);
Which unfortunately isn't right either [:-(, it must have broken some working
programs] since the coordinates passed to data->callback are supposed to be
allocation relative, not widget->window relative.
The right fix is along the lines of:
if (GTK_NO_WINDOW (widget))
{
gdk_window_get_position (window, &tx, &ty);
window_allocation_offset_x = tx - widget->allocation.x;
window_allocation_offset_y = ty - widget->allocation.y;
}
else
{
window_allocation_offset_x = 0;
window_allocation_offset_y = 0;
}
[ This can be used in place of the existing condition at the top ]
data->found = data->callback (widget,
data->context,
data->x - x_offset + window_allocation_offset_x,
data->y - y_offset + window_allocation_offset_y,
data->time);
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]