* Time view was broken
* The view wasn't updated on changes... (you shouldn't develop such an application on a desktop computer) * enlarged the polling interval to 2 seconds. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19146 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,8 +37,8 @@ const uint32 kMsgToggleStatusIcon = 'tgsi';
|
|||||||
const uint32 kMinIconWidth = 16;
|
const uint32 kMinIconWidth = 16;
|
||||||
const uint32 kMinIconHeight = 16;
|
const uint32 kMinIconHeight = 16;
|
||||||
|
|
||||||
const bigtime_t kUpdateInterval = 1000000;
|
const bigtime_t kUpdateInterval = 2000000;
|
||||||
// every second
|
// every two seconds
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
@@ -408,7 +408,7 @@ PowerStatusView::_SetLabel(char* buffer, size_t bufferLength)
|
|||||||
snprintf(buffer, bufferLength, "%s%ld%%%s", open, fPercent, close);
|
snprintf(buffer, bufferLength, "%s%ld%%%s", open, fPercent, close);
|
||||||
else if (fShowTime && fTimeLeft >= 0) {
|
else if (fShowTime && fTimeLeft >= 0) {
|
||||||
snprintf(buffer, bufferLength, "%s%ld:%ld%s",
|
snprintf(buffer, bufferLength, "%s%ld:%ld%s",
|
||||||
open, fTimeLeft / 3600, fTimeLeft / 60, close);
|
open, fTimeLeft / 3600, (fTimeLeft / 60) % 60, close);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +416,10 @@ PowerStatusView::_SetLabel(char* buffer, size_t bufferLength)
|
|||||||
void
|
void
|
||||||
PowerStatusView::_Update(bool force)
|
PowerStatusView::_Update(bool force)
|
||||||
{
|
{
|
||||||
|
int32 previousPercent = fPercent;
|
||||||
|
bool previousTimeLeft = fTimeLeft;
|
||||||
|
bool wasOnline = fOnline;
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
// TODO: retrieve data from APM/ACPI kernel interface
|
// TODO: retrieve data from APM/ACPI kernel interface
|
||||||
fPercent = 42;
|
fPercent = 42;
|
||||||
@@ -436,6 +440,8 @@ PowerStatusView::_Update(bool force)
|
|||||||
fTimeLeft = fPercent >= 0 ? regs[3] : -1;
|
fTimeLeft = fPercent >= 0 ? regs[3] : -1;
|
||||||
if (fTimeLeft > 0xffff)
|
if (fTimeLeft > 0xffff)
|
||||||
fTimeLeft = -1;
|
fTimeLeft = -1;
|
||||||
|
else if (fTimeLeft & 0x8000)
|
||||||
|
fTimeLeft = (fTimeLeft & 0x7fff) * 60;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -459,7 +465,9 @@ PowerStatusView::_Update(bool force)
|
|||||||
ResizeTo(width, Bounds().Height());
|
ResizeTo(width, Bounds().Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force)
|
if (force || wasOnline != fOnline
|
||||||
|
|| (fShowTime && fTimeLeft != previousTimeLeft)
|
||||||
|
|| (!fShowTime && fPercent != previousPercent))
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user