]> Dogcows Code - chaz/tint2/blobdiff - src/clock/clock.c
fixed issue 98
[chaz/tint2] / src / clock / clock.c
index eaaf69cb83e8a3c493f39151f4d5778c8be72899..01b1991e247d090e85015c720403ef4b9cedd086 100644 (file)
@@ -44,12 +44,29 @@ static char buf_time[40];
 static char buf_date[40];
 
 
+void init_precision()
+{
+       if (!time1_format) time_precision = 60;
+       else if (strchr(time1_format, 'S')) time_precision = 1;
+       else if (strchr(time1_format, 'T')) time_precision = 1;
+       else if (strchr(time1_format, 'r')) time_precision = 1;
+       else time_precision = 60;
+}
+
+
 void init_clock()
 {
    Panel *panel;
    Clock *clock;
    int i, time_height, time_height_ink, date_height, date_height_ink;
 
+       init_precision();
+       // update clock to force update (-time_precision)
+       struct timeval stv;
+       gettimeofday(&stv, 0);
+       time_clock.tv_sec = stv.tv_sec - time_precision;
+       time_clock.tv_sec -= time_clock.tv_sec % time_precision;
+
        for (i=0 ; i < nb_panel ; i++) {
           panel = &panel1[i];
           clock = &panel->clock;
@@ -61,17 +78,6 @@ void init_clock()
 
                if (!clock->area.on_screen) continue;
 
-               if (strchr(time1_format, 'S')) time_precision = 1;
-               else if (strchr(time1_format, 'T')) time_precision = 1;
-               else if (strchr(time1_format, 'r')) time_precision = 1;
-               else time_precision = 60;
-
-               // update clock to force update (-time_precision)
-               struct timeval stv;
-               gettimeofday(&stv, 0);
-               time_clock.tv_sec = stv.tv_sec - time_precision;
-               time_clock.tv_sec -= time_clock.tv_sec % time_precision;
-
                clock->area.posy = panel->area.pix.border.width + panel->area.paddingy;
                clock->area.height = panel->area.height - (2 * clock->area.posy);
                clock->area.resize = 1;
@@ -169,7 +175,6 @@ void resize_clock (void *obj)
    new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
 
    if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
-      int i;
       Panel *panel = ((Area*)obj)->panel;
 
       printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
@@ -179,9 +184,8 @@ void resize_clock (void *obj)
       clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
 
       // resize other objects on panel
-               for (i=0 ; i < nb_panel ; i++) {
-                       panel1[i].area.resize = 1;
-               }
+               panel->area.resize = 1;
+               panel->battery.area.resize = 1;
                systray.area.resize = 1;
                panel_refresh = 1;
    }
This page took 0.020463 seconds and 4 git commands to generate.