]> Dogcows Code - chaz/tint2/commitdiff
*fix* tooltip fixed
authorAndreas Fink <andreas.fink85@googlemail.com>
Thu, 17 Dec 2009 18:25:51 +0000 (18:25 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Thu, 17 Dec 2009 18:25:51 +0000 (18:25 +0000)
*fix* send battery low command if below the value, not exactly the value

src/battery/battery.c
src/tooltip/tooltip.c

index 5c1f6cc8ee814b3f67d84a6eb0fe44bb2b4f15d2..b1f19130cfe178b002696375a9aeb9923944630e 100644 (file)
@@ -43,6 +43,7 @@ static char buf_bat_time[20];
 
 int8_t battery_low_status;
 char *battery_low_cmd=0;
+unsigned char battery_low_cmd_send=0;
 char *path_energy_now=0;
 char *path_energy_full=0;
 char *path_current_now=0;
@@ -266,10 +267,15 @@ void update_battery() {
        if(energy_full > 0)
                new_percentage = (energy_now*100)/energy_full;
 
-       if(battery_low_status != 0 && battery_low_status == new_percentage && battery_state.percentage > new_percentage) {
-               //printf("battery low, executing: %s\n", battery_low_cmd);
-               if (battery_low_cmd) system(battery_low_cmd);
+  if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
+    printf("battery low, executing: %s\n", battery_low_cmd);
+    if (battery_low_cmd)
+      system(battery_low_cmd);
+    battery_low_cmd_send = 1;
        }
+  if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
+    battery_low_cmd_send = 0;
+  }
 
        battery_state.percentage = new_percentage;
 
index fe8866225d319b2583789550c2332859ea392a0b..ba1acfe9a127336236df7b947dd24196972c3f15 100644 (file)
@@ -108,7 +108,10 @@ void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root)
 
 void tooltip_show()
 {
-       Area* area = click_area(g_tooltip.panel, x, y);
+  int mx, my;
+  Window w;
+  XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w);
+  Area* area = click_area(g_tooltip.panel, mx, my);
        stop_timeouts();
        if (!g_tooltip.mapped && area->_get_tooltip_text) {
                tooltip_copy_text(area);
This page took 0.025774 seconds and 4 git commands to generate.