Task Manager enhs & fiexs <Pablo <pborobia@gmail.com>
authorAlex Ionescu <aionescu@gmail.com>
Thu, 12 Jan 2006 20:54:35 +0000 (20:54 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Thu, 12 Jan 2006 20:54:35 +0000 (20:54 +0000)
- make a last used cpu usage color memory
- fix colors in the cpu history
- high refresh more offten
- fix kernel cpu usage colorbars paint

Bug 1271.

svn path=/trunk/; revision=20817

reactos/subsys/system/taskmgr/graph.c
reactos/subsys/system/taskmgr/graph.h
reactos/subsys/system/taskmgr/perfpage.c
reactos/subsys/system/taskmgr/taskmgr.c

index bc19756..e05a701 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <precomp.h>
 
+int                nlastBarsUsed = 0;
+
 LONG                OldGraphWndProc;
 
 void                Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
@@ -158,11 +160,8 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
      * Get the CPU usage
      */
     CpuUsage = PerfDataGetProcessorUsage();
-    CpuKernelUsage = PerfDataGetProcessorSystemUsage();
     if (CpuUsage < 0)         CpuUsage = 0;
     if (CpuUsage > 100)       CpuUsage = 100;
-    if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
-    if (CpuKernelUsage > 100) CpuKernelUsage = 100;
 
     /*
      * Check and see how many digits it will take
@@ -197,11 +196,14 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
     {
         nBarsUsed = 1;
     }
-    nBarsFree = nBars - nBarsUsed;
+    nBarsFree = nBars - (nlastBarsUsed>nBarsUsed ? nlastBarsUsed : nBarsUsed);
+    
     if (TaskManagerSettings.ShowKernelTimes)
     {
-        nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100;
-        nBarsUsed -= (nBarsUsedKernel / 2);
+           CpuKernelUsage = PerfDataGetProcessorSystemUsage();
+           if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
+           if (CpuKernelUsage > 100) CpuKernelUsage = 100;
+        nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
     }
     else
     {
@@ -226,7 +228,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
 
     if (nBarsUsedKernel < 0)     nBarsUsedKernel = 0;
     if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
-
+    
     /*
      * Draw the "free" bars
      */
@@ -242,6 +244,25 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
         rcBarRight.bottom += 3;
     }
 
+    /*
+     * Draw the last "used" bars
+     */
+       if ((nlastBarsUsed - nBarsUsed) > 0) {
+           for (i=0; i< (nlastBarsUsed - nBarsUsed); i++)
+           {
+               if (nlastBarsUsed > 5000) nlastBarsUsed = 5000;
+       
+               FillSolidRect(hDC, &rcBarLeft, MEDIUM_GREEN);
+               FillSolidRect(hDC, &rcBarRight, MEDIUM_GREEN);
+       
+               rcBarLeft.top += 3;
+               rcBarLeft.bottom += 3;
+       
+               rcBarRight.top += 3;
+               rcBarRight.bottom += 3;
+           }
+       }
+       nlastBarsUsed = nBarsUsed;
     /*
      * Draw the "used" bars
      */
@@ -262,48 +283,25 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
     /*
      * Draw the "used" kernel bars
      */
-    rcBarLeft.bottom--;
-    rcBarRight.bottom--;
-    if (nBarsUsedKernel && nBarsUsedKernel % 2)
-    {
-        rcBarLeft.top -= 2;
-        rcBarLeft.bottom -= 2;
-
-        rcBarRight.top -= 2;
-        rcBarRight.bottom -= 2;
+    
+    rcBarLeft.top -=3;
+    rcBarLeft.bottom -=3;
 
-        FillSolidRect(hDC, &rcBarLeft, RED);
-        FillSolidRect(hDC, &rcBarRight, RED);
-
-        rcBarLeft.top += 2;
-        rcBarLeft.bottom += 2;
-
-        rcBarRight.top += 2;
-        rcBarRight.bottom += 2;
-
-        nBarsUsedKernel--;
-    }
+    rcBarRight.top -=3;
+    rcBarRight.bottom -=3;
+    
     for (i=0; i<nBarsUsedKernel; i++)
     {
-        if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
 
         FillSolidRect(hDC, &rcBarLeft, RED);
         FillSolidRect(hDC, &rcBarRight, RED);
 
-        rcBarLeft.top++;
-        rcBarLeft.bottom++;
+        rcBarLeft.top -=3;
+        rcBarLeft.bottom -=3;
 
-        rcBarRight.top++;
-        rcBarRight.bottom++;
+        rcBarRight.top -=3;
+        rcBarRight.bottom -=3;
 
-        if (i % 2)
-        {
-            rcBarLeft.top++;
-            rcBarLeft.bottom++;
-
-            rcBarRight.top++;
-            rcBarRight.bottom++;
-        }
     }
 }
 
@@ -338,8 +336,10 @@ void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
     CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
     CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
 
-    _stprintf(Text, _T("%dK"), (int)CommitChargeTotal);
-
+    if (CommitChargeTotal > 1024)
+       _stprintf(Text, _T("%d MB"), (int)(CommitChargeTotal / 1024));
+       else
+               _stprintf(Text, _T("%d K"), (int)CommitChargeTotal);
     /*
      * Draw the font text onto the graph
      * The bottom 20 pixels are reserved for the text
index 8cd0bb6..69b668a 100644 (file)
@@ -29,6 +29,7 @@ extern "C" {
 
 
 #define BRIGHT_GREEN   RGB(0, 255, 0)
+#define MEDIUM_GREEN   RGB(0, 190, 0)
 #define DARK_GREEN             RGB(0, 130, 0)
 #define RED                            RGB(255, 0, 0)
 
index 4316dbd..0c54b83 100644 (file)
@@ -174,8 +174,10 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 /*         PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
         GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
         GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
-        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
-        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(0, 255, 0)) ;
+        
+        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(0, 255, 0)) ;
+        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(255, 0, 0)) ;
+        
 
         GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
         GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
@@ -418,12 +420,19 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
                 *  Get the CPU usage
                 */
                CpuUsage = PerfDataGetProcessorUsage();
-               CpuKernelUsage = PerfDataGetProcessorSystemUsage();
                if (CpuUsage < 0 )        CpuUsage = 0;
                if (CpuUsage > 100)       CpuUsage = 100;
-               if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
-               if (CpuKernelUsage > 100) CpuKernelUsage = 100;
-
+               
+               if (TaskManagerSettings.ShowKernelTimes)
+               {
+                       CpuKernelUsage = PerfDataGetProcessorSystemUsage();
+                       if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
+                       if (CpuKernelUsage > 100) CpuKernelUsage = 100;
+                       } 
+                       else
+                       {
+                               CpuKernelUsage = 0;
+                       }
             /*
              *  Get the memory usage
              */
@@ -435,6 +444,7 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
                        PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
             nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
 
+                        
 
             GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
             GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
index 2bb23ed..5723168 100644 (file)
@@ -873,7 +873,7 @@ void TaskManager_OnViewUpdateSpeedHigh(void)
     CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_HIGH, MF_BYCOMMAND);
 
     KillTimer(hMainWnd, 1);
-    SetTimer(hMainWnd, 1, 1000, NULL);
+    SetTimer(hMainWnd, 1, 500, NULL);
 }
 
 void TaskManager_OnViewUpdateSpeedNormal(void)