From b2ff4877e43c33cf26de6f9880745259b5237ebb Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 25 Oct 2014 19:59:11 +0100 Subject: Remove the vertical scroll bar if there's nothing to scroll --- amiga/gui.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index e39d9e7af..4722b1769 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2507,6 +2507,24 @@ void ami_get_msg(void) ami_quit_netsurf_delayed(); } +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, + bool scaled) +{ + struct IBox *bbox; + if(!g) return; + + GetAttr(SPACE_AreaBox, g->shared->objects[GID_BROWSER], (ULONG *)&bbox); + + *width = bbox->Width; + *height = bbox->Height; + + if(scaled) + { + *width /= g->shared->bw->scale; + *height /= g->shared->bw->scale; + } +} + /* Add a vertical scroller, if not already present * Returns true if changed, false otherwise */ static bool ami_gui_vscroll_add(struct gui_window_2 *gwin) @@ -2566,7 +2584,14 @@ static void ami_gui_vscroll_update(struct gui_window_2 *gwin) if((vscroll == BW_SCROLLING_NO) || browser_window_is_frameset(gwin->bw) == true) { rethink = ami_gui_vscroll_remove(gwin); } else { - rethink = ami_gui_vscroll_add(gwin); + int h, w, wh, ww; + if((browser_window_get_extents(gwin->bw, false, &w, &h) == NSERROR_OK)) { + gui_window_get_dimensions(gwin->bw->window, &ww, &wh, false); + if (h > wh) rethink = ami_gui_vscroll_add(gwin); + else rethink = ami_gui_vscroll_remove(gwin); + } else { + rethink = ami_gui_vscroll_add(gwin); + } } if(rethink) { @@ -4631,24 +4656,6 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) // g->shared->new_content = false; } -static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, - bool scaled) -{ - struct IBox *bbox; - if(!g) return; - - GetAttr(SPACE_AreaBox, g->shared->objects[GID_BROWSER], (ULONG *)&bbox); - - *width = bbox->Width; - *height = bbox->Height; - - if(scaled) - { - *width /= g->shared->bw->scale; - *height /= g->shared->bw->scale; - } -} - static void gui_window_update_extent(struct gui_window *g) { struct IBox *bbox; -- cgit v1.2.3