Commit b92213e4 authored by Timm Bäder's avatar Timm Bäder 🤔

GtkWindow: Don't needlessly resize popovers

Check whether the given popover even changed size in
_gtk_window_set_popover_position. If not, just move its GdkWindow
without calling gtk_widget_queue_resize. Using popover_get_rect here is
still relatively costly, but popover_size_allocate would be doing that
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
parent eb8a6498
......@@ -11904,7 +11904,8 @@ _gtk_window_set_popover_position (GtkWindow *window,
GtkPositionType pos,
const cairo_rectangle_int_t *rect)
{
gboolean need_resize = TRUE;
gboolean need_resize;
gboolean need_move;
GtkWindowPopover *data;
g_return_if_fail (GTK_IS_WINDOW (window));
......@@ -11919,12 +11920,16 @@ _gtk_window_set_popover_position (GtkWindow *window,
gtk_widget_get_name (GTK_WIDGET (window)));
return;
}
else
{
if (data->pos == pos &&
memcmp (&data->rect, rect, sizeof (cairo_rectangle_int_t)) == 0)
need_resize = FALSE;
}
/* Don't queue a resize if the position as well as the size are the same */
need_move = data->pos != pos ||
data->rect.x != rect->x ||
data->rect.y != rect->y;
need_resize = data->pos != pos ||
data->rect.width != rect->width ||
data->rect.height != rect->height;
data->rect = *rect;
data->pos = pos;
......@@ -11936,7 +11941,15 @@ _gtk_window_set_popover_position (GtkWindow *window,
}
if (need_resize)
gtk_widget_queue_resize (popover);
{
gtk_widget_queue_resize (popover);
}
else if (need_move)
{
cairo_rectangle_int_t new_size;
popover_get_rect (data, window, &new_size);
gdk_window_move (data->window, new_size.x, new_size.y);
}
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment