]> Dogcows Code - chaz/tint2/blobdiff - src/battery/battery.c
*fix* battery: set background_id to 0 if none has been specified
[chaz/tint2] / src / battery / battery.c
index faf27e9f5a1596a99ee065aac8650c4c0d452f59..2b4780e24b7d87e30e94674bfc5423974e9cbd49 100644 (file)
@@ -238,6 +238,9 @@ void init_battery_panel(void *p)
        if (!battery_enabled)
                return;
 
+       if (battery->area.bg == 0)
+               battery->area.bg = &g_array_index(backgrounds, Background, 0);
+
        battery->area.parent = p;
        battery->area.panel = p;
        battery->area._draw_foreground = draw_battery;
@@ -460,8 +463,8 @@ int resize_battery(void *obj)
                if (new_size > battery->area.width || new_size < (battery->area.width-2)) {
                        // we try to limit the number of resize
                        battery->area.width =  new_size;
-                       battery->bat1_posy = ((battery->area.height - bat_percentage_height) / 2) - ((bat_time_height_ink + 2) / 2);
-                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
+                       battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height)/2;
+                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height;
                        ret = 1;
                }
        }
@@ -469,8 +472,8 @@ int resize_battery(void *obj)
                int new_size = bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
                if (new_size > battery->area.height || new_size < (battery->area.height-2)) {
                        battery->area.height =  new_size;
-                       battery->bat1_posy = ((battery->area.height - bat_percentage_height) / 2) - ((bat_time_height_ink + 2) / 2);
-                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
+                       battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2)/2;
+                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2;
                        ret = 1;
                }
        }
This page took 0.025256 seconds and 4 git commands to generate.