The patch below proposes an extension for and resolves 3 bugs
of xclock 1.0.3. I think the code and comments should be
self-explanatory, but if there are questions just ask and I
will describe the underlying logic.
The update period is used to round the next display time. Thus e.g.
a value of 15 s results in redisplays at :00 :15 :30 :45 :00 ...
bug 1: Initialize ()
if XRENDER && w->clock.render && !defined(NO_I18N) && !no_locale
then the already computed min_width is overwritten by the plain
font rule: min_width = XTextWidth(w->clock.font, str, len) + ...
The new behaviour conforms to xclock 1.0.2.
reproduce: xclock -d -utime -fn 10x20 (notice the wide window)
bug 2: RenderTextBounds ()
The offset off is relative to str[0..off..len-1] and can't be used
for utf8_str due to multibyte characters. This patch calls
clock_to_utf8() first for the head and then for the tail.
bug 3: clock_tic()
if(!w->clock.utf8) && defined(HAVE_ICONV)
then the head to skip is taken into account by
utf8_str = clock_to_utf8(time_ptr + i, len - i)
so there is no need for 'strlen(utf8_str) - i' afterwards.
Created attachment 12964 [details] [review]
Initialize() do not overwrite core.width, clock_tic() round display time.
Thanks for the fixes - they all look fine, so I've pushed to git master.