Bug 15435 - Clock in the desktop panel resizes
Summary: Clock in the desktop panel resizes
Status: RESOLVED FIXED
Alias: None
Product: Matchbox
Classification: Yocto Project Subprojects
Component: matchbox (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 6.1
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard: newcomer
Depends on:
Blocks:
 
Reported: 2024-03-07 15:16 UTC by Richard Purdie
Modified: 2026-05-21 15:55 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Purdie 2024-03-07 15:16:35 UTC
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.
Comment 1 Ross Burton 2024-10-10 11:15:05 UTC
This can be done with pango_font_metrics_get_approximate_digit_width().
Comment 2 Dmitry Sakhonchik 2026-04-23 07:51:46 UTC
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.
Comment 3 Randy MacLeod 2026-05-07 20:49:55 UTC
Ross, question for you from Dmitry
Comment 4 Ross Burton 2026-05-08 14:04:22 UTC
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);
Comment 5 Dmitry Sakhonchik 2026-05-18 13:40:36 UTC
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/
Comment 6 Ross Burton 2026-05-21 15:55:48 UTC
Merged, thanks Dmitry! I'll send the recipe update as I have the patch to hand.