On Mon, 09 Feb 2009, bill lam wrote:
>       while(running && !XNextEvent(dpy, &ev)) {
> +             {
> +                     time_t  t;
> + 
> +                     t = time(NULL);
> +                     strftime(stext, sizeof stext - 1, "%a %e %b, %I:%M%p", 
> localtime(&t));
> +             /* Depending on the implementation of strftime, stext might
> +              * not be null terminated. */
> +             stext[sizeof stext - 1] = '\0';
> +                     drawbar();
> +             }
>               if(handler[ev.type])
>                       (handler[ev.type])(&ev); /* call handler */
>       }

On further testing, this eats up a lot of cpu time, the following
should be better,

while(running && !XNextEvent(dpy, &ev)) {
        if(handler[ev.type])
        {
                {
                        time_t  t;

                        t = time(NULL);
                        strftime(stext, sizeof stext - 1, "%a %e %b, %I:%M%p", 
localtime(&t));
            /* Depending on the implementation of strftime, stext might
             * not be null terminated. */
            stext[sizeof stext - 1] = '\0';
                        drawbar();
                }
                (handler[ev.type])(&ev); /* call handler */
        }
}

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩150 劉禹錫  蜀先主廟
    天地英雄氣  千秋尚凜然  勢分三足鼎  業復五銖錢
    得相能開國  生兒不象賢  淒涼蜀故妓  來舞魏宮前

Reply via email to