Modify ProcessController's System Resources and Caches item: it
now shows cache and total committed mem respectively. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24801 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -30,12 +30,12 @@
|
|||||||
KernelMemoryBarMenuItem::KernelMemoryBarMenuItem(system_info& systemInfo)
|
KernelMemoryBarMenuItem::KernelMemoryBarMenuItem(system_info& systemInfo)
|
||||||
: BMenuItem("System Resources & Caches...", NULL)
|
: BMenuItem("System Resources & Caches...", NULL)
|
||||||
{
|
{
|
||||||
fTotalWriteMemory = -1;
|
|
||||||
fLastSum = -1;
|
fLastSum = -1;
|
||||||
fGrenze1 = -1;
|
fGrenze1 = -1;
|
||||||
fGrenze2 = -1;
|
fGrenze2 = -1;
|
||||||
fPhsysicalMemory = float(int(systemInfo.max_pages * B_PAGE_SIZE / 1024));
|
fPhysicalMemory = float(int(systemInfo.max_pages * B_PAGE_SIZE / 1024));
|
||||||
fCommitedMemory = float(int(systemInfo.used_pages * B_PAGE_SIZE / 1024));
|
fCommittedMemory = float(int(systemInfo.used_pages * B_PAGE_SIZE / 1024));
|
||||||
|
fCachedMemory = float(int(systemInfo.cached_pages * B_PAGE_SIZE / 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,14 +49,11 @@ KernelMemoryBarMenuItem::DrawContent()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KernelMemoryBarMenuItem::UpdateSituation(float commitedMemory,
|
KernelMemoryBarMenuItem::UpdateSituation(float committedMemory,
|
||||||
float totalWriteMemory)
|
float cachedMemory)
|
||||||
{
|
{
|
||||||
if (commitedMemory < totalWriteMemory)
|
fCommittedMemory = committedMemory;
|
||||||
totalWriteMemory = commitedMemory;
|
fCachedMemory = cachedMemory;
|
||||||
|
|
||||||
fCommitedMemory = commitedMemory;
|
|
||||||
fTotalWriteMemory = totalWriteMemory;
|
|
||||||
DrawBar(false);
|
DrawBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +68,6 @@ KernelMemoryBarMenuItem::DrawBar(bool force)
|
|||||||
// draw the bar itself
|
// draw the bar itself
|
||||||
BRect cadre (frame.right - kMargin - kBarWidth, frame.top + 5,
|
BRect cadre (frame.right - kMargin - kBarWidth, frame.top + 5,
|
||||||
frame.right - kMargin, frame.top + 13);
|
frame.right - kMargin, frame.top + 13);
|
||||||
if (fTotalWriteMemory < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (fLastSum < 0)
|
if (fLastSum < 0)
|
||||||
force = true;
|
force = true;
|
||||||
@@ -86,8 +81,8 @@ KernelMemoryBarMenuItem::DrawBar(bool force)
|
|||||||
cadre.InsetBy(1, 1);
|
cadre.InsetBy(1, 1);
|
||||||
BRect r = cadre;
|
BRect r = cadre;
|
||||||
|
|
||||||
float grenze1 = cadre.left + (cadre.right - cadre.left) * fTotalWriteMemory / fPhsysicalMemory;
|
float grenze1 = cadre.left + (cadre.right - cadre.left) * fCachedMemory / fPhysicalMemory;
|
||||||
float grenze2 = cadre.left + (cadre.right - cadre.left) * fCommitedMemory / fPhsysicalMemory;
|
float grenze2 = cadre.left + (cadre.right - cadre.left) * fCommittedMemory / fPhysicalMemory;
|
||||||
if (grenze1 > cadre.right)
|
if (grenze1 > cadre.right)
|
||||||
grenze1 = cadre.right;
|
grenze1 = cadre.right;
|
||||||
if (grenze2 > cadre.right)
|
if (grenze2 > cadre.right)
|
||||||
@@ -135,7 +130,7 @@ KernelMemoryBarMenuItem::DrawBar(bool force)
|
|||||||
fGrenze2 = grenze2;
|
fGrenze2 = grenze2;
|
||||||
|
|
||||||
// draw the value
|
// draw the value
|
||||||
double sum = fTotalWriteMemory * FLT_MAX + fCommitedMemory;
|
double sum = fCachedMemory * FLT_MAX + fCommittedMemory;
|
||||||
if (force || sum != fLastSum) {
|
if (force || sum != fLastSum) {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
menu->SetLowColor(gMenuBackColorSelected);
|
menu->SetLowColor(gMenuBackColorSelected);
|
||||||
@@ -150,11 +145,11 @@ KernelMemoryBarMenuItem::DrawBar(bool force)
|
|||||||
menu->SetHighColor(kBlack);
|
menu->SetHighColor(kBlack);
|
||||||
|
|
||||||
char infos[128];
|
char infos[128];
|
||||||
sprintf(infos, "%.1f MB", fTotalWriteMemory / 1024.f);
|
sprintf(infos, "%.1f MB", fCachedMemory / 1024.f);
|
||||||
BPoint loc(cadre.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth(infos),
|
BPoint loc(cadre.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth(infos),
|
||||||
cadre.bottom + 1);
|
cadre.bottom + 1);
|
||||||
menu->DrawString(infos, loc);
|
menu->DrawString(infos, loc);
|
||||||
sprintf(infos, "%.1f MB", fCommitedMemory / 1024.f);
|
sprintf(infos, "%.1f MB", fCommittedMemory / 1024.f);
|
||||||
loc.x = cadre.left - kMargin - menu->StringWidth(infos);
|
loc.x = cadre.left - kMargin - menu->StringWidth(infos);
|
||||||
menu->DrawString(infos, loc);
|
menu->DrawString(infos, loc);
|
||||||
fLastSum = sum;
|
fLastSum = sum;
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ class KernelMemoryBarMenuItem : public BMenuItem {
|
|||||||
virtual void GetContentSize(float* _width, float* _height);
|
virtual void GetContentSize(float* _width, float* _height);
|
||||||
|
|
||||||
void DrawBar(bool force);
|
void DrawBar(bool force);
|
||||||
void UpdateSituation(float commitedMemory, float totalWriteMemory);
|
void UpdateSituation(float committedMemory, float fCachedMemory);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float fTotalWriteMemory;
|
float fCachedMemory;
|
||||||
float fPhsysicalMemory;
|
float fPhysicalMemory;
|
||||||
float fCommitedMemory;
|
float fCommittedMemory;
|
||||||
double fLastSum;
|
double fLastSum;
|
||||||
float fGrenze1;
|
float fGrenze1;
|
||||||
float fGrenze2;
|
float fGrenze2;
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ MemoryBarMenu::Pulse()
|
|||||||
{
|
{
|
||||||
system_info sinfo;
|
system_info sinfo;
|
||||||
get_system_info(&sinfo);
|
get_system_info(&sinfo);
|
||||||
int commitedMemory = int(sinfo.used_pages * B_PAGE_SIZE / 1024);
|
int committedMemory = int(sinfo.used_pages * B_PAGE_SIZE / 1024);
|
||||||
|
int cachedMemory = int(sinfo.cached_pages * B_PAGE_SIZE / 1024);
|
||||||
Window()->BeginViewTransaction();
|
Window()->BeginViewTransaction();
|
||||||
|
|
||||||
// create the list of items to remove, for their team is gone. Update the old teams.
|
// create the list of items to remove, for their team is gone. Update the old teams.
|
||||||
@@ -96,7 +97,7 @@ MemoryBarMenu::Pulse()
|
|||||||
MemoryBarMenuItem* item;
|
MemoryBarMenuItem* item;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (k = 1; (item = (MemoryBarMenuItem*)ItemAt(k)) != NULL; k++) {
|
for (k = 1; (item = (MemoryBarMenuItem*)ItemAt(k)) != NULL; k++) {
|
||||||
int m = item->UpdateSituation(commitedMemory);
|
int m = item->UpdateSituation(committedMemory);
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
if (lastRecycle == fRecycleCount) {
|
if (lastRecycle == fRecycleCount) {
|
||||||
fRecycleCount += EXTRA;
|
fRecycleCount += EXTRA;
|
||||||
@@ -157,7 +158,7 @@ MemoryBarMenu::Pulse()
|
|||||||
infos.team_info.team, infos.team_icon, true, NULL));
|
infos.team_info.team, infos.team_icon, true, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
int m = item->UpdateSituation(commitedMemory);
|
int m = item->UpdateSituation(committedMemory);
|
||||||
if (m >= 0) {
|
if (m >= 0) {
|
||||||
total += m;
|
total += m;
|
||||||
item = NULL;
|
item = NULL;
|
||||||
@@ -181,7 +182,7 @@ MemoryBarMenu::Pulse()
|
|||||||
fLastTotalTime = system_time();
|
fLastTotalTime = system_time();
|
||||||
KernelMemoryBarMenuItem *kernelItem;
|
KernelMemoryBarMenuItem *kernelItem;
|
||||||
if ((kernelItem = (KernelMemoryBarMenuItem*)ItemAt(0)) != NULL)
|
if ((kernelItem = (KernelMemoryBarMenuItem*)ItemAt(0)) != NULL)
|
||||||
kernelItem->UpdateSituation(commitedMemory, total);
|
kernelItem->UpdateSituation(committedMemory, cachedMemory);
|
||||||
|
|
||||||
Window()->EndViewTransaction();
|
Window()->EndViewTransaction();
|
||||||
Window()->Flush();
|
Window()->Flush();
|
||||||
|
|||||||
Reference in New Issue
Block a user