diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index c500288aae..a2d793d69b 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -68,10 +68,17 @@ void wxScrollHelper::DoAdjustScrollbar(GtkRange* range, *linesPerPage = 0; } + GtkAdjustment* adj = gtk_range_get_adjustment(range); + const bool wasVisible = gtk_adjustment_get_upper(adj) > gtk_adjustment_get_page_size(adj); + gtk_range_set_increments(range, 1, page_size); - gtk_adjustment_set_page_size(gtk_range_get_adjustment(range), page_size); + gtk_adjustment_set_page_size(adj, page_size); gtk_range_set_range(range, 0, upper); + const bool isVisible = gtk_adjustment_get_upper(adj) > gtk_adjustment_get_page_size(adj); + if (isVisible != wasVisible) + m_win->m_useCachedClientSize = false; + // ensure that the scroll position is always in valid range if (*pos > *lines) *pos = *lines; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 7fb8b0433f..ee5af5e8e4 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4827,12 +4827,19 @@ void wxWindowGTK::SetScrollbar(int orient, g_signal_handlers_block_by_func( sb, (void*)gtk_scrollbar_value_changed, this); + GtkAdjustment* adj = gtk_range_get_adjustment(sb); + const bool wasVisible = gtk_adjustment_get_upper(adj) > gtk_adjustment_get_page_size(adj); + gtk_range_set_increments(sb, 1, thumbVisible); - gtk_adjustment_set_page_size(gtk_range_get_adjustment(sb), thumbVisible); + gtk_adjustment_set_page_size(adj, thumbVisible); gtk_range_set_range(sb, 0, range); gtk_range_set_value(sb, pos); m_scrollPos[dir] = gtk_range_get_value(sb); + const bool isVisible = gtk_adjustment_get_upper(adj) > gtk_adjustment_get_page_size(adj); + if (isVisible != wasVisible) + m_useCachedClientSize = false; + g_signal_handlers_unblock_by_func( sb, (void*)gtk_scrollbar_value_changed, this); }