processcontroller: Scale up width on high core counts
* 4 cores or less, use static table. More make view larger. * 16 cores or less, 2px CPU bars * More than 16 cores, 1px CPU bars * Tested through 128 cores in qemu Change-Id: I5fb460e7ee5848d0395b109acc602e86f4d5bbd7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3616 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Alex von Gluck IV
parent
61282f9574
commit
c38dea9e37
@@ -29,7 +29,17 @@ PCWindow::PCWindow()
|
||||
preferences.SaveInt32(kCurrentVersion, kVersionName);
|
||||
preferences.LoadWindowPosition(this, kPosPrefName);
|
||||
|
||||
SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767);
|
||||
system_info info;
|
||||
get_system_info(&info);
|
||||
int width = 15;
|
||||
if (info.cpu_count > 4)
|
||||
width = info.cpu_count;
|
||||
if (info.cpu_count <= 16)
|
||||
width *= 2;
|
||||
|
||||
// For the memory bar
|
||||
width += 8;
|
||||
|
||||
BRect rect = Bounds();
|
||||
|
||||
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
@@ -38,8 +48,11 @@ PCWindow::PCWindow()
|
||||
|
||||
// set up a rectangle && instantiate a new view
|
||||
// view rect should be same size as window rect but with left top at (0, 0)
|
||||
rect.Set(0, 0, 15, 15);
|
||||
rect.Set(0, 0, width, 15);
|
||||
SetSizeLimits(rect.Width() + 21, rect.Width() + 21, 15 + 21, 15 + 21);
|
||||
|
||||
rect.OffsetTo((Bounds().Width() - 16) / 2, (Bounds().Height() - 16) / 2);
|
||||
|
||||
topView->AddChild(new ProcessController(rect));
|
||||
|
||||
// make window visible
|
||||
|
||||
@@ -117,14 +117,6 @@ layoutT layout[] = {
|
||||
{ 3, 1, 4 }, // 2
|
||||
{ 2, 1, 3 },
|
||||
{ 2, 0, 3 }, // 4
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 2 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 0, 3 }, // 8
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 0, 3 },
|
||||
{ 1, 0, 2 },
|
||||
{ 1, 0, 1 } // 12
|
||||
};
|
||||
|
||||
|
||||
@@ -135,7 +127,23 @@ extern "C" _EXPORT BView*
|
||||
instantiate_deskbar_item(float maxWidth, float maxHeight)
|
||||
{
|
||||
gInDeskbar = true;
|
||||
return new ProcessController(maxHeight - 1, maxHeight - 1);
|
||||
|
||||
system_info info;
|
||||
get_system_info(&info);
|
||||
int width = 15;
|
||||
if (info.cpu_count > 4)
|
||||
width = info.cpu_count;
|
||||
if (info.cpu_count <= 16)
|
||||
width *= 2;
|
||||
|
||||
// For the memory bar
|
||||
width += 8;
|
||||
|
||||
// Damn, you got a lot of CPU
|
||||
if (width > maxWidth)
|
||||
width = maxWidth;
|
||||
|
||||
return new ProcessController(width - 1, maxHeight - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -600,8 +608,8 @@ ProcessController::DoDraw(bool force)
|
||||
float barWidth;
|
||||
float barGap;
|
||||
float memWidth;
|
||||
if (gCPUcount <= 12 && bounds.Width() == 15) {
|
||||
// Use fixed sizes for small icon sizes
|
||||
if (gCPUcount <= 4 && bounds.Width() == 15) {
|
||||
// Use fixed sizes for small CPU counts
|
||||
barWidth = layout[gCPUcount].cpu_width;
|
||||
barGap = layout[gCPUcount].cpu_inter;
|
||||
memWidth = layout[gCPUcount].mem_width;
|
||||
|
||||
Reference in New Issue
Block a user