[PATCH] taskmgr: Use different units depending on memory usage.
Vijay Kiran Kamuju
infyquest at gmail.com
Wed Apr 3 05:45:42 CDT 2019
From: Michael Müller <michael at fds-team.de>
From: Michael Müller <michael at fds-team.de>
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
programs/taskmgr/graph.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/programs/taskmgr/graph.c b/programs/taskmgr/graph.c
index 7e978e16f7a..eb2a4a3ba8e 100644
--- a/programs/taskmgr/graph.c
+++ b/programs/taskmgr/graph.c
@@ -239,8 +239,10 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
/* Top bars that are "unused", i.e. are dark green, representing free memory */
int i;
- static const WCHAR wszFormat[] = {'%','d','K',0};
-
+ static const WCHAR wszFormatKB[] = {'%','u',' ','K','B',0};
+ static const WCHAR wszFormatMB[] = {'%','u',' ','M','B',0};
+ static const WCHAR wszFormatGB[] = {'%','.','1','f',' ','G','B',0};
+
/*
* Get the client area rectangle
*/
@@ -257,8 +259,13 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
- swprintf(Text, wszFormat, (int)CommitChargeTotal);
-
+ if (CommitChargeTotal > 1048576)
+ swprintf(Text, wszFormatGB, (float)CommitChargeTotal / 1048576);
+ else if (CommitChargeTotal > 1024)
+ swprintf(Text, wszFormatMB, (DWORD)CommitChargeTotal / 1024);
+ else
+ swprintf(Text, wszFormatKB, (DWORD)CommitChargeTotal);
+
/*
* Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text
--
2.17.0
More information about the wine-devel
mailing list