aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-01-12 10:40:19 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-01-12 10:41:33 +0100
commit05453718bb15465ac4d27c1e5ac5d644b78b1b18 (patch)
treec037ac009bf7d19a7960d63afadc5b6525e66e76
parentcfa90fb7de19c45bf3dc5046efffa7dc31e8e7b1 (diff)
downloadfiv-05453718bb15465ac4d27c1e5ac5d644b78b1b18.tar.gz
fiv-05453718bb15465ac4d27c1e5ac5d644b78b1b18.tar.xz
fiv-05453718bb15465ac4d27c1e5ac5d644b78b1b18.zip
Avoid blank browser space when resizing the window
-rw-r--r--fiv-browser.c12
1 files 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