forked from AuroraMiddleware/gtk
widget: Make gtk_widget_pick() really slow
We cannot fast-track picking by using gtk_widget_contains(). Child widgets may extend their parent using ie negative margins. This is not just a theoretical concern, this is what's happening right now with GtkScale's sliders relative to the trough. The problem is that we now iterate through all widgets, even when they aren't anywhere near the mouse pointer. So essentially every pick operation is now guaranteed O(N_WIDGETS) which used to be the worst case that pretty much never happened.
This commit is contained in:
parent
cf1cd19b61
commit
994287b71f
@ -955,9 +955,6 @@ gtk_widget_real_pick (GtkWidget *widget,
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
if (!gtk_widget_contains (widget, x, y))
|
||||
return NULL;
|
||||
|
||||
for (child = _gtk_widget_get_last_child (widget);
|
||||
child;
|
||||
child = _gtk_widget_get_prev_sibling (child))
|
||||
@ -972,6 +969,9 @@ gtk_widget_real_pick (GtkWidget *widget,
|
||||
return picked;
|
||||
}
|
||||
|
||||
if (!gtk_widget_contains (widget, x, y))
|
||||
return NULL;
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
@ -13186,6 +13186,11 @@ gtk_widget_pick (GtkWidget *widget,
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
if (gtk_widget_get_pass_through (widget) ||
|
||||
!gtk_widget_is_sensitive (widget) ||
|
||||
!gtk_widget_is_drawable (widget))
|
||||
return NULL;
|
||||
|
||||
return GTK_WIDGET_GET_CLASS (widget)->pick (widget, x, y);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user