Re: long standing dnd bug fixes



On 7 Jan 2002, Owen Taylor wrote:

> 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;

then, shouldn't this simply be:

if (GTK_WIDGET_NO_WINDOW (widget))
{
widget_allocation_x = widget->allocation.x;
widget_allocation_y = widget->allocation.y;
}

[...]

 	  data->found = data->callback (widget,
 					data->context,
 					data->x - x_offset - widget_allocation_x,
 					data->y - y_offset - widget_allocation_y,
 					data->time);

since y/x_offset just translates data.x/y from widget->parent->window
to widget->window, and subtratacting widget_allocation_x/y makes those
coordinates allocation relative?

>    }
> 
> [ This can be used in place of the existing condition at the top ]

> 
> Regards,
>                                                  Owen

---
ciaoTJ




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]