summaryrefslogtreecommitdiffstats
path: root/widget/gtk/gtk3drawing.cpp
diff options
context:
space:
mode:
authortrav90 <travawine@protonmail.ch>2018-04-06 10:34:41 -0500
committertrav90 <travawine@protonmail.ch>2018-04-06 10:34:41 -0500
commitd75e9071f11fe7ad2cb1271a002326d2d71c075d (patch)
tree6c3b22c25fd5f337665f46efc61da1cd62b0d47f /widget/gtk/gtk3drawing.cpp
parentb1f27cb866e0e317a574df81ff101cb2e9ca5217 (diff)
downloadUXP-d75e9071f11fe7ad2cb1271a002326d2d71c075d.tar
UXP-d75e9071f11fe7ad2cb1271a002326d2d71c075d.tar.gz
UXP-d75e9071f11fe7ad2cb1271a002326d2d71c075d.tar.lz
UXP-d75e9071f11fe7ad2cb1271a002326d2d71c075d.tar.xz
UXP-d75e9071f11fe7ad2cb1271a002326d2d71c075d.zip
[GTK3] Consider also margin when determine range widget slider size
Diffstat (limited to 'widget/gtk/gtk3drawing.cpp')
-rw-r--r--widget/gtk/gtk3drawing.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp
index 4363391c9..351c7c654 100644
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -2548,10 +2548,27 @@ moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint*
MOZ_GTK_SCALE_THUMB_HORIZONTAL:
MOZ_GTK_SCALE_THUMB_VERTICAL;
GtkStyleContext* style = ClaimStyleContext(widget);
- gtk_style_context_get(style, gtk_style_context_get_state(style),
- "min-width", thumb_length,
- "min-height", thumb_height,
+ gint min_width, min_height;
+ GtkStateFlags state = gtk_style_context_get_state(style);
+ gtk_style_context_get(style, state,
+ "min-width", &min_width,
+ "min-height", &min_height,
nullptr);
+ GtkBorder margin;
+ gtk_style_context_get_margin(style, state, &margin);
+ gint margin_width = margin.left + margin.right;
+ gint margin_height = margin.top + margin.bottom;
+
+ // Negative margin of slider element also determines its minimal size
+ // so use bigger of those two values.
+ if (min_width < -margin_width)
+ min_width = -margin_width;
+ if (min_height < -margin_height)
+ min_height = -margin_height;
+
+ *thumb_length = min_width;
+ *thumb_height = min_height;
+
ReleaseStyleContext(style);
}