The clock in the desktop panel resizes depending on whether the current time has 3 or 4 digits and this moves other icons. For now for screenshot purposes we're just masking out the icons as well to avoid comparison failures. Ideally the pango API to work out a fixed width should be used and the space taken by the clock/time should remain consistent regardless of the time.
This can be done with pango_font_metrics_get_approximate_digit_width().
Hi. The bug is still relevant? I tried to reproduce it on scarthgap but it seems the clock always has 4 digits (e.g. 07:50) and no resize happens.
Ross, question for you from Dmitry
The original comment is wrong as it doesn't show single digit hours, but as digits are different widths the label will subtly change size over time. We can probably tell the font to use 'tabular numbers' which are all the same width, mitigating this. It would be interesting to see if this code does the right thing when creating the label in clock.c: PangoAttrList *attrs = pango_attr_list_new(); PangoAttribute *attr = pango_attr_font_features_new("tnum=1"); attr->start_index = 0; attr->end_index = G_MAXUINT; pango_attr_list_insert(attrs, attr); gtk_label_set_attributes(GTK_LABEL(label), attrs); pango_attr_list_unref(attrs);
Ross, I have tried both of your approaches. Approach with PangoAttribute simply didn't change widget's behavour at all, maybe because default font doesn't support tnum (it's just a guess, I haven't checked it). Approach with get_approximate_digit_width does not fit because we have to take in accont ":" character and it makes things much more complicated. I decided that we could just take the widest time string possible (88:88), measure it and set its width as widget's width. I tested it and it seems to work. I will be glad to hear your opinion on this. Patch: https://patchwork.yoctoproject.org/project/oe-core/patch/20260518132106.1296563-1-frezidok1@gmail.com/
Merged, thanks Dmitry! I'll send the recipe update as I have the patch to hand.