From patchwork Mon Jun 20 22:58:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2093 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 51C1523E54 for ; Mon, 20 Jun 2011 22:58:55 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 22E38A182CD for ; Mon, 20 Jun 2011 22:58:55 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so4124077vws.11 for ; Mon, 20 Jun 2011 15:58:55 -0700 (PDT) Received: by 10.52.112.106 with SMTP id ip10mr4671359vdb.127.1308610734939; Mon, 20 Jun 2011 15:58:54 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs32803vdc; Mon, 20 Jun 2011 15:58:54 -0700 (PDT) Received: by 10.216.61.8 with SMTP id v8mr1504078wec.83.1308610732866; Mon, 20 Jun 2011 15:58:52 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by mx.google.com with ESMTP id k64si14004950weq.9.2011.06.20.15.58.51; Mon, 20 Jun 2011 15:58:51 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.95.191]) by mwinf5d06 with ME id yNyp1g00347kPVY03NyqCk; Tue, 21 Jun 2011 00:58:51 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 03/17] simplify the windows Date: Tue, 21 Jun 2011 00:58:11 +0200 Message-Id: <1308610705-23281-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308610705-23281-1-git-send-email-daniel.lezcano@linaro.org> References: <1308610705-23281-1-git-send-email-daniel.lezcano@linaro.org> We don't need a window per pm block, just a main window refreshed at the right moment is needed. Signed-off-by: Daniel Lezcano --- display.c | 66 +++++++++++++++++++++++++++--------------------------------- 1 files changed, 30 insertions(+), 36 deletions(-) diff --git a/display.c b/display.c index 45446cb..80663a7 100644 --- a/display.c +++ b/display.c @@ -36,6 +36,7 @@ enum { PT_COLOR_DEFAULT = 1, static WINDOW *header_win; static WINDOW *footer_win; +static WINDOW *main_win; static int current_win; int maxx, maxy; @@ -52,7 +53,6 @@ struct rowdata { }; struct windata { - WINDOW *win; WINDOW *pad; struct display_ops *ops; struct rowdata *rowdata; @@ -348,8 +348,8 @@ int display_init(int wdefault) for (i = 0; i < array_size; i++) { - windata[i].win = subwin(stdscr, maxy - 2, maxx, 1, 0); - if (!windata[i].win) + main_win = subwin(stdscr, maxy - 2, maxx, 1, 0); + if (!main_win) return -1; windata[i].pad = newpad(maxrows, maxx); @@ -374,51 +374,45 @@ int display_init(int wdefault) void print_regulator_header(void) { - WINDOW *regulator_win = windata[REGULATOR].win; - - werase(regulator_win); - wattron(regulator_win, A_BOLD); - print(regulator_win, 0, 0, "Name"); - print(regulator_win, 12, 0, "Status"); - print(regulator_win, 24, 0, "State"); - print(regulator_win, 36, 0, "Type"); - print(regulator_win, 48, 0, "Users"); - print(regulator_win, 60, 0, "Microvolts"); - print(regulator_win, 72, 0, "Min u-volts"); - print(regulator_win, 84, 0, "Max u-volts"); - wattroff(regulator_win, A_BOLD); - wrefresh(regulator_win); + werase(main_win); + wattron(main_win, A_BOLD); + print(main_win, 0, 0, "Name"); + print(main_win, 12, 0, "Status"); + print(main_win, 24, 0, "State"); + print(main_win, 36, 0, "Type"); + print(main_win, 48, 0, "Users"); + print(main_win, 60, 0, "Microvolts"); + print(main_win, 72, 0, "Min u-volts"); + print(main_win, 84, 0, "Max u-volts"); + wattroff(main_win, A_BOLD); + wrefresh(main_win); show_header_footer(REGULATOR); } void print_clock_header(void) { - WINDOW *clock_win = windata[CLOCK].win; - - werase(clock_win); - wattron(clock_win, A_BOLD); - print(clock_win, 0, 0, "Name"); - print(clock_win, 56, 0, "Flags"); - print(clock_win, 75, 0, "Rate"); - print(clock_win, 88, 0, "Usecount"); - print(clock_win, 98, 0, "Children"); - wattroff(clock_win, A_BOLD); - wrefresh(clock_win); + werase(main_win); + wattron(main_win, A_BOLD); + print(main_win, 0, 0, "Name"); + print(main_win, 56, 0, "Flags"); + print(main_win, 75, 0, "Rate"); + print(main_win, 88, 0, "Usecount"); + print(main_win, 98, 0, "Children"); + wattroff(main_win, A_BOLD); + wrefresh(main_win); show_header_footer(CLOCK); } void print_sensor_header(void) { - WINDOW *sensor_win = windata[SENSOR].win; - - werase(sensor_win); - wattron(sensor_win, A_BOLD); - print(sensor_win, 0, 0, "Name"); - print(sensor_win, 36, 0, "Value"); - wattroff(sensor_win, A_BOLD); - wrefresh(sensor_win); + werase(main_win); + wattron(main_win, A_BOLD); + print(main_win, 0, 0, "Name"); + print(main_win, 36, 0, "Value"); + wattroff(main_win, A_BOLD); + wrefresh(main_win); show_header_footer(SENSOR); }