From kde-commits Thu Dec 12 15:54:44 2002 From: George Staikos Date: Thu, 12 Dec 2002 15:54:44 +0000 To: kde-commits Subject: kdeutils/klaptopdaemon X-MARC-Message: https://marc.info/?l=kde-commits&m=103970856503330 CVS commit by staikos: round percentage to nearest int, not floor() (now I get 100% battery! yay!) commit old and partially incomplete patch that I had. makes have_apm return true on machines where pmu is present but apm is not, so that any new apm functionality in klaptopdaemon will get enabled automatically still. will only affect systems with pmu present. the incomplete part is that having /proc/pmu is not enough. it should also check to see that a battery is present perhaps. M +8 -3 portable.cpp 1.39 --- kdeutils/klaptopdaemon/portable.cpp #1.38:1.39 @@ -71,4 +71,5 @@ #include #include +#include #include #include @@ -201,5 +202,5 @@ pmu_read(apm_info *ap) bf.close(); } - ap->battery_percentage = int(100.0*float(float(charge)/float(maxcharge))); + ap->battery_percentage = int(rint(100.0*float(float(charge)/float(maxcharge)))); ap->battery_time = timerem; @@ -477,6 +478,10 @@ has_apm() } - if (val == 0) + if (val == 0) { val = have_pmu(); + if (val && pmu_read(&apmx)) { + val = 0; + } + } return(val); }