From 8f259bc5e1b9a6a95c16b971cf4733cf76725c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Fri, 10 Sep 2021 15:28:42 +0200 Subject: MemorySwapMeter: align with CPU meter Use the same width for each sub meter to align with CPU meter. Currently if the total width is even, so it does not split exactly into 2 equal parts plus 1 (for the middle space character column), the extra column is added to the second meter width. Closes: #783 --- MemorySwapMeter.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'MemorySwapMeter.c') diff --git a/MemorySwapMeter.c b/MemorySwapMeter.c index b653cf21..ffd57331 100644 --- a/MemorySwapMeter.c +++ b/MemorySwapMeter.c @@ -33,10 +33,14 @@ static void MemorySwapMeter_updateValues(Meter* this) { static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) { MemorySwapMeterData* data = this->meterData; + /* Use the same width for each sub meter to align with CPU meter */ + const int colwidth = w / 2; + const int diff = w - colwidth * 2; + assert(data->memoryMeter->draw); - data->memoryMeter->draw(data->memoryMeter, x, y, w / 2); + data->memoryMeter->draw(data->memoryMeter, x, y, colwidth); assert(data->swapMeter->draw); - data->swapMeter->draw(data->swapMeter, x + w / 2, y, w - w / 2); + data->swapMeter->draw(data->swapMeter, x + colwidth + diff, y, colwidth); } static void MemorySwapMeter_init(Meter* this) { -- cgit v1.2.3