From 05453718bb15465ac4d27c1e5ac5d644b78b1b18 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Wed, 12 Jan 2022 10:40:19 +0100 Subject: Avoid blank browser space when resizing the window --- fiv-browser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fiv-browser.c b/fiv-browser.c index 1707e46..9566e10 100644 --- a/fiv-browser.c +++ b/fiv-browser.c @@ -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 -- cgit v1.2.3-70-g09d2