Ticket #6952: powerstatus_r1.patch

File powerstatus_r1.patch, 1.3 KB (added by kallisti5, 13 years ago)

powerstatus patch hrev1

  • src/apps/powerstatus/PowerStatusView.cpp

     
    177177        rect.left - 1, floorf(rect.bottom - rect.Height() / 4)));
    178178
    179179    int32 percent = fPercent;
    180     if (percent > 100 || percent < 0 || !fHasBattery)
     180    if (percent > 100)
    181181        percent = 100;
     182    else if (percent < 0 || !fHasBattery)
     183        percent = 0;
    182184
    183185    if (percent > 0) {
    184186        rect.InsetBy(gap, gap);
     
    332334
    333335    _GetBatteryInfo(&fBatteryInfo, fBatteryID);
    334336
    335     if (fBatteryInfo.full_capacity != 0)
     337    fHasBattery = (fBatteryInfo.state & BATTERY_CRITICAL_STATE) == 0;
     338
     339    if (fBatteryInfo.full_capacity > 0 && fHasBattery) {
    336340        fPercent = (100 * fBatteryInfo.capacity) / fBatteryInfo.full_capacity;
    337 
    338     fTimeLeft = fBatteryInfo.time_left;
    339     if ((fBatteryInfo.state & BATTERY_CHARGING) != 0)
    340         fOnline = true;
    341     else
     341        fOnline = (fBatteryInfo.state & BATTERY_CHARGING) != 0;
     342        fTimeLeft = fBatteryInfo.time_left;
     343    } else {
     344        fPercent = 0;
    342345        fOnline = false;
     346        fTimeLeft = false;
     347    }
    343348
    344     // TODO: if critical really means that, its name should be changed...
    345     fHasBattery = (fBatteryInfo.state & BATTERY_CRITICAL_STATE) == 0
    346         && fPercent >= 0;
    347349
    348350    if (fInDeskbar) {
    349351        // make sure the tray icon is large enough