Bug 13537 - xclock 1.0.3: Clock.c Initialize(): wrong core.width
Summary: xclock 1.0.3: Clock.c Initialize(): wrong core.width
Alias: None
Product: xorg
Classification: Unclassified
Component: App/other (show other bugs)
Version: git
Hardware: All All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
Keywords: patch
Depends on:
Reported: 2007-12-05 11:11 UTC by vdb128
Modified: 2007-12-20 16:13 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Initialize() do not overwrite core.width, clock_tic() round display time. (13.49 KB, patch)
2007-12-05 11:15 UTC, vdb128
no flags Details | Splinter Review

Description vdb128 2007-12-05 11:11:20 UTC
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.  


extension: clock_tic()
   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.
Comment 1 vdb128 2007-12-05 11:15:25 UTC
Created attachment 12964 [details] [review]
Initialize() do not overwrite core.width, clock_tic() round display time.
Comment 2 Alan Coopersmith 2007-12-20 16:13:25 UTC
Thanks for the fixes - they all look fine, so I've pushed to git master.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.