Bug 13537

Summary: xclock 1.0.3: Clock.c Initialize(): wrong core.width
Product: xorg Reporter: vdb128 <vdb128>
Component: App/otherAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium Keywords: patch
Version: git   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Initialize() do not overwrite core.width, clock_tic() round display time. none

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.  

Summary--

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.