|
|
188765f |
From f10ab9b513241a08af69f50f985b972715e27f07 Mon Sep 17 00:00:00 2001
|
|
|
188765f |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
188765f |
Date: Thu, 4 Jul 2019 11:45:09 +0200
|
|
|
188765f |
Subject: [PATCH] clients/lcdproc: MemTop: be smarter about how much processes
|
|
|
188765f |
to show
|
|
|
188765f |
|
|
|
188765f |
Instead of hardcoding the number of processes to 5, which only works
|
|
|
188765f |
well for LCDs with 4 lines or less, do the following:
|
|
|
188765f |
|
|
|
188765f |
On LCDs with 4 lines or less show 5 processes (no change)
|
|
|
188765f |
|
|
|
188765f |
On LCDs with 5 lines we have 4 free lines, showing 5 processes with
|
|
|
188765f |
scrolling here makes things look like we scroll 1 line down and then 1
|
|
|
188765f |
line back up again, which looks wrong (*). So show 4 processes here.
|
|
|
188765f |
|
|
|
188765f |
On LCDs with 6 lines or more, show as many processes as will fit so that
|
|
|
188765f |
we use the entire screen.
|
|
|
188765f |
|
|
|
188765f |
Note that the last 2 cases both come down to showing as many lines as
|
|
|
188765f |
will fit.
|
|
|
188765f |
|
|
|
188765f |
*) This happens e.g. on the LCD panel in various Logitech keyboards, which
|
|
|
188765f |
fits 5 lines.
|
|
|
188765f |
|
|
|
188765f |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
188765f |
---
|
|
|
188765f |
clients/lcdproc/mem.c | 27 ++++++++++++++++++++++-----
|
|
|
188765f |
1 file changed, 22 insertions(+), 5 deletions(-)
|
|
|
188765f |
|
|
|
188765f |
diff --git a/clients/lcdproc/mem.c b/clients/lcdproc/mem.c
|
|
|
188765f |
index 187d421..ddec98c 100644
|
|
|
188765f |
--- a/clients/lcdproc/mem.c
|
|
|
188765f |
+++ b/clients/lcdproc/mem.c
|
|
|
188765f |
@@ -224,7 +224,7 @@ sort_procs(void *a, void *b)
|
|
|
188765f |
|
|
|
188765f |
|
|
|
188765f |
/**
|
|
|
188765f |
- * Mem Top Screen displays info about top 5 memory hogs...
|
|
|
188765f |
+ * Mem Top Screen displays info about top memory hogs...
|
|
|
188765f |
*
|
|
|
188765f |
*\verbatim
|
|
|
188765f |
*
|
|
|
188765f |
@@ -246,8 +246,25 @@ int
|
|
|
188765f |
mem_top_screen(int rep, int display, int *flags_ptr)
|
|
|
188765f |
{
|
|
|
188765f |
LinkedList *procs;
|
|
|
188765f |
+ int lines;
|
|
|
188765f |
int i;
|
|
|
188765f |
|
|
|
188765f |
+ /* On screen <= 4 lines show info for 5 processes and use scrolling */
|
|
|
188765f |
+ if (lcd_hgt <= 4)
|
|
|
188765f |
+ lines = 5;
|
|
|
188765f |
+ /*
|
|
|
188765f |
+ * On 5 lines displays we have 4 free lines, using 5 lines with
|
|
|
188765f |
+ * scrolling here makes things look like we scroll 1 line down and
|
|
|
188765f |
+ * then 1 line back up again, which looks wrong. So we use as many
|
|
|
188765f |
+ * lines as fit (4) instead of 5 on a 5 lines display, so that we do
|
|
|
188765f |
+ * not get the weird scrolling.
|
|
|
188765f |
+ *
|
|
|
188765f |
+ * Likewise for > 5 lines we also want to show as many lines as fit
|
|
|
188765f |
+ * so that we use the entire screen.
|
|
|
188765f |
+ */
|
|
|
188765f |
+ else
|
|
|
188765f |
+ lines = lcd_hgt - 1;
|
|
|
188765f |
+
|
|
|
188765f |
if ((*flags_ptr & INITIALIZED) == 0) {
|
|
|
188765f |
*flags_ptr |= INITIALIZED;
|
|
|
188765f |
|
|
|
188765f |
@@ -260,12 +277,12 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|
|
188765f |
sock_send_string(sock, "widget_add S f frame\n");
|
|
|
188765f |
|
|
|
188765f |
/* scroll rate: 1 line every X ticks (= 1/8 sec) */
|
|
|
188765f |
- sock_printf(sock, "widget_set S f 1 2 %i %i %i 5 v %i\n",
|
|
|
188765f |
- lcd_wid, lcd_hgt, lcd_wid,
|
|
|
188765f |
+ sock_printf(sock, "widget_set S f 1 2 %i %i %i %i v %i\n",
|
|
|
188765f |
+ lcd_wid, lcd_hgt, lcd_wid, lines,
|
|
|
188765f |
((lcd_hgt >= 4) ? 8 : 12));
|
|
|
188765f |
|
|
|
188765f |
/* frame contents */
|
|
|
188765f |
- for (i = 1; i <= 5; i++) {
|
|
|
188765f |
+ for (i = 1; i <= lines; i++) {
|
|
|
188765f |
sock_printf(sock, "widget_add S %i string -in f\n", i);
|
|
|
188765f |
}
|
|
|
188765f |
sock_send_string(sock, "widget_set S 1 1 1 Checking...\n");
|
|
|
188765f |
@@ -291,7 +308,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|
|
188765f |
LL_Rewind(procs);
|
|
|
188765f |
LL_Sort(procs, sort_procs);
|
|
|
188765f |
LL_Rewind(procs);
|
|
|
188765f |
- for (i = 1; i <= 5; i++) {
|
|
|
188765f |
+ for (i = 1; i <= lines; i++) {
|
|
|
188765f |
procinfo_type *p = LL_Get(procs);
|
|
|
188765f |
|
|
|
188765f |
if (p != NULL) {
|
|
|
188765f |
--
|
|
|
188765f |
2.21.0
|
|
|
188765f |
|