diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index d9245f9df5..e607474937 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -949,33 +949,45 @@ static GdkRectangle GetMonitorGeom(GdkWindow* window) } #endif +#ifdef __WXGTK3__ +static int GetNodeWidth(wxGtkStyleContext& sc) +{ + int width; + gtk_style_context_get(sc, GTK_STATE_FLAG_NORMAL, "min-width", &width, nullptr); + GtkBorder border; + gtk_style_context_get_padding(sc, GTK_STATE_FLAG_NORMAL, &border); + width += border.left + border.right; + gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border); + width += border.left + border.right; + gtk_style_context_get_margin(sc, GTK_STATE_FLAG_NORMAL, &border); + width += border.left + border.right; + + return width < 0 ? 0 : width; +} +#endif // __WXGTK3__ + static int GetScrollbarWidth() { int width; #ifdef __WXGTK3__ if (wx_is_at_least_gtk3(20)) { - GtkBorder border; #if GTK_CHECK_VERSION(3,10,0) wxGtkStyleContext sc(gtk_widget_get_scale_factor(ScrollBarWidget())); #else wxGtkStyleContext sc; #endif sc.Add(GTK_TYPE_SCROLLBAR, "scrollbar", "scrollbar", "vertical", "right", nullptr); + width = GetNodeWidth(sc); - gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border); + sc.Add("contents"); + width += GetNodeWidth(sc); - sc.Add("contents").Add("trough").Add("slider"); + sc.Add("trough"); + width += GetNodeWidth(sc); - gtk_style_context_get(sc, GTK_STATE_FLAG_NORMAL, "min-width", &width, nullptr); - width += border.left + border.right; - - gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border); - width += border.left + border.right; - gtk_style_context_get_padding(sc, GTK_STATE_FLAG_NORMAL, &border); - width += border.left + border.right; - gtk_style_context_get_margin(sc, GTK_STATE_FLAG_NORMAL, &border); - width += border.left + border.right; + sc.Add("slider"); + width += GetNodeWidth(sc); } else #endif