Gtk.Scale's highlight can overflow the trough
Steps to reproduce
- Give trough of any horizontal Gtk.Scale a large height e.g. 20pt (so that the bug can be observed more easily).
- Make the slider invisible using
opacity: 0;
CSS property (so that we can see the highlight more clearly). - Give both the trough and highlight a large border-radius e.g. 10pt (so that highlight doesn't even have a reason to overflow trough).
- Set Scale's adjustment's min and max to 0.0 and 1.0 respectively (for simplicity).
- Change value of Scale's adjustment to a small value e.g.
0.03
.
Minimal Example
-
Save the following contents as
scale-overfolow-bug.css
.scale trough { min-height: 20pt; } scale trough slider { opacity: 0; } scale trough, scale trough highlight { border-radius: 10pt; }
-
Save the following code as
scale-overfolow-bug.c
.#include <gtk/gtk.h> void on_activate (GtkApplication *app) { GtkWindow *win; GtkWidget *scale; GFile *css_file; GdkDisplay *display; GtkAdjustment *adj; GtkCssProvider *provider; win = GTK_WINDOW (gtk_application_window_new (app)); scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1, 0.1); adj = gtk_range_get_adjustment( GTK_RANGE (scale)); css_file = g_file_new_for_path ("scale-overflow-bug.css"); display = gdk_display_get_default (); provider = gtk_css_provider_new (); gtk_css_provider_load_from_file (provider, css_file); gtk_style_context_add_provider_for_display(display, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); gtk_adjustment_set_value (adj, 0.03); gtk_window_set_child (win, scale); gtk_window_present (win); } int main(int argc, char **argv) { GtkApplication *app = gtk_application_new (NULL, 0); g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL); return g_application_run (G_APPLICATION (app), argc, argv); }
-
Compile and run the code with the following command.
gcc $(pkg-config --libs --cflags gtk4) scale-overflow-bug.c -o scale-overflow-bug && ./scale-overflow-bug
Current behavior
The highlight overflows the trough.
Expected outcome
The highlight should not overflow the trough.
Version information
GTK: 4.10.1 (from Manjaro repos)
Shell: 43.4
Windowing System: Wayland
OS: Manjaro 22.1.0 Talos (2023-04-01)
Graphics: Mesa Intel® HD Graphics 620 (KBL GT2) (as reported by GNOME Settings)
Device: Dell Vostro 14-3468