From patchwork Thu Jun 16 20:29:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1996 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 421E223E54 for ; Thu, 16 Jun 2011 20:31:49 +0000 (UTC) Received: from mail-vw0-f50.google.com (mail-vw0-f50.google.com [209.85.212.50]) by fiordland.canonical.com (Postfix) with ESMTP id 1243AA18585 for ; Thu, 16 Jun 2011 20:31:48 +0000 (UTC) Received: by mail-vw0-f50.google.com with SMTP id 14so1756035vws.37 for ; Thu, 16 Jun 2011 13:31:48 -0700 (PDT) Received: by 10.52.162.72 with SMTP id xy8mr1940969vdb.87.1308256308858; Thu, 16 Jun 2011 13:31:48 -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 em2cs211211vdc; Thu, 16 Jun 2011 13:31:48 -0700 (PDT) Received: by 10.227.165.69 with SMTP id h5mr1303983wby.78.1308256304732; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by mx.google.com with ESMTP id p18si1376265wbh.3.2011.06.16.13.31.44; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.130; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.130 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.76.78]) by mwinf5d16 with ME id wkXf1g0031hMfSL03kXjJh; Thu, 16 Jun 2011 22:31:44 +0200 From: Daniel Lezcano To: patches@linaro.org Subject: [PATCH 11/28] refresh the windows instead of killing them and recreate Date: Thu, 16 Jun 2011 22:29:40 +0200 Message-Id: <1308256197-29155-11-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> References: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano --- display.c | 74 +++++++++++++++++++++++---------------------------------- powerdebug.c | 2 +- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/display.c b/display.c index 2ab2167..dd5543c 100644 --- a/display.c +++ b/display.c @@ -45,31 +45,6 @@ static char *win_names[TOTAL_FEATURE_WINS] = { "Sensors" }; -/* "all" : Kill header and footer windows too ? */ -void killall_windows(int all) -{ - if (all && header_win) { - delwin(header_win); - header_win = NULL; - } - if (regulator_win) { - delwin(regulator_win); - regulator_win = NULL; - } - if (clock_win) { - delwin(clock_win); - clock_win = NULL; - } - if (sensor_win) { - delwin(sensor_win); - sensor_win = NULL; - } - if (all && footer_win) { - delwin(footer_win); - footer_win = NULL; - } -} - static void display_fini(void) { endwin(); @@ -99,18 +74,36 @@ int display_init(void) init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED)) return -1; - return atexit(display_fini); -} - -void create_windows(int selectedwindow) -{ + if (atexit(display_fini)) + return -1; getmaxyx(stdscr, maxy, maxx); - killall_windows(1); + + regulator_win = subwin(stdscr, maxy - 2, maxx, 1, 0); + if (!regulator_win) + return -1; + + clock_win = subwin(stdscr, maxy - 2, maxx, 1, 0); + if (!clock_win) + return -1; + + sensor_win = subwin(stdscr, maxy - 2, maxx, 1, 0); + if (!sensor_win) + return -1; header_win = subwin(stdscr, 1, maxx, 0, 0); + if (!header_win) + return -1; + footer_win = subwin(stdscr, 1, maxx, maxy-1, 0); + if (!footer_win) + return -1; + + return 0; +} +void create_windows(int selectedwindow) +{ strcpy(footer_items[0], " Q (Quit) "); strcpy(footer_items[1], " R (Refresh) "); @@ -129,26 +122,19 @@ void create_windows(int selectedwindow) void create_selectedwindow(int selectedwindow) { - WINDOW *win; - - killall_windows(0); - - getmaxyx(stdscr, maxy, maxx); - - win = subwin(stdscr, maxy - 2, maxx, 1, 0); - switch (selectedwindow) { - case REGULATOR: regulator_win = win; + case REGULATOR: + wrefresh(regulator_win); break; - case CLOCK: clock_win = win; + case CLOCK: + wrefresh(clock_win); break; - case SENSOR: sensor_win = win; + case SENSOR: + wrefresh(sensor_win); break; } - - refresh(); } void show_header(int selectedwindow) diff --git a/powerdebug.c b/powerdebug.c index 94dd31a..af8d28c 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -215,7 +215,7 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, keychar = toupper(keystroke); //#define DEBUG #ifdef DEBUG - killall_windows(1); fini_curses(); + fini_curses(); printf("key entered %d:%c\n", keystroke, keychar); exit(1); #endif