Avoid blank browser space when resizing the window

This commit is contained in:
Přemysl Eric Janouch 2022-01-12 10:40:19 +01:00
parent cfa90fb7de
commit 05453718bb
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -1019,11 +1019,19 @@ fiv_browser_realize(GtkWidget *widget)
static void
fiv_browser_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
FivBrowser *self = FIV_BROWSER(widget);
GTK_WIDGET_CLASS(fiv_browser_parent_class)
->size_allocate(widget, allocation);
// TODO(p): Update adjustments so that blank space is avoided.
relayout(FIV_BROWSER(widget), allocation->width);
int height = relayout(FIV_BROWSER(widget), allocation->width);
// Avoid fresh blank space.
if (self->vadjustment) {
double y1 = gtk_adjustment_get_value(self->vadjustment);
double ph = gtk_adjustment_get_page_size(self->vadjustment);
if (y1 + ph > height)
gtk_adjustment_set_value(self->vadjustment, height - ph);
}
}
static gboolean